Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Order by clause on child (Hibernate) not working

 
Maalti Iyer
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


I'm new to Hibernate.

I've a parent order_header mapped one-to-many to order_details (for every header there can be multiple details). I need to order by LINE_NUMBER on the child (order_detail).

Here's my java code


Session session = HibernateSession.currentSession();
Criteria crit = session.createCriteria(SalesOrderHeader.class);
crit.add(Expression.eq("batchId", batchId));
crit.addOrder(Order.asc("SalesOrderLine.id"));
results = crit.list();

when I run my java pgm I'm getting QueryException : Could not resolve Property SalesOrderLine.id of com.bos.order.process.resource.beans.SalesOrderHeader

Here's my parent

<hibernate-mapping>
<class name="com.bos.order.process.resource.beans.SalesOrderHeader" table="order_header" >
<id name="webPOKey" column="PO_KEY" type="long" unsaved-value="null">
<generator class="hilo"/>
</id>
<property name="status" column="stat_id" type="long" not-null="true"/>
<property name="orderSource" column="ORIGINATOR" type="string" length="50" not-null="true"/>

<bag name="orderDetail">
<key column="PO_KEY"/>
<one-to-many class="com.bos.order.process.resource.beans.SalesOrderLine"/>

</class>

</hibernate-mapping>

and the child

<hibernate-mapping>
<class name="com.bos.order.process.resource.beans.SalesOrderLine" table="order_detail">
<composite-id>
<key-property name="webPOKey" column="PO_KEY" type="long"/>
<key-property name="id" column="LINE_NUMBER" type="long" length="6"/>
</composite-id>
<property name="itemNumber" column="ITEM_CODE" type="string" />
<property name="description" column="DESCRIPTION" type="string" />

</class>
</hibernate-mapping>

Can someone help me?

Thanks
Maalti Iyer
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try

instead of
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic