-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Delayed constraint checking?
PostPosted: Mon Apr 03, 2006 4:59 am 
Newbie

Joined: Mon Apr 03, 2006 4:22 am
Posts: 1
Hello,

I need to have delayed constraint checks done, i.e. all constraints should be checked at commit time; this allows for temporarily inconsistent states while a transaction is in progress. I encountered two problems there so far:

1) Setting the constraints at the DB level. I tried to subclass Dialect (Oracle9Dialect) to add the known "deferrable initially deferred" clause at "not-null" or "unique", but the only hook there is getAddForeignKeyConstraintString(...) and it seems only few SQL is dispatched over the Dialect to that extent. For example, Table.sqlCreateString(...) and UniqueKey.sqlConstraintString(...) all use hardcoded SQL for uniqueness and not-null constraint creation. My solution was to patch these Hibernate classes directly ... .

2) Hibernate checks upon saving objects. When calling Session.save(...), Hibernate eagerly performs not-null constraint checks, etc. Is there a way to delay these to commit time, for the same reasons? I have a hard time understanding why it is done like this, consider a class where "a" is declared not-null:

then

Code:
obj.setA(null);
session.save(obj);


would fail, whereas:

Code:
session.save(obj);
obj.setA(null);
...
obj.setA(<something ok>)
tx.commit();


would pass.

I initially tried to delay the session.save(...) until very late in the transaction, but then you get other problems because domain code may already refer (or use them in queries, etc.) to persistent objects not yet known to Hibernate.

Any ideas? Anyone had similar stuff?

zup


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.