I have the following table structure (abbreviated for brewity):
Code:
table A (a_id PK)
table B (b_id PK)
table C (c_id PK, a_id FK ref A(a_id), b_id FK ref B(b_id))
Table C has an independent master-detail relationship with both A and B (and these two are not related in any way)
Here's what I'm trying to accomplish in Java:
Code:
class A {
Map<B, Set<C>> mapping;
}
class B {
// no link to the other two
}
class C {
A a;
B b;
}
In other words, instead of keeping A->C relationship as a simple master-detail (as it is), I'd like to get it grouped by B. Is it possible in Hibernate? I've been playing with ternary association, like that:
Code:
<class name="A">
<map name="mapping">
<key column="A_ID" />
<map-key-many-to-many class="B" column="B_ID" />
<one-to-many class="C" />
</map>
</class>
but this seem to only map one instance of C for each B (so that I get a Map<B, C> structure).