Hi folks,
I'd like to know if and how I could map several objects to several tables when using the SINGLE_TABLE inheritance strategy? For example I got four classes:
Code:
abstract class Class1
abstract class Class2 extends Class1
class Class3 extends Class2
class Class4 extends Class2
And I'd like to have attributes from class Class1 in one table and attributes from classes Class2, Class3 and Class4 in an other, second table.
I've tried with @SecondaryTable, but unfortunately failed. Hibernate generates three (!) forein keys pointing to Class1. Thus when I try to persist a object of type Class3 or Class4 I get a DuplicateKeyException as probably every object in the hierarchy tries to persist its data with the same id on the second table. Using different names for the foreign keys, the same fails due to a forign key constraint.
Any ideas how I could achieve the above mentioned goal?