Sql sql = Sqls.create("update @table1 set state = @state where pledge_id in(select pledge_id from @table2 where apply_no = @applyNo)");
sql.setParam("table1", PledgeEntity.class.getAnnotation(Table.class).value());
sql.setParam("table2", ApplyInfoEntity.class.getAnnotation(Table.class).value());
sql.setParam("state", state);
sql.setParam("applyNo", applyNo);
dao.execute(sql);
setParam是只能支持设置where条件中的变量吗?
如上代码,表名如果用这种方法,就会因为自动加了单引号而导致sql执行时报错。
拼完的sql是这样子的:
update ’table1‘ set state = '1' where pledge_id in(select pledge_id from ’table2' where apply_no = '2017082900001')