Vish
Vish

Reputation: 879

Using interceptor with Hibernate Template

i am trying to inject EmptyInterceptor implementation in the Hibernate Template.But this interceptor is not functioning at runtime. Does there is any other condition that need to fulfilled for interceptor to work like scope of bean whom we are injecting interceptor should be session or something else

 <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
    <property name="sessionFactory">
        <ref bean="sessionFactory" />
    </property>
    <property name="entityInterceptor">
    <ref bean="interceptor"/>
    </property>

problem solved by adding the Interceptor in the sesssion factory class

Upvotes: 1

Views: 1273

Answers (2)

Perky
Perky

Reputation: 47

By using code in HIbernate5

template.getSessionFactory().withOptions()
      .interceptor(interceptor)

Upvotes: 0

Vish
Vish

Reputation: 879

This issue is solved by adding the Interceptor in the sesssion factory class instead of template

Upvotes: 1

Related Questions