Ibatis的不理解
首先我要做的就是查出一个集合,添加到另外一个表里,之前是没用到RKRQ,是可以添加的,后来加了一个RKRQ,就怎么也不能加,一直报错,说好像是找不到属性?详情:查出集合的数据,里面是Map,Map里有一个字段是RKRQ 就是入库日期,之前用批处理出错了,又改成现在这个样子,还是一样的错误
public int batchAddGrQyGlb(List<Map> gxList){// doBatch(gxList, "Grxy.batchAddGrQyGlb"); for(int i = 0; i < gxList.size(); i++){ Map map = gxList.get(i); sqlMapClient.insert("Grxy.batchAddGrQyGlb", map); } return 1; }
@SuppressWarnings("unchecked") public void doBatch(final List<Map> replyList, final String ibatisId){ // 执行回调 sqlMapClient.execute(new SqlMapClientCallback(){ // 实现回调接口 public Object doInSqlMapClient(SqlMapExecutor executor){ // 开始批处理 try{ executor.startBatch(); for(Map map : replyList){ // 插入操作 sqlMapClient.insert(ibatisId, map); } executor.executeBatch(); }catch(SQLException e){ e.printStackTrace(); } return null; } }); }
<select id="getGxRecords" parameterClass="java.util.HashMap" resultClass="java.util.HashMap"> select fr.SFZJMC, fr.SFZJHM, isNull(dj.FDDBR, fr.XM) XM, dj.NBXH, bg.RKRQ YXQX, dj.RKRQ LASTRKSJ from db_zxxt.ZX_GS_QYDJ dj left join db_zxxt.ZX_GS_FDDBR fr on dj.NBXH = fr.NBXH left join db_zxxt.ZX_GS_BGNR bg on fr.NBXH = bg.NBXH where dj.RKRQ >= #lastRksj# order by dj.RKRQ asc </select>
<insert id="batchAddGrQyGlb" parameterClass="java.util.HashMap"> insert into db_grxy.QYXG_GRQYGLB (SFZJMC, SFZJHM, XM, XYDJ, NBXH, GRLB, YXQX, LASTRKSJ) values ( #SFZJMC:VARCHAR#, #SFZJHM:VARCHAR#, #XM:VARCHAR#, #XYDJ:VARCHAR#, #NBXH#, 'fr', #YXQX:DATE#, #LASTRKSJ:DATE# ) </insert>
select A.CODE,A.NAME,A.GZ COUNTER,B.NAME COUNTERNAME,A.YXBJ
from W_SPPL A,W_GZ B
WHERE A.GZ=B.CODE
<dynamic prepend=" AND ">
<isNotEmpty prepend=" AND " property="code">
A.CODE=#code#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="name">
A.NAME like '%'||#name#||'%'
</isNotEmpty>
<isNotEmpty prepend=" AND " property="counter">
A.GZ=#counter#
</isNotEmpty>
</dynamic>
order by A.CODE
</select>
只要给参数就可以了
ibaties自己封装的 自己执行