Bruce
Bruce

Reputation: 691

Any workaround for the openjpa to do ORDER BY NULLS LAST | FIRST query?

We are now using the spring-data-jpa(v1.10.2.RELEASE) and openjpa(v2.2.2) and have to do the ORDER BY query with NULLS LAST as code below.

Sort.Order order = new Sort.Order(Direction.DESC, "latestConnectTime", NullHandling.NULLS_LAST);

Sort sort = new Sort(order);

PageRequest pageRequest = new PageRequest(1, 20, sort);

It looks like the EclipseLink and Hibernate have already supported this feature, the openjpa, however, doesn't?

https://github.com/spring-projects/spring-data-jpa/issues/1185 (formerly DATAJPA-825/925)
https://github.com/spring-projects/spring-data-jpa/issues/1626 (formerly DATAJPA-1302)
https://github.com/javaee/jpa-spec/issues/76
https://github.com/javaee/jpa-spec/issues/130

And the hibernate also does the workaround by the EmptyInterceptor or just configure the hibernate property hibernate.order_by.default_null_ordering as the link below.

Hibernate order by with nulls last

Is there any workaround for the openjpa to do the ORDER BY NULLS LAST query?

Upvotes: 2

Views: 536

Answers (0)

Related Questions