-->
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: Session and datasource + JBoss
PostPosted: Sun Aug 31, 2003 1:02 am 
Newbie

Joined: Fri Aug 29, 2003 8:02 pm
Posts: 8
I'm completely ignorant about Hibernate, so please ignore if this is a stupid comment. What is concerning me is this thread right here:

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

IMHO, Session should be creating and closing a connection whenever it is used and, if possible let the TM/Connection manager manage commits and rollbacks. Or maybe you can already do this and the user is just plain using Hibernate+JBoss in the wrong way.

Sorry if I'm not making any sense whatsoever.

Regards,

Bill

_________________
============
Bill Burke
Chief Architect
JBoss Group, LLC
============


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 31, 2003 1:29 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
hmmmmm.


Currently the session keeps hold of the connection until you explicitly close() or disconnect() the session. This makes perfect sense when used in a servlet container, main() method or in a single call to a stateless session bean.


I'm not so sure about the case of re-using the same session accross nested calls to multiple session beans. I've never tried to use Hibernate that way myself....


Certainly we let the container manage commit/rollback ... however, the user must still explicitly flush() the session, either in a beforeCompletion() method of the session bean, or at the end of the business logic.

Tell me what we should be doing.


Top
 Profile  
 
 Post subject: about re-using the same session
PostPosted: Sun Aug 31, 2003 1:44 pm 
Newbie

Joined: Sun Aug 31, 2003 1:19 pm
Posts: 3
hi gavin, there maybe some senses of re-using the same session, in our case (in developing...), there is an business object named Employee, it's have many associated sub objets such as family info , education info etc.
then in Employee.hbm.xml there is something like below:
----------------------------------------------------------------------
<set name="empdept" cascade="all" where ="validto &gt; getCurrentDate()">
<key column="empid"/>
<one-to-many class="com.sophia.hr.domain.EmpDept" />
</set>

<set name="empDuty" cascade="all" where ="validto &gt; getCurrentDate()">
<key column="empid"/>
<one-to-many class="com.sophia.hr.domain.EmpDutyLink"/>
</set>

<set name="empAccountInfo" cascade="all" where ="validto &gt; getCurrentDate()">
<key column="empid"/>
<one-to-many class="com.sophia.hr.domain.EmpAccountInfo"/>
</set>

<set name="empFamilyInfo" cascade="all" where ="validto &gt; getCurrentDate()">
<key column="empid"/>
<one-to-many class="com.sophia.hr.domain.EmpFamilyInfo"/>
</set>
--------------------------------------------------------------------------
so , as you see we used set to map sub objects, then there has a problem, its makes Employee very heavy, and at some times i just
want to get just one or two attributes of Employee,but hibernate get all of its sub classes set to me and make a bad feeling.

so we used "lazy" flag to resolve the problem, and then we found "lazy" doesn't work in multi-sessions, so we used the way below:

Session s = getSession();
beforeAction(Session s)
action(Session s)
afterAction(Session s)
s.close();

and it bring another problem, its dangerous when the actions persist a long time :(

can you give us some tip on it?
thx alot

_________________
you know, programming is art ...


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 31, 2003 7:23 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
In 2.1 you can reassociate an object with a new session using session.lock(transientObject, LockMode.NONE) if you just want to navigate its uninitialized associations.


But that is only tangentially related to what we are discussing here.


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.