-->
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: composite ids and composite foreign keys
PostPosted: Thu Jul 10, 2008 2:41 pm 
Newbie

Joined: Wed Jul 09, 2008 6:50 pm
Posts: 6
Hibernate-Version: 3.2.4.sp1

We are currently using composite-keys for all of our tables.
Below are the mapping files for a parent-child one-to-many association:


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Jun 20, 2008 12:44:28 PM by Hibernate Tools 3.2.0.b9 -->
<hibernate-mapping>
<class name="com.expd.app.edms.domain.hiber.MasterDeliveryOrderData" table="MASTER_DELIVERY_ORDER">
<meta attribute="implements" inherit="false">com.expd.app.edms.data.IMasterDeliveryOrderData</meta>
<composite-id name="id" class="com.expd.app.edms.domain.hiber.EdmsPrimaryKey">
<key-property name="oid" type="big_decimal">
<column name="OID" scale="0" />
</key-property>
<key-property name="branch" type="string">
<column name="BRANCH" length="3" />
</key-property>
</composite-id>
<timestamp name="lastUpd" column="LAST_UPD" />
<set name="addressAssocDatas" inverse="true" fetch="subselect">
<key>
<column name="OWNER_MSTR_DELIVERY_ORDER_OID" scale="0" />
<column name="BRANCH" length="3" not-null="true" />
</key>
<one-to-many class="com.expd.app.edms.domain.hiber.AddressAssocData" />
</set>
</class>
</hibernate-mapping>

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Jun 20, 2008 12:44:28 PM by Hibernate Tools 3.2.0.b9 -->
<hibernate-mapping>
<class name="com.expd.app.edms.domain.hiber.AddressAssocData" table="ADDRESS_ASSOC">
<meta attribute="implements" inherit="false">com.expd.app.edms.data.IAddressAssocData</meta>
<composite-id name="id" class="com.expd.app.edms.domain.hiber.EdmsPrimaryKey">
<key-property name="oid" type="big_decimal">
<column name="OID" scale="0" />
</key-property>
<key-property name="branch" type="string">
<column name="BRANCH" length="3" />
</key-property>
</composite-id>
<timestamp name="lastUpd" column="LAST_UPD" />
<many-to-one name="masterDeliveryOrderData" class="com.expd.app.edms.domain.hiber.MasterDeliveryOrderData" fetch="select">
<column name="OWNER_MSTR_DELIVERY_ORDER_OID" scale="0" />
<column name="BRANCH" length="3"/>
</many-to-one>
</class>
</hibernate-mapping>


We get the following error:

main app.edms.hiber.HibernateUtil - org.hibernate.MappingException: Repeated column in mapping for entity: com.expd.app.edms.domain.hiber.AddressAssocData column: BRANCH (should be mapped with insert="false" update="false")

Is there any way around this problem?

Thanks,
Debra Zarley


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.