A query was run and no Result Maps were found for the Mapped Statement 'user.insertUser!selectKey'. It's likely that neither a Result Type nor a Result Map was specified.


使用mybatis時出現異常問題:

有如下的錯誤

1 Error querying database.  Cause: org.apache.ibatis.executor.ExecutorException: A query was run and no Result Maps were found for the Mapped Statement 'user.insertUser!selectKey'.  It's likely that neither a Result Type nor a Result Map was specified.

這個是使用MyBatis最常見的一種錯誤,從其描述來看是user.insertUser!selectKey這個Statement沒有Result Type或Result Map。下面是我的配置文件的statement:

1 <insert id="insertUser" parameterType="com.luchao.mybatis.first.po.User">
2         <selectKey keyProperty="id" order="AFTER" >
3             select LAST_INSERT_ID()
4         </selectKey>
5         insert into user(username,birthday,sex,address) value (#{username},#{birthday},#{sex},#{address});
6 </insert>

可以看出主要是<selectKey>沒有resultType所致的。

mybatis中不管什么查詢,都必須返回resultType或者resultMap的值,否則就會報錯的。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM