-->
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.  [ 5 posts ] 
Author Message
 Post subject: j2ee/threadlocal questions
PostPosted: Tue Jul 06, 2004 6:50 am 
Newbie

Joined: Tue Jul 06, 2004 6:17 am
Posts: 5
Hi,
I am just investigating the use of Hibernate with EJBs (stateless session only.) The threadlocal pattern looks like the definitive technique to use to grab the appropriate hibernate session (am i correct?!) I was just hoping that a few of you experienced users could help me clarify a few things:

1. I still want to use container declarative transactions in my stateless session beans as per usual - am I right in assuming I can do this? In which case, I guess I don't need to call the session.beginTransaction() etc, right? So is it really as simple as just grabbing the session from my HibernateSessionUtil helper when needed and calling the (eg) save method for my object?

2. I guess I simply close the session at the end of my transacion in the stateless session bean, with nothing more to do than that? (ie no commit as it's container-handled)

3. Does all still work fine with nested EJB calls?

If there's any good documentation out there as to setting this kinda thing up (I'm sure loads of people must need to do it!) please feel free to drop a few URLs into a reply!

thanks loads!
mike


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 06, 2004 7:03 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
1. using the Transaction API is optional if you use CMT
2. Yes, but you have to manually do session.flush()
3. No rpoblem, as long as it is inside of one thread.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 06, 2004 7:22 am 
Newbie

Joined: Tue Jul 06, 2004 6:17 am
Posts: 5
thanks for the quick reply!

re: 3, under what circumstances would a nested EJB call not be within the same thread and cause problems?

also, would the sample HibernateUtil helper class included in the reference guide be adequate for a J2EE implementation as described? (I have seen various more complex implementations for a J2EE implementation but am not sure if they're necessary)

thanks again


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 16, 2004 4:43 am 
Newbie

Joined: Sat May 29, 2004 2:32 am
Posts: 8
Which Application Server do you use?
I use Weblogic Application Server and ThreadLocal does not work with it.

Could you please send your ThreadLocal implementation to me? I just want to check if I've made mistake in my work.

Regards,
Amin Emami


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 16, 2004 6:56 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
It must work in the same way as method parameter for local beans, it is designed to emulate method parameter (JVM allocates stack for parameters and local variables per thread too).
Stateful bean can be used to propagate remote transactions, but you need to create bean per thead on client (it can be assigned to threadlocal too).


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