-->
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.  [ 1 post ] 
Author Message
 Post subject: creating interceptor at session level using JTA
PostPosted: Fri Feb 24, 2006 12:10 am 
Newbie

Joined: Thu Sep 15, 2005 6:53 am
Posts: 7
Issue
In managed environment how to create interceptor for each session. in an un-managed environment, SF.openSession(interceptor) is available. But in managed environment using CMT , sesison is taken using SF.getCurrentSession() method. how to specify interceptor in this case.

there is option to specify interceptor at sesison factory level using new Configuration.configure(" ").setInterceptor(interceptor).buildSessionFactory() . but for audit need to create new instance of interceptor for each sesison. In interceptor value for each transaction lile userId, code etc need to be set. these values will be used in interceptor call back methods.
Is there a way out.

Hibernate version: 3.0.5

Mapping documents:
<property name="hibernate.session_factory_name">HibernateSessionFactory</property>
<property name="connection.datasource">jdbc/p4fDB</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="show_sql">true</property>
<property name="transaction.manager_lookup_class">org.hibernate.transaction.SunONETransactionManagerLookup</property>
<property name="transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</property>
<property name="hibernate.cglib.use_reflection_optimizer">false</property>

Code :
public static Session getSession(String jndiName, Interceptor interceptor){
Session session = null;
SessionFactory sessionFactory = getSessionFactory(jndiName);
if(sessionFactory != null){
// this code doesn't work properly. like for saving an entity, session.save() persist but session.saveOrupdate() doesn't. also not sure if this session is aware of JTA
session = sessionFactory.openSession(interceptor);
}
return session;
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.