ibatis中动态查询返回字段返回用resultClass="java.util.HashMap" Java.sql.SQLException: 列名无效的问题
来源:互联网 发布:手机淘宝如何管理店铺 编辑:程序博客网 时间:2024/04/30 19:14
错误信息:
org.springframework.jdbc.BadSqlGrammarException: SqlMapClient operation; bad SQL grammar []; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in jndi:/localhost/studen/WEB-INF/app-config/query/sqlmap/Test.xml.--- The error occurred while applying a result map.
--- Check the QueryReport_QueryBucketTest.SELECT_QUERYUBUCKETTESTDETAIL_CN-AutoResultMap.
--- Check the result mapping for the 'LPV_CNT_1' property.
--- Cause: Java.sql.SQLException: 列名无效
SQLMAP:
<select id="getWarningRecordListForXXFK" resultClass="java.util.HashMap" parameterClass="java.util.HashMap"> SELECT * FROM $tableName$ WHERE MR_BatchNo IN ( <iterate property="requestList" conjunction=","> #requestList[].ApplyForID# </iterate> )</select>
表名动态传参,获取的结果集也是以Map形式动态返回的
Map<String,Object> paramap = new HashMap<String, Object>();//查询的参数Mapparamap.put("tableName",standardType.getScorrespondTable());paramap.put("requestList",requestList);String sqlId=getEntityName()+".getWarningRecordListForJSHD";List lstResult=warningDao.getSqlMapClientTemplate().queryForList(sqlId, paramap);//查询出来的结果
通过这种方式去接收结果集for(int i=0;i<lstResult.size();i++) { Map result = (Map)lstResult.get(i); String cardNo=result.get("CardNo").toString();}
因为ibatis保留列名为第一次查询时候的列名,第二次查另外一张表的时候,这张表中并没有第一张表的 列,所以就会报列名不存在!!
ibatis可以设置一个参数remapResults="true",每次查询都重新更新列名。
感谢 seng3018 的分享,原文地址:http://blog.csdn.net/seng3018/article/details/7550186
0 0
- ibatis中动态查询返回字段返回用resultClass="java.util.HashMap" Java.sql.SQLException: 列名无效的问题
- ibatis中动态查询返回字段返回用resultClass="java.util.HashMap" 的问题
- ibatis中动态查询表返回用resultClass="java.util.HashMap" 的问题
- ibatis中动态查询表返回用resultClass="java.util.HashMap" 的问题
- ibatis java.sql.SQLException:列名无效
- ibatis用resultClass动态返回查询结果
- ibatis返回结果映射到HashMap时,列名无效的问题
- ibatis resultclass "java.util.hashmap" 缓存
- ibatis 用HashMap解决Ibatis未知列名和列数的查询结果的resultClass映射
- java.sql.SQLException: 列名无效
- java.sql.SQLException: 列名无效
- 使用iBatis中报 java.sql.SQLException: 无效的列类型异常
- ibatis 返回list<String[]>----resultClass="hashMap" 可以实现
- jdbc查询中出错 java.sql.SQLException: 无效的列索引
- java.sql.SQLException: 无效的列类型
- java.sql.SQLException: 无效的列索引
- java.sql.SQLException: 无效的列索引
- java.sql.SQLException: 无效的列索引
- Ubuntu 16.04无线网卡RTL8723BE频繁掉线及信号不足解决办法
- HDU 5727 - Necklace
- Spark1.5堆内存分配
- 【我的Android进阶之旅】解决SVN Cleanup错误: Failed to run the WC DB work queue associated with
- Linux kernel printk的用法
- ibatis中动态查询返回字段返回用resultClass="java.util.HashMap" Java.sql.SQLException: 列名无效的问题
- ES6笔记:正则的扩展
- ROC曲线-阈值评价标准
- 获取信息,组装数据,后台接收流程
- oracle存储过程和自定义函数
- OPENNI学习实践-利用openni和opencv提取人的轮廓
- 深度学习算法的几个难点 | 36大数据
- 相机相册OC 详解
- HDOJ-【1215 七夕节】