Caused by: org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; 列名无效; nested exception is java.sql.SQLException: 列名无效
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:212)
at org.springframework.orm.ibatis.SqlMapClientTemplate.executeWithListResult(SqlMapClientTemplate.java:249)
at com.asc.alibaba.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:65)
at com.asc.alibaba.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:47)
at com.asc.alibaba.orm.ibatis.AbstractDaoRouter.query(AbstractDaoRouter.java:66)
at com.asc.alibaba.orm.ibatis.AbstractDaoRouter.query(AbstractDaoRouter.java:175)
at com.alibaba.click.service.app.impl.AppServiceImpl.getUserApps(AppServiceImpl.java:52)
at com.alibaba.click.web.module.screen.app.AppList.execute(AppList.java:38)
at com.alibaba.click.web.module.screen.app.AppList$$FastClassByCGLIB$$be3cb533.invoke(<generated>)
at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
at com.alibaba.citrus.service.moduleloader.impl.adapter.MethodInvoker.invoke(MethodInvoker.java:72)
at com.alibaba.citrus.service.moduleloader.impl.adapter.DataBindingAdapter.execute(DataBindingAdapter.java:37)
at com.alibaba.citrus.turbine.pipeline.valve.PerformScreenValve.performScreenModule(PerformScreenValve.java:100)
... 48 more
Caused by: java.sql.SQLException: 列名无效
at com.asc.alibaba.dao.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:234)
at com.asc.alibaba.dao.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:42)
at com.asc.alibaba.orm.ibatis.SqlMapClientTemplate$2.doInSqlMapClient(SqlMapClientTemplate.java:70)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:209)
ibatis的配置:
<resultMap id="App_ResultMap" class="com.alibaba.click.bean.App" > <result column="ID" property="id" jdbcType="INTEGER" /> <result column="APPNAME" property="appname" jdbcType="VARCHAR" /> <result column="USER_ID" property="userId" jdbcType="INTEGER" /> <result column="STATUS" property="status" jdbcType="CHAR" /> <result column="OWNER" property="owner" jdbcType="VARCHAR" /> <result column="SYNC_TYPE" property="syncType" jdbcType="VARCHAR" /> <result column="CREATE_TIME" property="createTime" /> <result column="MODIFY_TIME" property="modifyTime" /> <result column="LAST_SYNC_TIME" property="lastSyncTime" /> <result column="USERNAME" property="userName" jdbcType="VARCHAR" /> <result column="DW_CLICK_URL" property="dwClickUrl" jdbcType="VARCHAR"/> <result column="DW_EXPOSURE_URL" property="dwExposureUrl" jdbcType="VARCHAR" /> </resultMap> <!-- 查询 --> <select id="query" resultMap="App_ResultMap" parameterClass="java.util.Map" > select CK_APP.ID, CK_APP.APPNAME, CK_APP.USER_ID, CK_APP.STATUS, CK_APP.OWNER, CK_APP.CREATE_TIME, CK_APP.MODIFY_TIME, CK_APP.LAST_SYNC_TIME, wpf_user.USERNAME,CK_APP.DW_CLICK_URL,CK_APP.DW_EXPOSURE_URL from CK_APP, wpf_user where <!-- wpf_user.USER_ID=#userId# AND --> CK_APP.STATUS != '0' AND CK_APP.USER_ID = wpf_user.USER_ID <!-- AND CK_APP.ID in <iterate open="(" close=")" conjunction="," property="appIdList"> #appIdList[]# </iterate> --> </select>
这里query的select语句查询出来的少了一个resultmap的一个字段 <result column="SYNC_TYPE" property="syncType" jdbcType="VARCHAR" />,所以报列名无效,
在下面的两个类里面会对查询结果根据resultmap反射到对应的bean里进行处理,可以查看对应的源码进行深入了解: