Follow javax.persistence.criteria.Order.reverse() contract
Description
Activity
Show:
Sergey Chernov February 28, 2020 at 2:30 PM
Pull request for master 5.4.x: https://github.com/hibernate/hibernate-orm/pull/3271
Pull request for wip/6.0: https://github.com/hibernate/hibernate-orm/pull/3272
Fixed
Details
Details
Assignee
Sergey Chernov
Sergey ChernovReporter
Sergey Chernov
Sergey ChernovLabels
Components
Fix versions
Priority
Created February 28, 2020 at 1:04 PM
Updated March 18, 2021 at 7:49 PM
Resolved September 28, 2020 at 6:18 AM
javax.persistence.criteria.Order.reverse()
method javadoc explicitly declares:public interface Order { /** * Switch the ordering. * @return a new <code>Order</code> instance with the reversed ordering */ Order reverse();
This interface is implemented by two classes:
1. In master branch (5.4.x versions) - by
org.hibernate.query.criteria.internal.OrderImpl
with this implementation:... public Order reverse() { ascending = !ascending; return this; } ...
It returns
this
instead of new object2. In wip/6.0 branch there is another class
org.hibernate.query.sqm.tree.select.SqmSortSpecification
that has the same problem:@Override public JpaOrder reverse() { this.sortOrder = this.sortOrder == null ? SortOrder.DESCENDING : sortOrder.reverse(); return this; }
Proposal: respect the contract and return new created object.