-->
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: setting that tells Hibernate to automatically commit changes
PostPosted: Thu Nov 03, 2005 4:03 pm 
Newbie

Joined: Thu Nov 03, 2005 3:52 pm
Posts: 3
Location: Chico, CA
This question is regarding Spring MVC and Hibernate.

I have code in my SimpleFormController to break out if the cancel
button is hit... I verified that it works and is not hitting my onSubmit
method... but it is still saving the object with the info from the form... looking at the logs, I can see that it DID NOT enter the onSubmit method and it NEVER red my saveUser method which is the only place that I have code to
save that object.

Logic would tell me that I have a setting somewhere that tells
Hibernate to automatically commit changes to my objects (could be a Spring setting but I'm leaning towards Hibernate)... does anyone know of a setting that would do this?

I'm fairly new to both so I'm hoping it is a simple setting somewhere.

thanks a lot to the hard working folk here. Thanks for your time and patience

ilango


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 03, 2005 6:39 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Assuming your using a Transaction filter; if you change an object's data it will be dirty thus when the transcation is commited an update will automatically occur as hibernate is aware/determined that the object has changed. No need to call save in this case.


Top
 Profile  
 
 Post subject: transaction filter
PostPosted: Fri Nov 04, 2005 5:54 am 
Newbie

Joined: Thu Nov 03, 2005 3:52 pm
Posts: 3
Location: Chico, CA
I am using a Transaction filter. I'm not sure I understand why an
autocommit is done like this... the Command object is already set when I go to check for the call for cancel... so I would need to reset the object to
original state before the Transaction manager decides to commit the changes.

Can you give me a hint as to what approach to take?... ex. do I look at
the Transaction docs to figure out how to turn the autocommit off or do I
do what I mentioned above and just make sure that I reset the Command
object to original state?... the 2nd idea seems dumb and the whole idea of
autocommit goes against the idea of transactions anyway doesn't it?

I'd be more than happy to learn deeper on the subject

I have both Spring in Action and Spring Live! books and I don't recall
anything about this in those books.

Thanks very much once again

ilango


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 04, 2005 9:34 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Yust do not modify object on "cancel" (you do not need to load it too).


Top
 Profile  
 
 Post subject: hi
PostPosted: Fri Nov 04, 2005 5:12 pm 
Newbie

Joined: Thu Nov 03, 2005 3:52 pm
Posts: 3
Location: Chico, CA
I got an idea. Is it possible for you to elaborate. Thanks once again. You have been very helpful.

Could you give me an example, if possible.

thanks very much


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 04, 2005 10:32 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
When you cancel - that workflow should not modify the hibernate object. If you doing a wizard type operation then you would rollback the transaction on cancel.


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.