I'm trying to order a querydsl query so that all entities with a null value for a relationship are ordered first, but I can't figure out how to do it.
I would expect:
query.orderBy(
QBook.book.original.isNull().asc()
)
To be what I need, where original
is a self-referential relationship with Book
.
But that produces the exception:
Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: is null
[select book
from com.mydomain.Book book
order by book.original is null asc]
(The real exception is much longer, but that should be all the relevant info.)
I've also tried
QBook.book.original.name.asc().nullsFirst()
But that has two problems. First, it eliminates all books without an original
, and even if it didn't, it would sort them based off name, when I only want them sorted off of whether that value is null.
Hibernate version: 3.6.6.Final
QueryDSL version: 3.2.3
Aucun commentaire:
Enregistrer un commentaire