Hello everybody,
I have the following situation:
An abstract base class with a generic element.
Code:
@Entity
class abstract abstractBaseClass <T>{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer Id;
private T element;
}
Some of the following classes:
Code:
@Entity
class A extends abstractBaseClass <KlasseX>{
@ManyToOne(targetEntity = KlasseX.class)
public KlasseX getElement() {
}
}
@Entity
class B extends abstractBaseClass <KlasseY>>{
@ManyToOne(targetEntity = KlasseY.class)
public KlasseY getElement() {
}
@Entity
class C extends abstractBaseClass <KlasseZ>{
@ManyToOne(targetEntity = KlasseZ.class)
public KlasseZ getElement() {
}
Everything works just fine, when I use (strategy = InheritanceType.JOINED) in the abstractBaseClass
But because of performance issues I rather use @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) to have a single table per class. But that somehow does not work. I also read some about it and it is not realy recomended.
However, I could live with the SINGLE_TABLE sollution, but the generic type makes this impossible to use. I get constraint violation exceptions from the Database (of course I do)
The sollution must work with Oracle and MsSQL, so a sollution just for one DB System is not the desired one.
I hope I could make myself clear and someone can help me with it.
greets
Santo.