Hi,
I have a problem with sorting collections.
I have following schema (example):
Code:
<class name="Firm" table="firm">
<id name="id" column="id" type="long">
<generator class="native" />
</id>
<property name="name" column="name" />
<set name="employees" table="employee" inverse="true" cascade="all,delete-orphan">
<key column="firm_id" />
<one-to-many class="Employee" />
</set>
</class>
<class name="Employee" table="employee">
<id name="id" column="id" type="long">
<generator class="native" />
</id>
<property name="firstName" column="first_name" />
<property name="lastName" column="last_name" />
<many-to-one name="firm" column="firm_id" class="Firm" />
</class>
If I use HQL:
Code:
from Firm firm
left join fetch firm.employees employees
order by employees.lastName
employees in result are not sorted, although "order by" is present:
Code:
select
firm0_.id as id3_0_,
employees1_.id as id7_1_,
employees1_.first_name as first2_7_1_,
employees1_.last_name as last3_7_1_,
employees1_.firm_id as firm14_7_1_,
employees1_.firm_id as firm14_0__,
employees1_.id as id0__
from
firm firm0_
left outer join
employee employees1_
on firm0_.id=employees1_.firm_id
where
firm0_.id=1
order by
employees1_.last_name
If I add eg. order-by="1":
Code:
<set name="employees" table="employee" inverse="true" cascade="all,delete-orphan" order-by="1">
result is ok.
Thanks for help.