tags:

views:

65

answers:

1

Hi

Can somebody give me a simple example on how to delay validation in hibernate till i commit the transaction.

In oracle for example 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

+1  A: 

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.

Arthur Ronald F D Garcia
Is there a simple example out there somewhere which walsk me through this use case.
Edwards