I have a problem with Hibernate and Hibernate Validator 5. I have some entity, let's say Group
and another entity Person
. They are related as follows: Group has two references to Person - contact person and manager. They are both one-to-one relationships with full cascade and orphan removal options.
What I want is to validate the contact person and the manager while the group is being saved. The more, I want a different validation group to be used to validate contact person and manager. In order to do this, I placed @ConvertGroup(from = Default.class, to = ContactPersonValidation.class)
together with @Valid
before the contact person field and I did it analogously for manager field (using different validation group).
Now, Hibernate validation does not work - I mean that the group is not converted to the one provided in @ConvertGroup
. I followed the source code of Hibernate validator and it seems to validate Group object and two Person objects separately. Therefore, Person validation is not cascaded from Group object and the validation group is not converted.
Have you ever experienced a similar problem and know how to solve it?