-->
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: Transaction that spans Session and StatelessSession
PostPosted: Thu Jun 19, 2008 3:42 pm 
Beginner
Beginner

Joined: Sun Aug 22, 2004 11:00 am
Posts: 21
Is it possible to create a transaction that spans both Session and StatelessSession operations? obviously the operations would not occur concurrently.

can i manually fetch a connection from a C3P0 datasource (autocommit is false), then open a new Session using that connection, use it then open a StatelessSession using the same connection?

im guessing i would have to manually commit the connection and then close the Session and StatelessSession.

anyone have experience doing such a thing?

_________________
Ive got a Tomcat that Struts then Springs then Hibernates


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 20, 2008 5:50 pm 
Beginner
Beginner

Joined: Sun Aug 22, 2004 11:00 am
Posts: 21
i have found the solution to this and posted it in the other related thread i had started here:

http://forum.hibernate.org/viewtopic.php?p=2388548#2388548

pretty interesting for anyone considering this Transaction that spans Session and StatelessSession pattern.

_________________
Ive got a Tomcat that Struts then Springs then Hibernates


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 23, 2008 10:19 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Who even knew it was a pattern?

Great info!

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 24, 2008 12:15 am 
Beginner
Beginner

Joined: Sun Aug 22, 2004 11:00 am
Posts: 21
haha. well i coined that term myself. but im surprised no one had really brought this up before... mixing a Session and StatelessSession together.

all the examples i see of other people doing large batch operations with the StatelessSession API seem to be designed in a non-atomic way (for example, demarcating transaction boundaries around each JDBC batch rather than around the entire batch.

my main use case didnt seem all that uncommon. im loading a bunch of records from files into a db, and i need to maintain a history of loaded files (modeled using more complicated objects that arent suitable for the StatelessSession). of course all changes to the information must be atomic in order to ensure that a system crash doesnt lead to synchronization problems.

anyways, i hope the topic was useful to someone in the future.

_________________
Ive got a Tomcat that Struts then Springs then Hibernates


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.