-->
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 formula in mapping
PostPosted: Tue Apr 22, 2008 10:54 am 
Newbie

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.


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.