Announcement Announcement Module
Collapse
No announcement yet.
About getting session with entityInterceptor Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • About getting session with entityInterceptor

    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.
    Code:
      
         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?

  • #2
    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,

    Comment


    • #3
      Hi Colin,
      I'm facing the same problem here .
      Can you provide a small snippet of configuration for both scenarios ?

      Thanx

      Comment

      Working...
      X