请考虑以下内容
@Entity
@Table
@Check(constraints = "A IS NOT NULL OR B IS NOT NULL")
public class Model {
@Id
private Long id;
private A a;
private B b;
}
问题是我不知道如何命名checkConstraint吗? 我想要的是类似@Check(constraints = @Constraint(“ name” =“ CHK_CONST_1”,“ A IS NOT NULL或B IS NOT NULL”))的东西
答案 0 :(得分:0)
我认为您应该使用@Column
和name
属性来指定列的名称。
@Entity
@Table
@Check(constraints = "COL_A IS NULL OR COL_B IS NOT NULL")
public class Model {
@Id
private Long id;
@Column(name = "COL_A")
private A a;
@Column(name = "COL_B")
private B b;
}