Hello all,
Hibernate version: 3.2
What I want to do is that class B inherits A by "table per class" and C inherits B by "single table".
But JPA/Hibernate generates tables where both inheritance strategies are "table per class". Here is a simplified version:
Code:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class AbstractObject implements Serializable {
...
}
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="P_TYPE", discriminatorType=DiscriminatorType.STRING, length=1)
@DiscriminatorValue(value="P")
public class Pet extends AbstractObject implements Serializable {
...
}
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(discriminatorType=DiscriminatorType.STRING, length=1)
@DiscriminatorValue("D")
public class Dog extends Pet {
...
}
What I expect is that hibernate generates db tables AbstactObject and Pet where Pet also has the columns of Dog.
But what hibernate does is to ignore the inheritance annotations of Pet and Dog and generate 3 tables.
I need to keep this object structure as it is generated by another tool. Is there any way to fix this?
Thanks in advance.
PS: Pet and Dog is not my actual object model :) just wanted to make something easy to understand for people who are kind enough to help.