Is there a way to use a "contains" function in a @Query
tag? If no, what is the best way to implement this?
Example:
@Query("From User u where u.roles contains :role")
List<User> findByRole(@Param("role") Role role);
The User
class does have a Collection
containing their Roles
.
Edit: As suggested i tried it with like, the application starts, but when this method gets executed a "not matching expected type" exception occurs.
Just use the following query and you're done:
@Query("From User u where :role member u.roles")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With