ibatis动态的传入表名、字段名,主要传入表名和字段名的不一致。
Java代码:
Map<String,Object> params = new HashMap<String,Object>(); params.put("tableName", tableName); params.put("sidFieldName", sidFieldName); params.put("lastDateFiledName", lastDateFiledName); params.put("serviceDateFiledName", serviceDateFiledName); params.put("uidFieldName", uidFieldName); params.put("1", userType); params.put("2", uid); getSqlMapClientTemplate().update("updateUserType" , params);
sqlmap.xml代码:
<update id="updateUserType" parameterClass="map"> <![CDATA[ update /*99*/ $tableName$ SET $sidFieldName$ = #1# , $lastDateFiledName$ = sysdate,$serviceDateFiledName$ = sysdate WHERE $uidFieldName$ = #2# ]]> </update>