Results 1 to 2 of 2

Thread: How to use a temporary session in Hibernate Interceptor

  1. #1
    Join Date
    Nov 2004
    Posts
    6

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    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 at 04:38 PM.
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

Similar Threads

  1. OpenSessionInView and portlet support
    By garpinc2 in forum Web Flow
    Replies: 31
    Last Post: Apr 9th, 2010, 11:12 AM
  2. Loosing my SecureContext
    By sklakken in forum Security
    Replies: 3
    Last Post: Jul 21st, 2005, 01:44 PM
  3. Replies: 3
    Last Post: May 16th, 2005, 07:04 AM
  4. Replies: 3
    Last Post: Nov 19th, 2004, 07:16 PM
  5. Replies: 9
    Last Post: Sep 25th, 2004, 12:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •