Does JPA contains any validation API?
E.g. email property validation like this in hibernate validation:
@Email
public Strin开发者_如何转开发g getUserEmail() {
...
}
Bean Validation (JSR303) can be used nicely alongside JPA, but is a separate API. This is a very brief introduction to Bean Validation itself, and see this for how an introduction of how it can be used with JPA.
Note: Similar to JPA, you will have to pick an implementation, of which there are many. Hibernate Validator is the reference implementation.
精彩评论