Hi
I have the following structure:
Class Organisation mapped to TORGANISAT table, it contains an Id and some general fields and there are some Sub-classes and DB table with a foreign key (fk_torg_laufnr) to the organisation table for each subclass.
The Mapping looks something like that:
Code:
<hibernate-mapping>
<class name="najs.model.Organisation" table="TORGANISAT">
<cache usage="read-write" />
<id name="id" column="ILAUFNUMMER" type="java.lang.Integer">
<generator class="sequence">
<param name="sequence">seq_torganisat</param>
</generator>
</id>
<property name="orgNr" type="java.lang.String">
<column name="SORGNR" length="10" not-null="false" />
</property>
[...]
<joined-subclass name="najs.model.Schule" table="TSCHULE">
<key column="FK_TORG_LAUFNR" />
<property name="name" type="java.lang.String">
<column name="SNAME" length="50" not-null="true" />
</property>
[...]
</joined-subclass>
[...]
<joined-subclass name="najs.model.Verein" table="TVEREIN">
<key column="FK_TORG_LAUFNR" />
<property name="name" type="java.lang.String">
<column name="SNAME" length="50" not-null="true" />
</property>
[...]
</joined-subclass>
Now I have to convert some Class-Objects to other Subclass types (eg School to Institution). On DB the only thing that should be done is to delete the entry in TSCHULE (for School) and insert new entry in TVEREIN (Institution), but leave the base in TORGANISAT untouched.
I've done it so far with native sql (direct on the jdbc connection from hibernate), but I cannot load the new Object with Hibernate in the same Request. I've checked it by setting a breakpoint after the commit is done with Squirrel SQL Client, the changes are on DB but Hibernate returns then the old data.
Does anyone now a better solution for this type of cast? Or at least how I can get the actual data from Hibernate?[/code]