Hello,
i'm a new user of Hibernate mappings in my Java classes via Doclets.
And i have a few problems to resolve certain mappings...
I often have the following context :
- Class A
- Class B
These two classes are linked (n-n) by an association class C, witch have its own attributes (a kind of valuation of the link).
My Java Class "A" has certain attributes and a "getClassB-ObjectswithC-valuation()" method.
My Java Class "B" has the same inverse method, or a "getClassA-RefObject()" method if relation is 1-n.
I created a Java class "C" which contains its own attributes and one object of type A and one of type B.
In order to have this class work like the following "join table":
ClassAobj1 ClassBobj1 ClassCVal1
ClassAobj1 ClassBobj2 ClassCVal2
...
ClassAobj2 ClassBobj1 ClassCVal1
ClassAobj2 ClassBobj2 ClassCVal2
...
so the "key" of this table is (ClassA, ClassB) objects.
But i don't see how to declare/map this with hibernate doclets ???
shall i use (for Class A) something like :
@hibernate.set table="C"
@hibernate.collection-key column="A_ID"
@hibernate.collection-many-to-many
class="ext.xxx.data.bean.B"
column="B_ID"
foreign-key="A_ID"
but where do i define my class C attribute ?...
may i write something like :
@hibernate.set table="C"
@hibernate.collection-key column="A_ID"
@hibernate.collection-many-to-many
class="ext.xxx.data.bean.B"
column="B_ID"
@hibernate.collection-many-to-many
class="ext.xxx.data.bean.C"
column="C_ID"
primary-key="(A_ID,B_ID)"
or rather use a hibernate.map solution ? (which one) ?
I sometimes also have the same type of relations but with Class B = Class A. (an object A1 has a list of other A objects "valuated" with a C class attribute), which is even more difficult to write with doclet tags...
thank you in advance for any help!
Stephane
|