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: Complex Order by Question
PostPosted: Tue Aug 08, 2006 3:45 am 
Newbie

Joined: Tue Aug 08, 2006 2:56 am
Posts: 6
Dear all:
I have a Complex Order by Question for hibernate.
Here is the hbm.xml structure.

--- Person.hbm.xml ---
<hibernate-mapping default-lazy="false" >
<class name="tester.Person" table="Person"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
>

<id name="id" type="integer">
<generator class="increment" />
</id>

<property name="name" type="string" >
<column name="name" />
</property>

<property name="address" type="string" >
<column name="address" />
</property>

<set name="details" lazy="false" cascade="none" >
<key column="personUid"/>
<one-to-many
class="tester.PersonDetail" not-found="ignore"/>
</set>
</class>
</hibernate-mapping>

--- PersonDetail.hbm.xml ---
<hibernate-mapping default-lazy="false" >

<class name="tester.PersonDetail"
table="PersonDetail"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
>

<id name="id" type="integer">
<generator class="increment" />
</id>

<property name="detail" type="string" >
<column name="detail" />
</property>

<property name="personUid" type="integer" >
<column name="personUid" />
</property>

<property name="backgroundId" type="integer" >
<column name="backgroundId" />
</property>

<many-to-one name="backgroundVo"
column="backgroundId"
class="tester.PersonBackground"
cascade="all"
lazy="false"
unique="true"
fetch="join"
insert="false" update="false"
/>
</class>
</hibernate-mapping>

--- PersonBackground.hbm.xml ---
<hibernate-mapping default-lazy="false" >
<class name="tester.PersonBackground"
table="PersonBackground"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
>

<id name="id" type="integer">
<generator class="increment" />
</id>

<property name="experience" type="string" >
<column name="experience" />
</property>

</class>
</hibernate-mapping>

From the previous xml, I can get the information via...
DetachedCriteria detachedCriteria = DetachedCriteria.forClass
(Person.class);
List list = detachedCriteria.getExecutableCriteria(session).list();

The result will be represented as
For each Person.class, it contains a list of PersonDetail.class.
And For each PersonDetail.class, it has a PersonBackground.class.

My Question is...
Is it possible
to make the list of PersonDetail order by PersonBackground.class.experience?

Through the
DetachedCriteria detachedCriteria = DetachedCriteria.forClass
(Person.class);
List list = detachedCriteria.getExecutableCriteria(session).list();

or

criteria.list();

Thank You


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.