'Select only a set to improve perfomance
I search to know if a user have an active subscription
@Query("select case when count(u) > 0 then true else false end from User u where u.id=:userId and current_date < u.subscriptionEndDate")
boolean userActiveSubscription(Long userId);
subscriptionEndDate use a localdate
Probably user object is queried, is there a way to limit data retrived to return true or false
Generated query
select
case
when count(user0_.id)>0 then 1
else 0
end as col_0_0_
from
user user0_
where
user0_.id=?
and current_date<=user0_.subscription_end_date
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
