-->
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.  [ 1 post ] 
Author Message
 Post subject: bidirectional association with maps on both ends
PostPosted: Thu Sep 01, 2005 7:58 pm 
Newbie

Joined: Mon Aug 29, 2005 10:20 am
Posts: 1
Hi,

I'm a beginner with Hibernate Annotations(3.1b4) & Hibernate(3.1b1)
and I'm not sure how to map the following (bit more advanced) scenario.

The basic idea is to have a bidirectional 1:n relationship which depends on
a string key (context). The navigation should occur via maps on both
association ends i.e.

a has members e1, e2, e3 in context "1"
a has members e4, e5, e2 in context "2"
b has members e6, e7, e2 in context "3"
via linkToTargets

e2 has parent a in context "1"
e2 has parent a in context "2"
e2 has parent a in context "3"
via linkToSource


class Thing {
...
Map<String, Thing> linkToSource;
Map<String, Set<Thing>> linkToTargets;
...
}

Whereas the association table should be something like (omitting fks)

create table assoc (
linktosource_id integer NOT NULL,
context varchar(255) NOT NULL,
linktotarget_id integer NOT NULL)
create unique index xy
ON assoc (context, linktotarget_id)


Is this possible with EJB3/Hibernate Annotations? If not what would the hibernate xml mapping look like?

Any help would be much appreciated,
--John


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.