-->
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.  [ 3 posts ] 
Author Message
 Post subject: Advanced question: Dirty Checking vs. SaveOrUpdate
PostPosted: Fri Apr 22, 2005 4:04 am 
Newbie

Joined: Fri Apr 22, 2005 3:17 am
Posts: 5
Hi there everybody,

i got the following problem in my application using Hibernate 2.1.7 in a Tomcat 5.0 w/ Java 5 and an Oracle 8i DB.

i retrieve an business object (i.e. an Employee) and i change some properties on it. when i click on the save button i want a popup to open asking me wether i really want to apply the changes. Therefore i used to call session.saveOrUpdate( model ) after retrieving and call session.isDirty() on save to open the popup or not.

The problem is when the model is a new instance and the db table has not-null columns. SaveOrUpdate automatically creates an insert statement in the batch process, inserting null values to all columns, as a new employee never has any default values/associations. Obviously this causes an sql error at not-null columns.

i excepted the session only to create statements when a transaction is started, which isn't the case here. The transaction begins right after i accepted the save popup.

Is there many option to change this behaviour in the mapping file?
How do you/other users manage the dirty checking in there application?

TIA,
Lothar


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 22, 2005 8:14 am 
Senior
Senior

Joined: Mon Apr 04, 2005 8:04 am
Posts: 128
Location: Manchester, NH USA
Just to clarify - you are/were calling saveOrUpdate outside the context of a transaction? Can you post relevant code?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 22, 2005 8:41 am 
Newbie

Joined: Fri Apr 22, 2005 3:17 am
Posts: 5
yes, it is used outside the transactrion, just to get the dirty checking.
But it seems as i can solve the problem by calling saveOrUpdate() only on existing instances and do a more complicated dirty check including a check if an instance is new before opening my popup window.

anyway i won't expect the method saveOrUpdate generating insert statements outside a transaction.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.