-->
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.  [ 6 posts ] 
Author Message
 Post subject: deferring constraint validation till commit-time
PostPosted: Tue Apr 26, 2005 7:13 pm 
Newbie

Joined: Mon Jun 14, 2004 4:47 am
Posts: 7
[b]Hibernate version:3.0[/b]

I have some objects with NOT NULL constraint on them.
When a query happens, the system tries to flush the dirty objects to the database before answering the query and raising an exception because of the not null constraints.

My understanding of the options are as follows: I can either set the FlushMode=COMMIT, which will result in stale data, and -I presume- will not incorporate any new objects i have created in memory, OR get rid of the NOT NULL constraints all together, and enforce them only in my Java API. Both options have obvious issues.
Can anyone recommend an alternate solution?
Thanks,
Kagan


Top
 Profile  
 
 Post subject: deferring enforcement of constraints until commit time
PostPosted: Tue Apr 26, 2005 7:18 pm 
Newbie

Joined: Mon Jun 14, 2004 4:47 am
Posts: 7
Just to be clear:
- I would like to enforce the not null constraints at commit time, but don't mind having null values during the flush, since those validation errors will likely be fixed in subsequent operations within the transaction, or else the entire transaction will fail.

Also: does anyone have any input on performance implications on auto-flush behavior for short transactions. Any locking/concurrency issues that we have to be aware of as a result of auto-flush?
------------------------
I have some objects with NOT NULL constraint on them.
When a query happens, the system tries to flush the dirty objects to the database before answering the query and raising an exception because of the not null constraints.

My understanding of the options are as follows: I can either set the FlushMode=COMMIT, which will result in stale data, and -I presume- will not incorporate any new objects i have created in memory, OR get rid of the NOT NULL constraints all together, and enforce them only in my Java API. Both options have obvious issues.
Can anyone recommend an alternate solution?
Thanks,
Kagan


Top
 Profile  
 
 Post subject: deferring enforcement of constraints until commit time
PostPosted: Wed Apr 27, 2005 3:07 am 
Beginner
Beginner

Joined: Thu Oct 16, 2003 7:30 am
Posts: 21
Location: Brussels
Which database are you using? Oracle allows you to define your database constraints as "deferred", such that they are only checked at (database) commit time.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 27, 2005 12:58 pm 
Newbie

Joined: Mon Jun 14, 2004 4:47 am
Posts: 7
thanks for the hint.
is there a way to set oracle's constraint policy within hibernate during schema export, or is it something we should do outside of hibernate, within oracle?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 27, 2005 2:34 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
You need to perform this within Oracle.

Also note that there is a connection-level setting you need to set to get oracle to defer constraint checking (the name of it escapes me at the moment) in addition to marking the constraints as defer-able.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 27, 2005 8:15 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
you can disable constraint, for example

alter table my_table disable constraint my_table_constraint
/

You can view user_constraints and it is easy make procedure for disable/enable all constraints
for table or scema/user

it is similar for trigger, too
regards


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

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.