I have a table UserData with fields such as name, userRole, phonenumber etc. UserRole field can have values like ADMIN, USER, MANAGER, OWNER, VIEWER and many more. I am trying t
You can try this.
String selectQuery= "SELECT u FROM UserData u WHERE u.userRole IN :roles";
Query query = em.createQuery(selectQuery, UserData.class);
List<String> roles = Arrays.asList("ADMIN", "USER", "MANAGER");
query.setParameter("roles", roles);
List<UserData> users = query.getResultList();
Edit: For Hibernate
Query query = session.createQuery("SELECT u FROM UserData u WHERE u.userRole IN (:roles)");
query.setParameterList("roles", roles);
[It's implementation/version specific - :namedParameter OR (:namedParameter)]