"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);
时间: 2024-10-17 10:49:44