Joined: Tue Apr 22, 2008 10:45 am Posts: 1 Location: Amarillo,TX
|
I need to be able to order by a formula in a hibernate mapping. I am using criteria api.
My mapping looks like this
<hibernate-mapping>
<class entity-name= "A" name = "A" table="B" lazy="true">
<tuplizer entity-mode="pojo" class="X" />
<id name="identifier" column="aid" type="java.lang.Long" unsaved-value="0">
<generator class="increment" />
</id>
<many-to-one name="cEntity" entity-name="C" column="cid" fetch="join" cascade="save-update" />
<property name="dProperty" insert="false" update="false" formula="(select count(*) from sttable st where st.id = cid)" />
</class>
</hibernate-mapping>
There are other columns in the table but I deleted them for clarity. The mapping has a property name dProperty and I need to order by that property. When I try to order by the dProperty I get an exception saying "cid" is invalid in the context used. Can any one please clarify what needs to be done to order by properties which are basically formulaes? Thanks for your help.
Thanks,
Vootan.
|
|