Reputation: 5544
Using bean validation, particular hibernate validator implementation is it possible to define certain groups to automatically be used on certain crud operations like create or update?
or are there some build in hibernate groups that are internally checked for those operations?
Upvotes: 5
Views: 1694
Reputation: 128829
You're probably looking for "Hibernate event-based validation" under "ORM Integration". You can set properties to specify which groups to validate at different times by setting properties on the SessionFactory like so:
<property name="javax.persistence.validation.group.pre-persist">javax.validation.Default</property>
<property name="javax.persistence.validation.group.pre-update">javax.validation.Default</property>
<property name="javax.persistence.validation.group.pre-remove"></property>
The above is the default configuration if you don't specify anything. Specifically, the javax.validation.Default
group is validated on creates and updates. Nothing is validated on deletes.
Upvotes: 6