views:

265

answers:

1
A: 

You can sort just like you said. You may also want to add the comparable interface to your objects so you can sort them in your services.

The following hibernate file has an example of using an sql bit for sorting

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                                   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt;
<hibernate-mapping>
    <class name="au.gov.abs.maserati.domain.entity.CURF" 
     table="CURF" >
     <id name="ID" column="ID">
      <generator class="native" />
     </id>

     <property name="title" />
     <property name="description" />
     <property name="active"
      type="yes_no" 
      not-null="true" />

     <set name="specialConditions" cascade="none"
      order-by="sortOrder, Text1"
      where=" Discriminator in ( 'SPECIAL-CURF-AGREEMENT' ) and active = 'Y' ">
      <key column="parentID" not-null="false" />
      <one-to-many
       class="au.gov.abs.maserati.domain.entity.Condition" />
     </set>
    </class>
</hibernate-mapping>
Martlark
i want to get sorting done by hibernate