I used nullslast() as the sample code as below,
List<Sort.Order> orders = new ArrayList<>();
Sort.Order orderAuditTime = new Sort.Order(Sort.Direction.DESC,"auditTime");
Sort.Order orderEntryTime = new Sort.Order(Sort.Direction.DESC,"customer.entryTime");
orders.add(orderAuditTime.nullsLast());
orders.add(orderEntryTime);
sort = new Sort(orders);
but got sql without nulls last like :
order by
auditrecor0_.audit_time desc,
customer1_.entry_time desc limit ?
Can someone help me why orderAuditTime.nullsLast() doesn't work ?
The database is postgre and the orm framework is hibernate.
As far as I can see, instances of Sort.Order get converted to javax.persistence.criteria.Order. This interface does not have support for nulls first/last:
package javax.persistence.criteria;
public interface Order {
Order reverse();
boolean isAscending();
Expression<?> getExpression();
}
Thus, nulls first/last specified on Sort.Order is ignored.
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.