-->
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: SFSB > SessionFactory > DAO
PostPosted: Thu Jul 08, 2004 12:10 am 
Newbie

Joined: Tue Jun 29, 2004 5:04 am
Posts: 8
Hi All!

I have written a POJO, and a DAO for every POJO.

I access the DAO from a StateFul Session Bean(SFSB).

Code:
e.g.
======
Session mySession = SessionFactory.getSession();
DepartmentDAO deptDAO = new DepartmentDAO( mySession );
EmployeeDAO empDAO = new EmployeeDAO( mySession );

Transaction transaction = mySession.beginTransaction();
try
{
empDAO.saveEmployee( new Employee(...) );
deptDAO.save( new Department(...) );
transaction.commit()
}
catch( DAOException exc )
{
transaction.rollback();
}
======

Now, when I do the above from a method in a SFSB, do I need to worry about ThreadLocal session.

Also, what happens, when I define the session as an instance variable, instead of a method variable ?


TIA,

Kunal


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 12, 2004 1:27 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I don't know what SessionFactory does but if you open and close the session explicitly in the SFSB then, no problem. The Thread local session pattern is not that useful in a type-3 IoC pattern (constuctor use).

An instance variable:
The session ahs to be opened AND closed properly, this is important

_________________
Emmanuel


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.