From: Nguyen H. G. (JIRA) <no...@at...> - 2006-07-21 07:40:16
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-594?page=comments#action_23712 ] Nguyen Hau Giang commented on HHH-594: -------------------------------------- I met the same problem when querying by Criteria with join-fetch or left-join-alias. Please see HHH-1928 > order-by mapping for collections overrides order by in HQL > ---------------------------------------------------------- > > Key: HHH-594 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-594 > Project: Hibernate3 > Type: Bug > Components: core > Versions: 3.0.4 > Environment: Hibernate v3.0.4, Oracle 8i > Reporter: Jim Reed > Assignee: Gavin King > Fix For: 3.1 beta 1 > > > In Hibernate v2.1 if you included an order-by in the mapping for a collection, that order by would automatically be concatenated onto any order by clause in your HQL. This allows you to sort your list of Hibernate objects and also sort the collections within those objects. In Hibernate v3.0, however, the order-by clause in the mapping for a collection completely overrides an order by for your HQL. > Example: > Mapping file: > <hibernate-mapping package="com.mycompany.hibernate"> > <class name="Client" table="CLIENT"> > <id > column="CLIENT_ID" > name="id" > type="integer" > > > <generator class="vm" /> > </id> > <property > column="NAME" > length="255" > name="name" > not-null="true" > type="string" > /> > <set > name="contactSet" > inverse="true" > lazy="true" > order-by="LAST_NAME asc" > > > <key column="CLIENT_ID" /> > <one-to-many class="Contact" /> > </set> > </class> > </hibernate-mapping> > HQL: > from com.mycompany.hibernate.Client c, c.contactSet cs > order by c.name > Hibernate v2.1 SQL: > select c1.name,c2.first_name,c2.lastname > from client c1, contact c2 > order by c1.name, c2.last_name > Hibernate v3.0 SQL: > select c1.name,c2.first_name,c2.lastname > from client c1, contact c2 > order by c2.last_name -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |