I also want a 3 level heirarchy:
Code:
A (annotated with @MappedSuperclass)
/ \
B C (These use table per class. General business entities)
/ \
D E (no attributes, annotated with DiscriminatorValue)
Class "A" is our "BaseEntity" class. It defines the id, version, and an audit embedded object wich we want all our business entities to have. The entities are all on seperate tables of course.
All our business entities are instances of BaseEntity. This is
very convenient.
But now we want another subclass heirarchy
below that with class "B" which is in fact called "Preference" being the root of a new subclass heirarchy which uses SINGLE_TABLE strategy.
Our user preferences are all going to be keyed similarly, only the value held will change between the different types, so what we need is one Preference table, a "preference_type" discriminator column, and there will be columns for each subclass's value type.
What is is creating is
seperate tables for each subclass of Preference.
The Preference table is being created with the discriminator column! But its subclasses get
seperate tables in spite of Preference having:
Code:
@Entity
@Inheritance(strategy=SINGLE_TABLE)
@DiscriminatorColumn(name="PreferenceType", discriminatorType=INTEGER)
public abstract class Preference extends BaseEntity implements Serializable {
It appears that Hibernate inheritance can only be one level deep?!!!
Can that
possibly be true?