Hi
I would like to implement a two-level-hierarchy. First level uses a SINGLE_TABLE inheritance strategy with Secondary Tables for all Subclasses (e.g. BooleanCondition, see below). Second Level uses a SINGLE_TABLE strategy (no Secondary Tables for subclasses).
I tried to implement this like follows:
I quickly list the annotations I used for the Entities from top down (class hierarchy):
1: Abstract Class
Code:
@Entity
@Table(name = "CONDITION", schema = "ESV")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "CONDITION_KIND", discriminatorType = DiscriminatorType.STRING)
public abstract class Condition {
2: Abstract Class
Code:
@Entity
@SecondaryTable(name = "BOOLEAN_CONDITION", pkJoinColumns = { @PrimaryKeyJoinColumn(name = "AS_CONDITION_ID") })
@DiscriminatorValue("BOOL_COND")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "BOOLEAN_CONDITION_TYPE", discriminatorType = DiscriminatorType.STRING)
public abstract class BooleanCondition extends Condition {
3: Concrete Class
Code:
@Entity
@DiscriminatorValue("AND")
public class AndCondition extends BooleanCondition {
Problem:
Second Hierarchy seems not to work. The Discriminiator Column is not set.
Code:
Caused by: java.sql.SQLIntegrityConstraintViolationException: ORA-01400: Einfügen von NULL in ("BOOLEAN_CONDITION"."BOOLEAN_CONDITION_TYPE") nicht möglich
Has anybody an idea how this could be done properly?
Thanks for any hints.
Michael