-->
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.  [ 4 posts ] 
Author Message
 Post subject: Child object save autotmatically.
PostPosted: Thu Mar 30, 2006 1:12 pm 
Newbie

Joined: Tue Dec 06, 2005 10:13 am
Posts: 17
Background: I am using Hibernate 3 in a web application. I use OpenSessionInView filter to open a session-per-request. On each request I start hibernate transaction and at the end I make: commit transaction. If any exception occurs I make a rollback.

Problem:
I have a screen that shows an object and its childs are detailed in a table. One column in the table is editable and the user can change a specific value of the childs. The screen has sevral commands. Some of them causes the screen to be relaoded. meaning that a session will be recreated on each request of the reload.

My problem is, that when I change some values of the childs and just press a link that causes the page to be reloaded, the data is somehow being saved to database by Hibernate. I also have a link in which I directly save the specific object, but it seems that the child objects are saved anyway, only be reloading the page by pressing some other link.

Does Hibernate saves child data even without directly specifying session.saveOrUpdate() ? I have a lot of other screens in my application that never did this problems ...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 30, 2006 2:40 pm 
Beginner
Beginner

Joined: Mon Jan 23, 2006 12:01 pm
Posts: 46
Hi,

I have the same problem. The thing is that if you enable cascade mode (save-update, for example), Hibernate runs 'cascade checker' code when your transaction commits (flushes all changes to objects), and this is when your updates are performed.
Now the question is: how do you tell Hibernate to use cascade actions only when you do update or save? Unfortunately I haven't found the answer yet. Maybe someone will read this and help us both.

HTH,

Bratek


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 30, 2006 9:59 pm 
Newbie

Joined: Tue Feb 07, 2006 4:56 pm
Posts: 4
Location: San Diego, CA
I believe you can set AutoFlush on the session to be never. The exact semantics would be something to the effect of:

session.setFlushMode(FlushMode.NEVER);

Obviously, this has some other side-effects I'm not really an expert at Hibernate so use your judgement.

Hope this helps
Derek


Top
 Profile  
 
 Post subject: Seems to be working fine ...
PostPosted: Wed Apr 05, 2006 11:32 am 
Newbie

Joined: Tue Dec 06, 2005 10:13 am
Posts: 17
Thanks!


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