-->
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.  [ 2 posts ] 
Author Message
 Post subject: commit and flush
PostPosted: Fri Dec 10, 2004 9:42 am 
Newbie

Joined: Fri Dec 10, 2004 9:28 am
Posts: 2
Hi all,

I'm a newbie and just realised that commit and flush are two different beasts.

I think (please, no offense) the documentation of H. is a bit misleading. That is, in the case one lets h. manage the jdbc connection for us (see 3.4 in the ref. documentation), then one also has to make sure he calls session.connection().commit() before close() ? That is :

Code:
Session session = currentSession();
GlossaryTerm princess = new GlossaryTerm();
princess.setTerm("King");
princess.setDescription("arthur");
session.save(princess);
session.flush(); // Is this really necessary ?
session.connection().commit(); // Really store the data


I think the doc is misleading because it says that if nothing spedcial is done, then H. provides a connection (cool for us newbie !), but (section 9.7.2) it also says that "If you are managing JDBC transactions yourself..." you should call commit(). My misunderstanding comes from the fact that I assume that if h. gives a connection to me, then I'm not managing it myself (so I don't have too commit(), which seems wrong because if I don't do it, the data doesn't end in the database).

So am i plainly wrong or just too dumb to read the doc correctly (then I appreciate if one can show me what I missed) or, right ?

thx,

stF


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 10, 2004 9:50 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You should use the Transaction API anyways, then you don't have to flush and commit at the transaction level.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.