ibatis一个很不灵活的地方

最近一直都不爽ibtais,用起来一点都不敏捷。今天发现一处非常不灵活的地方。比如一个DO我有两条SQL,其中一条SQL比另外一条SQL多一个last_like_datetime。我想共用一个resultMap居然会报错:

 

	   <resultMap id="RM-ALBUM" class="TA-ALBUM">
        	<result property="id" 				column="id"/>
        	<result property="gmtCreate" 		column="create_datetime"/>
        	<result property="lastLikeDatetime" 		column="last_like_datetime"/>
       </resultMap>

 

 

 

Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in com/duitang/model/mysql/blog/AlbumDO.xml.  
--- The error occurred while applying a result map.  
--- Check the AlbumDO.RM-ALBUM.  
--- Check the result mapping for the 'lastLikeDatetime' property.  
--- Cause: java.sql.SQLException: Column 'last_like_datetime' not found.
	at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWithCallback(MappedStatement.java:201)
	at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryForObject(MappedStatement.java:120)
	at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:518)
	at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:493)
	at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:106)
	at org.springframework.orm.ibatis.SqlMapClientTemplate$1.doInSqlMapClient(SqlMapClientTemplate.java:270)
	at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:200)
	... 32 more
Caused by: java.sql.SQLException: Column 'last_like_datetime' not found.
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919)
	at com.mysql.jdbc.ResultSetImpl.findColumn(ResultSetImpl.java:1166)
	at com.mysql.jdbc.ResultSetImpl.getTimestamp(ResultSetImpl.java:6229)
	at org.apache.commons.dbcp.DelegatingResultSet.getTimestamp(DelegatingResultSet.java:300)
	at org.apache.commons.dbcp.DelegatingResultSet.getTimestamp(DelegatingResultSet.java:300)
	at com.ibatis.sqlmap.engine.type.DateTypeHandler.getResult(DateTypeHandler.java:38)
	at com.ibatis.sqlmap.engine.mapping.result.ResultMap.getPrimitiveResultMappingValue(ResultMap.java:619)
	at com.ibatis.sqlmap.engine.mapping.result.ResultMap.getResults(ResultMap.java:345)
	at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.java:384)
	at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleMultipleResults(SqlExecutor.java:300)
	at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:189)
	at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.sqlExecuteQuery(MappedStatement.java:221)
	at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWithCallback(MappedStatement.java:189)
	... 38 more

 原来这SB只要发现resultMap有定义字段就会直接调用rs.getResult('column_name')。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值