[英]QueryDSL predicate for the equivalent query
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
SELECT * FROM mytable WHERE t_date <NOW()ORDER BY update_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 现在我可以解决这个问题,在
start
和end
我将传递LIMIT
值,例如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. Querydsl中的谓词是JPQL查询的“ where”部分。 Your pastRecords() implementation looks ok.
您的pastRecords()实现看起来不错。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.