|
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
|