-->
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.  [ 3 posts ] 
Author Message
 Post subject: Store childdata of two classes in one table
PostPosted: Tue Jul 31, 2007 3:55 am 
Newbie

Joined: Wed Apr 25, 2007 8:23 am
Posts: 8
Hi,

how to map this:

Code:

class A {
Set<class C>
}




Code:
class B {
Set<class C>
}



Every class should be mapped to one table.
Class A and B can have same values for their ids in the tables.

Sets of C are disjoint for A and B.

I haven't found any solution, yet.

Thanks !

(Using Hibernate3)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 01, 2007 3:02 am 
Newbie

Joined: Thu May 17, 2007 5:29 am
Posts: 13
Option 1> Keep two id columns in C : id_A, id_B, for any row one would be null, the other pointing to the parent.
Option 2> Keep Set<C> in a separate class D, and add methods in A/B to convert to/from D to Set<C>, so A/B contain foreign keys to D, while D contains Set<C>. (Don't map A.set, rather map A.d)

The first one will not involve any code change.

_________________
--
Saugata
Please rate if this post helps


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 01, 2007 8:16 am 
Newbie

Joined: Wed Apr 25, 2007 8:23 am
Posts: 8
Thanks saugata,

but where can I place the mapping for C ?
Is it twice in the mapping for A and B,
with the little difference you described ?


nola


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