【发布时间】:2011-02-16 10:17:20
【问题描述】:
我正在使用 JPA 2.0/Hibernate 验证来验证我的模型。我现在有一种情况,必须验证两个字段的组合:
public class MyModel {
public Integer getValue1() {
//...
}
public String getValue2() {
//...
}
}
如果getValue1() 和getValue2() 都是null,则模型无效,否则有效。
如何使用 JPA 2.0/Hibernate 执行这种验证?使用简单的 @NotNull 注释,两个 getter 都必须为非 null 才能通过验证。
【问题讨论】:
标签: java jpa jpa-2.0 bean-validation