We have a class Hit with several subclasses (let's say TrademarkHit)
Code:
<class name="com....Hit" table="HIT" abstract="true" >
...
</class>
<joined-subclass name="com....TrademarkHit" table="TRM_HIT" extends="com...Hit" abstract="true">
<key column="TRM_HIT_ID" on-delete="cascade"/> <!--NOTE THE ON-DELETE !!! -->
</joined-subclass>
It seems that the on-delete="cascade" does have no effect on the executed queries.
Hibernate still first deletes the 'subclass tables', before deleting the 'main class' table: HIT
Code:
DEBUG SQL:401 - delete from CCL_HIT where (CCL_HIT_ID) IN (select HIT_ID from HT_HIT)
DEBUG SQL:401 - delete from NONTRADEMARK_HIT where (NONTRADEMARKHIT_ID) IN (select HIT_ID from HT_HIT)
DEBUG SQL:401 - delete from TRM_HIT where (TRM_HIT_ID) IN (select HIT_ID from HT_HIT)
DEBUG SQL:401 - delete from HIT where (HIT_ID) IN (select HIT_ID from HT_HIT)
DEBUG SQL:401 - delete from HT_HIT 14:09:11,405
(other tables come from other joined-subclasses)
I would think that Hibernate knows that on-delete cascade is on, so it does not need to delete all subclass tables; this is done by the db (Oracle)
The creation of the temporary table is in this case also not needed.
Any thoughts on this?