Hi,
I would like to perform the following mapping, can someone help?
I have an interface, from which 2 abstract classes are derived:
BASE --> AB1, AB2
There is a very big difference between the fields of AB1 and AB2, so just for them, I would like to use the table per-subclass approach ('joined-subclass').
However, all classes
derived from AB1, AB2 do not add any members, I would like to keep the entire AB1 hierarchy in a single table. Same goes for AB2.
BUT: I cannot define a "discriminator column" for AB1, AB2 because they are declared as 'joined-subclass'!! Also, I cannot use the "table per subclass using disc." because it does not accept the 'many-to-one' property for some reason...
Can someone help me understand how I am supposed to map this???
Hibernate version:
3.1
Mapping documents:
For the base interface:
Code:
<class name="Base" table="BASE">
<id name="id" column="BASE_ID">
<generator class="native"/>
</id>
</class>
For AB1:
Code:
<joined-subclass name="Ab1" extends="Base" table="AB1">
<key column="AB_ID"/>
<discriminator column="class" type="string"/> <-------- ERROR
<many-to-one name="server" column="SRV_ID" cascade="all" class="Server"/>
<property name="name" column="NAME" access="field"/>
</joined-subclass>
For AB2:
Code:
<joined-subclass name="Ab2" extends="Base" table="AB2">
<key column="AB_ID"/>
<discriminator column="class" type="string"/> <-------- ERROR
<many-to-one name="site" column="SITE_ID" cascade="all" class="Site"/>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: