PDA

View Full Version : About getting session with entityInterceptor



borko
Aug 17th, 2004, 08:57 AM
Hi,

When I use HibernateTransactionManager I get session without entityInterceptor,
no entityInteceptor on HibernateTransactionManager or SessionFactory.

Calls in my DAO class (which is subclass of HibrenateDaoSupport) use hibernateTemplate
with enitityInreceptor(session level Interceptors), but session is unaware of that interceptor.


HibernateTempalte ht = getHibernateTemplate();
ht.setEntityInterceptor(auditLogInterceptor);
ht.saveOrUpdate(jci);

I presume that calls are on session (provided by TM), and
any hibernateTemplate calls in transaction will use this session.

Is there any possibility to "turn on" (or off, if configured) entityInterceptor on this session?

Colin Sampaleanu
Aug 17th, 2004, 12:31 PM
If you use HibernateTransactionManager (or alternately, JTATransactionManager+HibernateInterceptor), the Session will have already been created and bound to the thread, synchronized to the tx.

So the entity interceptor setting at the level of the template will be ignored, as no new session is created there.

If you have a need for a non-stateful entity interceptor, set it as the EntityInterceptor property of HibernateTransactionManager. If you have a need for a stateful entity interceptor, you can set a prototype entity interceptor to be used, with the new EntityInterceptorBeanName property in Spring 1.1RC1+.

Regards,

eovidiu
Feb 22nd, 2006, 06:36 AM
Hi Colin,
I'm facing the same problem here .
Can you provide a small snippet of configuration for both scenarios ?

Thanx