Hello,
I have two classes, A and B which have two kinds of relationships between them. I have the following methods in class A :
public Set getBsRole1()
public Set getBsRole2()
In a previous database model, I had 2 link tables, where each one mapping a relationship. At this stage, it made no problem to use two <set> including a <many-to-many> element in the mapping of class A toward class B.
Now, I would like to have a more compact/normal database design and thus storing both relationships within the same link table using a kind of discriminator as an extra column...
I found some bits of solution using composite-elements. I would have just to create 2 such classes, where one of their property would contain the right discriminator value, but yet the returned sets in class A would contain these composite-elements referencing instances of B, not directly instances of B. So, this solution requieres some uneasy rework in the current application (no compil error, but runtimes errors !).
Does anyone have a better solution ?
Thank you in advance.
Xavier.
|