Hi,
does anybody know if and how I can apply Hibernate @Check constraints on secondary tables?
Imagine following class hierarchy:
Code:
@Entity
@Table(name = "class_a")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "discr", discriminatorType = DiscriminatorType.STRING, length = 1)
@DiscriminatorValue("A")
public abstract class A {
...
}
and
Code:
@Entity
@Check(constraints = "flag = true")
@SecondaryTable(name = "class_b")
@DiscriminatorValue("B")
public class B extends A {
..
@Column(table = "class_b", name = "flag")
private boolean flag;
}
The code snippets should describe what I'd like to achieve. Unfortunately the @Check constraint on class B does not produce any output when generating the database DDL.
When I place the @Check constraint from above to class A, the generated DDL contains the contraint, but on table class_a. :(
So any idea how I may apply such a @Check constraint to a secondary table? Thanks in advance for your help!
Regards,
bitbyter