码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2017-11-07 19:48:28      阅读:229      评论:0      收藏:0      [点我收藏+]

标签:ons   ror   select   apach   int   amt   bat   bsp   involve   

"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);

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

标签:ons   ror   select   apach   int   amt   bat   bsp   involve   

原文地址:http://www.cnblogs.com/javaer-sww/p/7800276.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!