问题
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