简体   繁体   English

使用 Spring Data JPA 时无法提取 ResultSet

[英]Could not extract ResultSet while using Spring Data JPA

I am trying to extract result set from my database using Spring Boot and Spring Data jpa.我正在尝试使用 Spring Boot 和 Spring Data jpa 从我的数据库中提取结果集。 When I am applying jpa query I am getting the following error in my Postman application:当我应用 jpa 查询时,我的 Postman 应用程序出现以下错误:

{
"timestamp": "2020-09-25T06:28:05.202+0000",
"status": 500,
"error": "Internal Server Error",
"message": "Parameter value element [{0=com.spacestudy.model.Users@2357844c}] did not match expected type [java.lang.Integer (n/a)]; nested exception is java.lang.IllegalArgumentException: Parameter value element [{0=com.spacestudy.model.Users@2357844c}] did not match expected type [java.lang.Integer (n/a)]",
"path": "/spacestudy/rockefeller/security/retrieveUserByNotRoleAssigned"
}

and in my STS editor console, I am getting the following message,在我的 STS 编辑器控制台中,我收到以下消息,

 java.lang.IllegalArgumentException: Parameter value element [{0=com.spacestudy.model.Users@2357844c}] did not match expected type [java.lang.Integer (n/a)

My repository UserRepository.java is codded like the following,我的存储库UserRepository.java编码如下,

@Query("select new map(u.nuserId,u.susername) from Users u where u.nuserId NOT IN :userRoleMappingList")
List<Users> findByUsersNotassignedRole(@Param(value = "userRoleMappingList") List<Integer> userRoleMappingList);

And my service, I wrote like the following,而我的服务,我是这样写的,

public List<Users> retrieveUsersByNotassignedRoles() {
    // TODO Auto-generated method stub
    
    List<Integer> userRoleMappingList = userRoleMappingRepoObj.findByUserId();
    
    return userRepoObj.findByUsersNotassignedRole(userRoleMappingList);
 }

and UserRoleMappingRepository.java coded with,UserRoleMappingRepository.java编码,

@Query("select new map(ur.nuserId) from UserRoleMapping ur")
List<Integer> findByUserId();

Where did I go in the wrong direction?我哪里走错方向了?

userRoleMappingList 应该是一个 userIds 列表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM