鉴于以下类和接口JSR303验证组继承
class A{
@NotNull(groups=Section1.class)
private String myString
}
interface All{}
interface Section1 extends All {}
当调用
甲一个新= A(); validator.validate(a,All.class);
我认为它应该是无效的,因为myString为空,它不是空组延伸所有,但它不。请注意,我正在使用验证器的Hibernate impl(4.0.2.GA)
+1这个很好的解释。我对整个概念的唯一问题是,我不能让默认组扩展我的部分。所以当我希望Default组验证所有内容时,我必须将它添加到我使用另一个组的所有地方。至少我是这么想的。刚才看到您可以重新定义默认组:http://beanvalidation.org/1.0/spec/#constraintdeclarationvalidationprocess-groupsequence-redefiningdefaultgroup – Gandalf 2015-02-10 20:07:11