0
@SqlQuery("Select id from user where type in (<CAST(userType as user_type[])>)")
List<Long> getUserIdsByListOfTypes(@BindList("userType") List<User.UserType> userType);

I want to fetch the list of Ids from the List of userTypes.
Here User.UserType is an enum. In the method(getUserIdsByListOfTypes), I am passing the parameter(userTypes) of type list of enum.
I am not able to understand where is the problem in the query.

Swarnim Kumar
  • 335
  • 5
  • 21
  • Solution which works for me: ```@SqlQuery("Select id from user where type::text in ()") List getUserIdsByListOfTypes(@BindList("userType") List userType);``` – Swarnim Kumar Jan 11 '21 at 05:00

1 Answers1

0

Instead of taking list of enum type, I had taken the list of string.

@SqlQuery("Select id from user where type::text in (<userType>)")   
List<Long> getUserIdsByListOfTypes(@BindList("userType") List<String> userType);  

How to search an enum in list of strings by postgresql query?

Swarnim Kumar
  • 335
  • 5
  • 21