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
|