springboot+mybatis 的org.mybatis.spring.MyBatisSystemException 解决方法


"nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database.  Cause: java.lang.UnsupportedOperationException\r\n### The error may exist in com/hiteamtech/uws/dao/AppsDao.java (best guess)\r\n### The error may involve com.hiteamtech.uws.dao.AppsDao.findAppInfoByUserId\r\n### The error occurred while handling results\r\n### SQL: SELECT id,app_name,create_time,app_Introduction,user_id from app_info where status = 1 and user_id =? order by id limit ?,?\r\n### Cause: java.lang.UnsupportedOperationException"

以下是我DAO层的代码

和CONTROLLER层代码

@Select("SELECT id,app_name,create_time,app_Introduction,user_id from app_info where status = 1 and user_id =#{userId} order by id limit #{page},#{pageCount}")
List findAppInfoByUserId(@Param("userId") int userId, @Param("page") int page1, @Param("pageCount") int pageCount);



@GetMapping(value = "/apps/{userId}/{page}/{pageCount}")
public ResponseEntity<Map> findAppsByUserId(@PathVariable("userId") int userId, @PathVariable("page") int page, @PathVariable("pageCount") int pageCount,Map<String,Object> map){
log.debug("根据用户ID获取我的产品:"+ userId + "page:" + page+"pageCount:"+ pageCount);
map.put("appCount",iappService.findAppsCount(userId));
map.put("appInfo",iappService.findAppsByUserId(userId,page,pageCount));
return new ResponseEntity<>(map,HttpStatus.OK);
}


因为controller里返回的JSON数据是Map 所以不能用List 返回DAO

可以对DAO做以下修改

@Select("SELECT id,app_name,create_time,app_Introduction,user_id from app_info where status = 1 and user_id =#{userId} order by id limit #{page},#{pageCount}")
List<Map<String,Object>> findAppInfoByUserId(@Param("userId") int userId, @Param("page") int page1, @Param("pageCount") int pageCount);


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM