Navicat版
-- Mysql实现rownum(Mysql更新update字段为rownum)(Hibernate中sql时:=需用/*'*/:=/*'*/替换 否则报错)
set @rownum_mini_shop_goods=0;
update mini_shop_goods a SET a.weighing_num=(select @rownum_mini_shop_goods := @rownum_mini_shop_goods + 1 as nid) where a.enabled_flag=1 and (a.type_code like '25%' or a.type_code like '26%') and a.shop_id='402881e8761e798101761e7a147f0000';
Hibernate中SQL
报错:Space is not allowed after parameter prefix ':'
//Mysql实现rownum(Mysql更新update字段为rownum)(Hibernate中sql时:=需用/*'*/:=/*'*/替换 否则报错)
String sql = "set @rownum_mini_shop_goods=0";
this.excuteUpdateForSQL(sql, null);
//重排称号
String sqlU = "update mini_shop_goods " +
" set weighing_num=(" +
//bug,报错Space is not allowed after parameter prefix ':'
//Hibernate中sql时:=需用/*'*/:=/*'*/替换 否则报错
"select @rownum_mini_shop_goods /*'*/:=/*'*/ @rownum_mini_shop_goods + 1 as nid) " +
//"select @rownum_mini_shop_goods := @rownum_mini_shop_goods + 1 as nid) " +
" where enabled_flag=1 " +
" and (type_code like '25%' " +
" or type_code like '26%') " +
" and shop_id=? ";
this.excuteUpdateForSQL(sqlU, new Object[]{ shopId });