这基本上与此相反:
How to do a paged QueryDSL query with Spring JPA?
这是针对我无法使用任何 findAll() 方法的自定义查询。
编辑:
发错链接了。现在更正了。
最佳答案
您可以执行以下操作:但请确保修剪 o.getProperty() 以便您只传递属性而不是“别名”。+property
if (pageable != null) {
query.offset(pageable.getOffset());
query.limit(pageable.getPageSize());
for (Sort.Order o : pageable.getSort()) {
PathBuilder<Object> orderByExpression = new PathBuilder<Object>(Object.class, "object");
query.orderBy(new OrderSpecifier(o.isAscending() ? com.mysema.query.types.Order.ASC
: com.mysema.query.types.Order.DESC, orderByExpression.get(o.getProperty())));
}
}
关于spring-data - 如何将 spring 数据排序转换为 querydsl OrderSpecifier?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13072378/