-->
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-many surrogate key
PostPosted: Tue Dec 07, 2004 4:42 pm 
Newbie

Joined: Tue Dec 07, 2004 4:05 pm
Posts: 1
Hello,

I'm trying to map an existing schema, my problem is the following:

The class A is stored in table A with primary column APRIMARY.

Collections of A are stored in table AS with column ASPRIMARY and
foreign key column ASREF references A

The class C references collection of A: there is a column CAS which references the column ASPRIMARY of AS

The class D references collection of A: there is a column DAS which references the column ASPRIMARY of AS

eg
A: APRIMARY
1
2
...

AS: ASPRIMARY ASREF
1 1
1 7
2 1
2 9

C: CPRIMARY CAS
1 1

D: DPRIMARY CAS
1 2

How can i map this schema ?
Moreover how can i map such a design if the collection is heterogenous ? (that is to say the table AS contains one more column which is the class id)

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 08, 2004 3:56 am 
Senior
Senior

Joined: Sat Jul 17, 2004 5:16 pm
Posts: 143
I thought I saw a post saying this is not possible. Foreign keys in hibernate map off the primary key (in hibernate).

As an aside, OJB handles this. :) Kind of a mute point since Hibernate is better than OJB in most aspects.

I would map all the objects with no relationships like this, and do your queries external to the mapping to populate/persist the structure. Use helper methods.

Chris


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.