-->
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: Session-per-conversation
PostPosted: Wed Oct 12, 2005 11:25 am 
Newbie

Joined: Fri Mar 04, 2005 2:02 pm
Posts: 18
Sessions and Transactions

I want to make sure I understand the session-per-conversation pattern where there is a long running Session (cache) and multiple database transactions.

If Session has flush mode set to never and I commit a database transaction is that transactional piece of work written to the database? If so, what is the purpose of ever calling flush if I have a commit at the very end of the last piece of work?

The root of the question is that I'm a bit confused about the relationship between commit and flush.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 12, 2005 11:44 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Quote:
If Session has flush mode set to never and I commit a database transaction is that transactional piece of work written to the database?


No, only when flush() is called. That's the purpose of FlushMode.NEVER, as per documentation. Search for the section about "Flushing".


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 12, 2005 4:40 pm 
Newbie

Joined: Fri Mar 04, 2005 2:02 pm
Posts: 18
Ok got it, thanks! Flush is when things get written to db.

Follow up question...when the session is flushed is the Session cache still populated?

Here is my situation and why I am asking...

I have an workflow app (not web based) that will execute a series of tasks, some of which need to be commited (in the db) incase the app fails mid process. I'd like to have a Session bound to a longer running workflow to take advantage of the cache but still allow a task to be able to commit to the db. This pattern seems to break the session-per-conversation because the db needs to be synchronized mid stream (but i still want the cache).

If the Session cache is still around after flush it sounds like I can flush at commit time and start stop Transactions around specific tasks???


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 12, 2005 7:26 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
clear()


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 13, 2005 12:34 pm 
Newbie

Joined: Fri Mar 04, 2005 2:02 pm
Posts: 18
Just to clarify then...Flush does not clear the cache right? Clear does.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 13, 2005 12:40 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
And load() loads stuff :)


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.