Hello,
I have a simple structure:
XYDiagram extends Diagram extends DiagramBase.
I want Hibernate to use the Table-per-Subclass inheritance strategy.
Everything is working fine so far but hibernate persists the child objects in the parent table.
Example:
I have an object of the type XYDiagram. I want to persist it. Hibernate inserts the object in the Table DiagramBase and not in the table XYDiagram (which exists!!).
My mapping files are:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<subclass
name="...Diagram"
extends="...DiagramBase">
</subclass>
</hibernate-mapping>
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class
name="DiagramBase"
table="DIAGRAMBASE">
<id
name="id"
column="DIAGRAMBASE_ID">
<generator class="native"/>
</id>
<discriminator column="DTYPE"/>
<property
name="name"
column="DIAGRAM_NAME"/>
<property
name="lockUser"
column="DIAGRAM_LOCK_USER"/>
<property
name="lockTimeStamp"
column="DIAGRAM_LOCK_TIMESTAMP"/>
</class>
</hibernate-mapping>
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<joined-subclass
name="XYDiagram"
extends="Diagram"
table="xydiagram">
<key column="DIAGRAM_ID" foreign-key="DIAGRAMBASE_ID"></key>
</joined-subclass>
</hibernate-mapping>
I would appreciate any help!
Thanks in advance & best regards
Alex