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: getCurrentSession() in WebSphere managed environment
PostPosted: Wed Jan 28, 2009 10:25 am 
Newbie

Joined: Wed Jan 28, 2009 9:57 am
Posts: 16
Location: Leinfelden, Germany
Hello,

I am in the process of developing a persistence layer based on Hibernate. I want to use the ThreadLocal capability of Hibernate for obtaining a Session

I have the following properties set in the hibernate.cfg.xml

<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</property>
<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.WebSphereExtendedJTATransactionLookup</property>

<property name="hibernate.transaction.flush_before_completion">true</property>
<property name="hibernate.transaction.auto_close_session">true</property>

The SessionFactory.getCurrentSession() returns a session but when I try to perform an operation on this session, I get a HibernateException with the following message.
"get is not valid without active transaction"

I was under the impression that since I am using a datasource and a managed environment, the transaction would be associated with the Session.

Am I missing a config parameter or is the approach altogether wrong?

This error does not occur when I use SessionFactory.openSession()

Alternatively, I could implement ThreadLocal code myself and set a Session obtained by the SessionFactory.openSession().

Any help would be much appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 20, 2009 7:19 am 
Newbie

Joined: Wed Jan 28, 2009 9:57 am
Posts: 16
Location: Leinfelden, Germany
Well, it was pain to figure out what was wrong. But thanks to my good old friend Martin Sieber, we found the solution. The property "hibernate.current_session_context_class" should not be specified at all.


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.