spring 整合Mybatis 錯誤:A query was run and no Result Maps were found for the Mapped Statement 'com.xxhh.mapper.XxhhTableBabyCustomMapper.selectAllBaby'. It's likely that neither a Result Type nor a Resul


  運行環境:jdk1.7.0_17+tomcat 7 + spring:3.2.0 +mybatis:3.2.7+ eclipse

  錯誤:A query was run and no Result Maps were found for the Mapped Statement......

  錯誤原因:在使用springmvc+mybatis時候自定義mapper查詢數據是提示以下錯誤

  解決辦法:最后查詢出在我的自定義mapper中沒有寫查詢的返回類型也就是"resultType"每個查詢都會返回個結果集,我們需要讓系統知道返回什么樣的結果集,導致出現下面問題

  錯誤代碼: 

[org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver] - Resolving exception from handler [public java.util.Map<java.lang.String, java.lang.Object> com.xxhh.controller.BabyController.selectAllBaby()]: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException: A query was run and no Result Maps were found for the Mapped Statement 'com.xxhh.mapper.XxhhTableBabyCustomMapper.selectAllBaby'. It's likely that neither a Result Type nor a Result Map was specified.
[org.springframework.web.servlet.DispatcherServlet] - Could not complete request
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException: A query was run and no Result Maps were found for the Mapped Statement 'com.xxhh.mapper.XxhhTableBabyCustomMapper.selectAllBaby'. It's likely that neither a Result Type nor a Result Map was specified.
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:365)
at com.sun.proxy.$Proxy15.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:195)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:119)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
at com.sun.proxy.$Proxy20.selectAllBaby(Unknown Source)

 

  相關代碼:

自定義mapper

    <!--  查詢所有的寶貝 -->
    <select id="selectAllBaby" resultType="com.xxhh.po.XxhhTableBaby">
        SELECT * FROM xxhh_table_baby
    </select>

 


免責聲明!

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



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