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

转载于:https://www.cnblogs.com/javaer-sww/p/7800276.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值