-->
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: Mapping Question - Column has multiple uses
PostPosted: Fri May 19, 2006 7:22 pm 
Newbie

Joined: Fri May 19, 2006 7:01 pm
Posts: 1
Location: Salt Lake City, UT USA
In Hibernate 3.1, I have a many-one relationship that I don't understand how to map. The essence of the problem is that there is one column in the database that is used both as:

1. A foreign key to a parent table (in the classic parent-child style).

2. Part of a compound foreign key to another table (a sibling table).

Since the column is used in multiple "many-to-one"s, I get a duplicate column definition when Hibernate initializes. There is no way to specify that the column in the compound key should not be cascaded on insert/update, and it needs to be cascaded on the parent FK. So, how can I map this relationship?

My current map (which does not work) is as follows:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="tp5.business.store.ProductPrice" table="ProductPrice">
<id name="productPriceId">
<generator class="identity" />
</id>
<version name="modifiedTime" type="timestamp" />
<property name="amount" />
<property name="isPercentage" />
<property name="useBasePrice" />
<property name="startDate" type="date" />
<property name="endDate" type="date" />

<!-- associations -->
<many-to-one name="seller" column="sellerId" />

<many-to-one name="buyer" column="buyerId" />

<many-to-one name="productLine" column="productLineId" />

<many-to-one name="product" column="productId" />

<many-to-one name="sku">
<column name="sellerId" />
<column name="sku" />
</many-to-one>

<many-to-one name="credential" column="credentialId" />

<many-to-one name="relationship" />

</class>
</hibernate-mapping>

The "sellerId" column is the duplicated one.

Thanks in advance for any help.

_________________
Joe Thomas


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.