-->
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.  [ 3 posts ] 
Author Message
 Post subject: Single element returned for one-to-many association
PostPosted: Fri Oct 22, 2004 9:09 am 
Newbie

Joined: Tue Oct 19, 2004 12:18 pm
Posts: 4
Description:
We have 3 entites with the following associations. A Work Order has a one-to-many association with both Materials and Operations. When a given work order is retrieved via Hibernate we have a valid collection of Operations however only a single Material is returned versus a collection(if in fact more than one should exist within the database). Does anyone see something within these mapping files which would prohibit the collection of Materials to be returned(ie like our Operations). In looking at the generated SQL it appears both the Material and Operation association queries are performing a left outer join with our Item too. Does anything special need to be defined within the mapping files for this join to work?
Thanks in advance.

Hibernate version: 2.1.6

Mapping documents:
WorkOrder.hbm
<hibernate-mapping package="com.htch.erp.hibernate.movex">
<class name="WorkOrder" table="MMOHED">
<composite-id name="id" class="com.htch.erp.hibernate.movex.WorkOrderCompositeID">
<key-property name="companyNumber" column="QHCONO" type="integer" />
<key-property name="itemNumber" column="QHPRNO" type="string" />
<key-property name="orderNumber" column="QHMWNO" type="integer" />
</composite-id>

<!-- Item -->
<many-to-one name="item"
class="com.htch.erp.hibernate.movex.Item"
insert="false"
update="false"
not-null="true">
<column name="QHCONO"/>
<column name="QHPRNO"/>
</many-to-one>

<!-- Materials -->
<set name="materials" lazy="false" inverse="true" order-by="QMMSEQ asc">
<key>
<column name="QMCONO"/>
<column name="QMPRNO"/>
<column name="QMMWNO"/>
</key>
<one-to-many class="com.htch.erp.hibernate.movex.WorkOrderMaterial"/>
</set>

<!-- Operations -->
<set name="operations" lazy="false" inverse="true" order-by="QOOPNO asc">
<key>
<column name="QOCONO"/>
<column name="QOPRNO"/>
<column name="QOMWNO"/>
</key>
<one-to-many class="com.htch.erp.hibernate.movex.WorkOrderOperation"/>
</set>

</class>

WorkOrderMaterial.hbm(Association Not Working)

<hibernate-mapping package="com.htch.erp.hibernate.movex">
<class name="WorkOrderMaterial" table="MMOMAT">
<composite-id name="id" class="com.htch.erp.hibernate.movex.WorkOrderMaterialID">
<key-property name="companyNumber" column="QMCONO" type="integer" />
<key-property name="itemNumber" column="QMPRNO" type="string" />
<key-property name="orderNumber" column="QMMWNO" type="integer" />
<key-property name="operationNumber" column="QMOPNO" type="integer" />
</composite-id>
<!-- Work Order -->
<many-to-one name="order"
class="com.htch.erp.hibernate.movex.WorkOrder"
insert="false"
update="false"
not-null="true">
<column name="QMCONO"/>
<column name="QMPRNO"/>
<column name="QMMWNO"/>
</many-to-one>

<!-- Item -->
<many-to-one name="item"
class="com.htch.erp.hibernate.movex.Item"
insert="false"
update="false"
not-null="true">
<column name="QMCONO"/>
<column name="QMPRNO"/>
</many-to-one>

</class>
WorkOrderOperation.hbm(Association Working)
<hibernate-mapping package="com.htch.erp.hibernate.movex">
<class name="WorkOrderOperation" table="MMOOPE">
<composite-id name="id" class="com.htch.erp.hibernate.movex.WorkOrderOperationID">
<key-property name="companyNumber" column="QOCONO" type="integer" />
<key-property name="itemNumber" column="QOPRNO" type="string" />
<key-property name="orderNumber" column="QOMWNO" type="integer" />
<key-property name="operationNumber" column="QOOPNO" type="integer" />
</composite-id>
<!-- Work Order -->
<many-to-one name="order"
class="com.htch.erp.hibernate.movex.WorkOrder"
insert="false"
update="false"
not-null="true">
<column name="QOCONO"/>
<column name="QOPRNO"/>
<column name="QOMWNO"/>
</many-to-one>

<!-- Item -->
<many-to-one name="item"
class="com.htch.erp.hibernate.movex.Item"
insert="false"
update="false"
not-null="true">
<column name="QOCONO"/>
<column name="QOPRNO"/>
</many-to-one>

</class>

Item.hbm
<hibernate-mapping package="com.htch.erp.hibernate.movex">
<class name="Item" table="MITMAS">
<composite-id name="id" class="com.htch.erp.hibernate.movex.ItemCompositeID">
<key-property name="companyNumber" column="MMCONO" type="integer" />
<key-property name="itemNumber" column="MMITNO" type="string" />
</composite-id>
<!-- Manufacturing Orders -->
<set name="manufacturingOrders" lazy="true" inverse="true">
<key>
<column name="VHCONO"/>
<column name="VHITNO"/>
</key>
<one-to-many class="com.htch.erp.hibernate.movex.ManufacturingOrder"/>
</set>

<!-- Work Orders -->
<set name="workOrders" lazy="true" inverse="true">
<key>
<column name="QHCONO"/>
<column name="QHPRNO"/>
</key>
<one-to-many class="com.htch.erp.hibernate.movex.WorkOrder"/>
</set>


</class>

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using: DB2400

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 22, 2004 10:04 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
surely equals hashcode implementation to recode

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 22, 2004 10:39 am 
Newbie

Joined: Tue Oct 19, 2004 12:18 pm
Posts: 4
That was it Anthony. Thanks again!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

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.