Follow javax.persistence.criteria.Order.reverse() contract

Description

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 object

2. 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.

Activity

Show:

Sergey Chernov February 28, 2020 at 2:30 PM

Fixed

Details

Assignee

Reporter

Labels

Components

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