I want to create an equivalent predicate for the query below,
SELECT * FROM mytable WHERE t_date < NOW() ORDER BY updated_at DESC LIMIT 0,10
Right now I am up to this, in the start
and end
I will pass the LIMIT
values such as 0,10
simpleRepository.findAll(SimplePredicates.pastRecords(), new PageRequest(start, end,
QuerydslHelper.sortDescBy(QMyEntity.myEntity.updatedAt)));
And in the predicate,
public static Predicate pastRecords() {
QMyEntity myEntity=QMyEntity.myEntity;
return myEntity.tdate.before(new Date());
}
I am getting the result as desired, but I am not sure if this is the right way.
Any other possible solutions would be appreciated. Thanks in advance
The predicate in Querydsl is the 'where' part of the JPQL query. Your pastRecords() implementation looks ok.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.