Hibernate version:
2.1.7
This is more of a question than a problem or issue. I've read Hibernate in Action and the manual, but did not see a clear answer to this.
I've got a somewhat deep class hierarchy, with five classes A, B, C, D, E, F and G, such as:
Code:
A G
/ \
/ \
B C
/ |\
/ | \
D E F
Mapping documents:Code:
<class name="A">
<id name="id"><generator class="native"></generator></id>
<set name="Gs" table="G" lazy="true" inverse="true">
<key column="a-id"/>
<one-to-many class="G"/>
</set>
</class>
...
<class name="G">
<id name="id"><generator class="native"></generator></id>
<many-to-one name="parent" class="A"cascade="none" outer-join="false"></many-to-one>
</class>
Background/Requirements:
- Class G has a many-to-one reference to any A or subclass of A. However in reality only instances of class B and E will be referenced.
- I need to access a collection of Gs from instances of subclass B and E.
- Instances of B and E are a very small minority of the total instances - way less than one percent.
Question:
How much overhead does it cost to handle the non-existent collections for all subclasses of A? It will be somewhat messy if I have to create two variations of G, one for B and one for E.
Thank you - Richard