-->
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: HIbernate Association Mapping question
PostPosted: Tue Jul 07, 2009 2:14 pm 
Newbie

Joined: Tue Jul 07, 2009 2:01 pm
Posts: 2
Hello There

I have two tables like this
table 1
PK
attr1
attr2
PKField_1 - From table 2 it is one-to-many relationship to table 2

table 2
PKField_1
PKField_2
Attr1
Attr2

PKField_1 and PKField_2 are composite PK field.

I am trying to mapping table 2 in table 1 like
<class name="table1class"
.....
<set name="PKField1">
<key>
<column name="PKField_1" />
</key>
<one-to-many class="table2class" />
</set>
....

in table1class.java I have set<table2class> getPKField1() method and the setter method

But hibernate can not return any objects from getPKField1() method. I checked the set return from this mehod, it is empty.

The document said the key column in here must be FK which mean it must be primary key of table2 in my case. my question is how can i association two tables but just use a common column rather than FK column or columns. Does HIbernate support this way?

thank you very much!


Top
 Profile  
 
 Post subject: Re: HIbernate Association Mapping question
PostPosted: Wed Jul 08, 2009 11:55 am 
Newbie

Joined: Tue Jul 07, 2009 2:01 pm
Posts: 2
Solved.
Hibernate does not support this way. need to create a mid table to link two tables in this case.


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.