Sleeping criterion problems with order and joins
I have a dormant Contract object that has a set of "ContractVersions" (one-to-many mapping). Here's a short display:
<class name="Contract"> <set name="versions" order-by="version_id" mutable="false" lazy="false" fetch="join"> <key column="contract_id" not-null="true"/> <one-to-many class="ContractVersion"/> </set> </class>
Then I create a criterion that searches for a contract and you want to order the results by date:
However, when I look at the generated SQL, I see a problem. Hibernate uses left outer join to select versioning contracts and adds both orderings:
... order by version4_.version_id, this_.created_at desc ...
For me, ordering by date is more important. Is there a way to solve this problem?
source to share
No one has answered this question yet
Check out similar questions: