7 Eylül 2009 Pazartesi

jpa inheritance mechanism

i do not reinvent the wheel by explaning jpa inheritance mechanism here, it is already well documented at many places one of which http://windhood.wordpress.com/2009/03/03/jpa-inheritance-overview/

instead, i mention a bug i have met.. i think it is a bug, correct me if i am wrong :)

assume there is a root class ClassA which ClassB inherits from.. and there is a ClassC which inherits from ClassB..

@Inheritance(strategy=InheritanceType.JOINED)
public ClassA {
...
}

@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
public ClassB extends ClassA {
...
}

public ClassC extends ClassB {
...
}

It does not matter which inheritance type you specified for ClassB, for all hierarchy, the inheritance type specified for ClassA, the very root class, is used. 
In above case, the inheritance strategy is JOINED for all..

well, that is all.. 

Hiç yorum yok:

Yorum Gönder