Can I use hibernate entity annotations with bean validation

痴心易碎 提交于 2019-12-23 04:11:32

问题


To use bean validation for form fields in JSF 2, you can use annotations in the bean like @Length(max=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?


回答1:


No, you can't. And you shouldn't, because:

  • validation logic might change while field definition is retained
  • only a few of the constraints can be mapped to column definitions


来源:https://stackoverflow.com/questions/5718627/can-i-use-hibernate-entity-annotations-with-bean-validation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!