-->
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: Mapping sets when there is a foreigh key in just one way.
PostPosted: Wed Apr 08, 2009 7:36 pm 
Newbie

Joined: Wed Apr 08, 2009 7:18 pm
Posts: 1
Hi -

I am in the middle of some refactoring of legacy code and am not sure how to write the mappings for the new code.

Consider that now we have the following:

class A
class B

A has a String property U0
B has a String properties U1, U2

U0, U1, U2 are all the same concept, but are not an object at the moment.

Now, it has become necessary for A to have 0..n U values.


Therefore, I see the creation of an class U, that will have among other things a property that holds the current U values.

so:
class U {
....
int id;
String propertyToHoldUValue;
... more stuff.
}
and the table for U will have at the minimum

uId and uValue.

Now in

A and B I see having

class A{
.....
Set <U> zeroToNUs;
....
}
class B{
.....
Set <U> zeroToNUs;
....
}

Now how does map this? Should I use join tables? Should I use a discriminator? If so what would the mappings look like? I also see in the future other objects having 0..n U.

Thanks,
Bal


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 08, 2009 9:26 pm 
Beginner
Beginner

Joined: Sun Dec 28, 2008 6:01 pm
Posts: 24
You could use <set> to map U objects in your A hbm xml file. Something like this in your A.hbm.xml


Code:
<set name="UObjects">
         <key>
            <column name="U-TABLE-ID" length="123" />
         </key>
         <one-to-many class="com.UClass" />
</set>



__________________________________________
Please do RATE if this post was helpful


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.