hibernate validator - different groups on create, update, delete

后端 未结 1 1185
[愿得一人]
[愿得一人] 2021-01-18 23:20

Using bean validation, particular hibernate validator implementation is it possible to define certain groups to automatically be used on certain crud operations like create

相关标签:
1条回答
  • 2021-01-19 00:10

    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.

    0 讨论(0)
提交回复
热议问题