ibatis报列名无效的一个异常分析

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里进行处理,可以查看对应的源码进行深入了解:

 


 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值