I am creating a website using Spring MVC and for persistence I am using Spring Data JPA with Hibernate 4 as my JPA provider. You have to ask some more experienced users if it is good or not.Validation is being handled at present with Hibernate Validator. In my understanding it is done only for checking things like nulls, sizes format, spelling maybe some checksums not an application logic. Think also about junit tests, transaction management and other problems that for sure you will have with this kind of design.
The following is the sequence of calls leading up to the failure: Can anyone shed light on why the validators are being called twice and in particular, why stepping over line 'user Repository.save(user);' goes back into these validators?
Many thanks Here is my class package com.dating.domain; import
However, in my opinion I don't think so it is a good idea to do ANY persistence operations during a bean constraint validation.
Is it because the validator was called outside of the Spring context? You are probably right: You are out of the Spring context.
Just out of curiosity, would you happen to know why the user Repository was null during the second call even though I have set it to be Autowired?
NONE: Bean Validation is not used at all Awesome, thank you this fixed my problem.
If no Bean Validation provider is present, an exception is raised at initialization time.
DDL: (not standard, see below) database schemas are entities are validated on creation, update and deletion.
CALLBACK: entities are validated on creation, update and deletion.
You can fine-tune that if needed: AUTO: if Bean Validation is present in the classpath, CALLBACK and DDL are activated.
The database schema generated by Hibernate also reflects the constraints declared on the entity.