开发者

Hibernate delayed validation until commit

开发者 https://www.devze.com 2022-12-13 06:03 出处:网络
Can somebody give me a simple example on how to delay validation in hibernate till i commit the transaction.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号