Jsr303-hibernate-events-injection is a project mainly written in Java, it's free.
This small project demonstrates how to configure Spring's bean injection with Hibernate event-based validation.
The reference Hibernate Validator documentation states that it is possible to configure Hibernate to validate beans before three events:
Although this is convenient for simple validators, more complex custom validators might require that you inject references to beans managed by your Spring context. The example presented in Hibernate Validator's documentation doesn't mention this possibility. Although it is possible to do it, the exact way may not be immediately obvious.
This project defines:
com.github.davidmarquis.model.validation.CustomValidationValidator
) that
has an @Autowired
bean injected.com.github.davidmarquis.model.User
) that uses this custom validation rule on the email
field.src/main/resources/applicationContext.xml
.Run maven test
in the project root to see this in action.