I am trying to implement the following query with spring data JPA with method name resolving.
select count(*) from example ex where ex.id = id and ex.status in (1, 2);
I know there's a method in crud repo for count which will go like - countByIdAndStatus(params)
but I wasn't sure how can I incorporate "in" clause with this method.
Thank you!
This is how you can do it:
long countByIdAndStatusIn(Integer id, List<Type> params);
With @Query
:
@Query("select count(*) from Example ex where ex.id = ?1 and ex.status in (?2)")
long countByIdAndStatus(Integer id, List<Type> params);
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