Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JPA validation strategy

NetBeans let me choose between three values for the JPA validation strategy: Auto, Callback and None. What does "Auto" mean? Does "Callback" mean the use of @PrePersist, @PreUpdate, and @PreRemove?

Is there a performance hit if I use Auto or Callback if there is no validation to perform?

like image 446
deamon Avatar asked Feb 16 '10 12:02

deamon


1 Answers

The JPA 2.0 Spec (JSR 317) does not require a Bean Validation (JSR-303) implementation. Validation is optional. Thus, javax.persistence.ValidationMode can take different values:

  • Auto (default) - if a validation provider is available, then validation should occur
  • Callback - validation is required and a PersistenceException must be thrown if a provider cannot be obtained
  • None - no validation should be attempted and the lack of a validation provider should not cause an exception

This should answer all your questions.

like image 151
Pascal Thivent Avatar answered Oct 05 '22 01:10

Pascal Thivent