关于mybatis selectKey的问题

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException: Error selecting key or setting result to parameter object. Cause: org.apache.ibatis.executor.ExecutorException: A query was run and no Result Maps were found for the Mapped Statement 'com.ng.crossquery.entity.po.QueryMapper.addTemplate!selectKey'. It's likely that neither a Result Type nor a Result Map was specified.
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
报错但是数据插入成功了,但是ID的值插入的是0,而不是序列的值!

第1个回答  推荐于2016-10-15
看你的xml,貌似是order的问题。
order的属性
1:BEFORE,会先选择主键,然后设置keyProperty,再执行insert语句;2:AFTER,就先运行insert 语句再运行selectKey 语句。本回答被提问者采纳

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网