My User Entity
@Entity
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(nullable = fals
Here from User to Role is ONE-TO-MANY mapping
i.e list of Roles is an element of User entity, and you are passing a String
as List of Roles.
This is the reason you are getting Exception.
Solutions:
findByRolesIn(List roles)
instead of findByRoles(String role)
Or, Make one-to-one mapping as below:
@Column(nullable = false)
private String role;
Or, Use JPA Query or Native query as below.
@Query( "select u from User u where u.roles in :roles" )
public List findByRoles(@Param("roles") List roles);