-->
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.  [ 2 posts ] 
Author Message
 Post subject: Many-to-one with column sharing between primary/associaton
PostPosted: Thu Mar 31, 2005 10:10 pm 
Newbie

Joined: Thu Mar 31, 2005 9:57 pm
Posts: 3
I'm trying to do an mapping in a table like this
(taken from http://forum.hibernate.org/viewtopic.ph ... ymanytoone)

Quote:
<class name="com.mjwall.TableD" table="TABLE_D">
<meta attribute="field-description">@hibernate.class
table="TABLE_D"</meta>
<composite-id name="comp_id" class="com.mjwall.TableDPK">
<meta attribute="field-description">@hibernate.id
generator-class="assigned"</meta>
<key-property name="IdA" column="ID_A"
type="java.math.BigDecimal" length="22" />
<key-property name="IdB" column="ID_B"
type="java.math.BigDecimal" length="22" />
<key-property name="IdC" column="ID_C"
type="java.math.BigDecimal" length="22" />
</composite-id>
<many-to-one name="tableC" class="com.mjwall.TableC"
update="false" insert="false">
<column name="ID_A" />
<column name="ID_E" />
</many-to-one>
<many-to-one name="tableB" class="com.mjwall.TableB"
update="false" insert="false">
<column name="ID_A" />
<column name="ID_F" />
</many-to-one>
</class>


notice columns ID_E and ID_F in the associations, that is, ID_A, which is part of primary used in two other associations at the same time. In my application, only who changes the primary key should touch the ID_A, the associations would simple follow the same values. By what I read in the post above, I whoud use update=false and insert=false. Question: does hibernate would allow me to change ID_F and ID_E ? This is legacy databse so I'm trying to find how to map this, any help appreciated.
Quote:
Quote:
[code][/code]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 31, 2005 10:14 pm 
Newbie

Joined: Thu Mar 31, 2005 9:57 pm
Posts: 3
Should have used Code instead of Quote, reposting relevante part for readability

Code:
  <composite-id name="comp_id" class="com.mjwall.TableDPK">
    <key-property name="IdA" column="ID_A"
    <key-property name="IdB" column="ID_B"
    <key-property name="IdC" column="ID_C"
  </composite-id>
  <many-to-one name="tableC" class="com.mjwall.TableC"
      update="false" insert="false">
    <column name="ID_A" />
    <column name="ID_E" />
  </many-to-one>
  <many-to-one name="tableB" class="com.mjwall.TableB"
     update="false" insert="false">
    <column name="ID_A" />
    <column name="ID_F" />
  </many-to-one>
</class>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.