-->
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: When do session execute the JDBC statements?
PostPosted: Sat Nov 22, 2003 5:28 am 
Newbie

Joined: Thu Nov 13, 2003 1:14 pm
Posts: 18
Location: Leinfelden-Echterdingen, Germany
Being relatively new to hibernate, I never stop reading the reference manual. Today I found the following in section 7.8 (Flushing Sessions):

Quote:
Except when you explicity flush(), there are absolutely no guarantees about when the Session executes the JDBC calls, ...

Could someone just help me to get things clear: I thought that sessions can be considered as logical transactions. I planned to use sessions exactly like this. E.g. a user makes changes to an object through an UI. On user commit I would flush the session, on user abort, I would discard the session hopefully hibernate acts like I think it acts.

Is this scenario coherent with hibernate architecture or may the session be flushed at arbitrary moments without explicitely flushing it?

Thanks for your help,

Peter


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 22, 2003 5:39 am 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
Quote:
On user commit I would flush the session


You also need to commit transaction then. See "7.9. Ending a Session" for details. For your application this should work fine - you open session, user does whatever he wants and when he clicks "finish" you flush session, commit transaction.

Session may also be flushed by Hibernate when you call session.find() method.

[/quote]


Top
 Profile  
 
 Post subject: Re: When do session execute the JDBC statements?
PostPosted: Sat Nov 22, 2003 9:58 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
wielanpr wrote:
I thought that sessions can be considered as logical transactions.


Well not really. Before any query, Hibernate need to flush previous changes to objets to preserve consistency of query result (would be very hard/impossible otherwise).
So you cannot suppose that all you've done can be executed or discarded by the session.flush() method.

Keeping transaction consistency is done via DB transaction.

_________________
Emmanuel


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.