Announcement Announcement Module
No announcement yet.
How to use a temporary session in Hibernate Interceptor Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to use a temporary session in Hibernate Interceptor

    In the hibernate documentation is explained that it is not allowed to use the original hibernate session within an interceptor callback.
    This means that i should have access to the Sessionfactory within my Interceptor.

    The problem is that the interceptor is a property of the Sessionfactory in the ApplicationContext.
    How can i provide the SessionFactory to the Interceptor? Or is there another way to create a temporary session based on the current connection?

    <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
    <property name="dataSource"><ref bean="dataSource"/></property>
    <property name="mappingResources">
    <property name="entityInterceptor">
    <ref local="myHibernateInterceptor"/>
    <property name="hibernateProperties">
    <prop key="hibernate.dialect">@HIBERNATE-DIALECT@</prop>
    <prop key="hibernate.show_sql">true</prop>

    <bean id="myHibernateInterceptor" class="org.appfuse.MyInterceptor">

    Rene Boere

  • #2
    You can configure a new LocalSessionFactory and inject it inside your HibernateInterceptor.
    Take a look at
    Last edited by robyn; May 14th, 2006, 05:38 PM.