I recently upgraded from using Hibernate 2.1.8 to 3.0.4.
I have a class with a set that has an "order-by" attribute specified:
Code:
<class name="Customer" table="CUSTOMER" schema="C" lazy="true">
<id
column="CUSTOMER_ID"
name="id"
type="integer"
>
<generator class="native" />
</id>
[...]
<set
name="customerContactSet"
inverse="true"
lazy="true"
order-by="LAST_NAME asc"
>
</class>
</hibernate-mapping>
And I run something like the following HQL:
from Customer customer
left join fetch customer.customerContactSet ccs
where customer.relationship = 'test'
order by customer.type asc
Using 2.1.8 the generated SQL had an order by clause like this:
Quote:
order by cust1_.TYPE asc, custcont1_.LAST_NAME asc
where it appeared to combine the order by specified in the HQL and the mapping file order-by attribute, placing the HQL order by first.
With 3.0.4, if I run the same HQL the order by specified in the HQL seems to be ignored and only the order-by specified by the mapping file is used:
Quote:
order by custcont1_.LAST_NAME asc
This continues to be the case in any HQL so long as I am making a left join fetch to customerContactSet.
Thanks in advance,
Jared
Hibernate version:
3.0.4
Code between sessionFactory.openSession() and session.close():
String query = "from Customer customer
left join fetch customer.customerContactSet ccs
where customer.relationship = 'test'
order by customer.type asc";
List list = s.createQuery(query).list();
Name and version of the database you are using:
Oracle 10g
The generated SQL (show_sql=true):
see above