我可以使用Hibernate的实体标注与Bean验证 [英] Can I use hibernate entity annotations with bean validation
本文介绍了我可以使用Hibernate的实体标注与Bean验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
要在JSF 2使用Bean验证表单域,就可以像豆@Length(最大值= 5)使用注解
。
To use bean validation for form fields in JSF 2, you can use annotations in the bean like @Length(max=5)
.
然而,由于这些约束在我的Hibernate实体对象已经被定义,例如: @Column(NAME =FIELDX,长度= 5)
,我想知道如果有使用它们验证的方法?
However, since these constraints are already defined in my Hibernate entity object, for example: @Column(name = "FIELDX", length = 5)
, I was wondering if there's a way to use them for the validation?
推荐答案
没有,你不能。你应该不是,因为:
No, you can't. And you shouldn't, because:
- 而字段定义保留验证逻辑可能会更改
- 只有少数的约束可以被映射到的列定义
这篇关于我可以使用Hibernate的实体标注与Bean验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文