Can somebody give me a simple example on how to delay validation in hibernate till i commit the transaction.
In oracle for 开发者_如何学JAVAexample i can create a table with all the constraints as deferred so that validation takes place at commit time only and not at insert.
However i am currently not using Oracle
Hibernate Validator says:
Hibernate Validator integrates with Hibernate by applying the constraints on the database schema (DDL generation) and by checking entity validity before Hibernate inserts or updates instances
But you do not want validation before inserting or updating. So after seeing Interceptor API, there is a beforeTransactionCompletion method:
Called before a transaction is committed (but not before rollback)
This way you can validate your intances regardless of the target database.
精彩评论