-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: order-by and LinkedHashSet
PostPosted: Fri Jul 21, 2006 5:23 am 
Newbie

Joined: Sat Jul 08, 2006 5:56 am
Posts: 1
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.