-->
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 mapping to multiple classes using same column
PostPosted: Fri Oct 10, 2008 1:27 pm 
Beginner
Beginner

Joined: Thu Apr 19, 2007 9:52 am
Posts: 27
Hello Everyone,

I have a new problem now. I have three tables Test1, Test2 and Test3

This is how it looks like

Test1
ID - PK
Version
EmpID
Name

Test2
ID - PK
Version
SomeOtherData
ManagerOf
WorkerOf

Test3
ID - PK
Version
EmpID
Name

This is a sample table created to test a situation we have in the existing data model we have to use due to political reason.

Here is the mapping for test2

<?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 Oct 3, 2008 10:52:06 AM by Hibernate Tools 3.2.0.b9 -->
<hibernate-mapping>
<class name="com.mahen.Test2" table="TEST2">
<id name="id" type="big_decimal">
<column name="ID" precision="22" scale="0" />
<generator class="assigned" />
</id>
<many-to-one name="test1" class="com.mahen.Test1" fetch="select" cascade="all" property-ref="naturalId">
<column name="MANAGER_OF" />
<column name="VERSION" />
</many-to-one>
<many-to-one name="test3" class="com.mahen.Test3" fetch="select" cascade="all" property-ref="naturalIdTest3" >
<column name="WORKER_OF" />
<column name="VERSION" />
</many-to-one>
</class>
</hibernate-mapping>

Now when i run the test. It complains "Repeated column in mapping for entity: com.mahen.Test2 column: VERSION (should be mapped with insert="false" update="false")"

That make sense so I thought I'll put insert="false" update="false" for many-to-one name="test3". But if I do this it works but the value for WorkerOf is not set.

Which again make sense. Now I am stuck. I just want to set nsert="false" update="false" for version and not the other column. I did not find any way of setting just that. Can someone suggest me solution to this.


Thanks
Mahen


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 13, 2008 9:23 am 
Beginner
Beginner

Joined: Thu Apr 19, 2007 9:52 am
Posts: 27
Can someone help

Mahen

_________________
Regards,
Mahen
http://www.discoverabout.net
http://funnfacts.discoverabout.net


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.