Announcement Announcement Module
Collapse
No announcement yet.
How to use a temporary session in Hibernate Interceptor Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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">
    <list>
    <value>org/appfuse/model/Person.hbm.xml</value>
    </list>
    </property>
    <property name="entityInterceptor">
    <ref local="myHibernateInterceptor"/>
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">@HIBERNATE-DIALECT@</prop>
    <prop key="hibernate.show_sql">true</prop>
    </props>
    </property>
    </bean>

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

    Regards,
    Rene Boere

  • #2
    You can configure a new LocalSessionFactory and inject it inside your HibernateInterceptor.
    Take a look at http://forum.springframework.org/showthread.php?t=11488
    HTH
    Last edited by robyn; May 14th, 2006, 04:38 PM.

    Comment

    Working...
    X