-->
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 clause on child (one-to-many relationships)
PostPosted: Mon Mar 07, 2005 7:31 pm 
Newbie

Joined: Mon Mar 07, 2005 7:18 pm
Posts: 16
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>

I need some help here!

Thanks
Chicagoram


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.