Spring Framework
  1. Spring Framework
  2. SPR-9987

Cannot create session scoped hibernate interceptors in Hibernate4

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 3.1.2
    • Fix Version/s: Waiting for Triage
    • Component/s: Data:ORM
    • Labels:
      None

      Description

      Hibernate can be attached to the SessionFactory (if they're stateless) or to the Session (see http://docs.jboss.org/hibernate/orm/4.0/manual/en-US/html/events.html)

      In hibernate 3 the way to attach an interceptor to the session is by declaring it at the transaction level:

      <bean id="txManager"
      class="org.springframework.orm.hibernate3.HibernateTransactionManager">
      <property name="sessionFactory" ref="sessionFactory" />
      <property name="entityInterceptor" ref="myInterceptor" />
      </bean>

      However, in class org.springframework.orm.hibernate4.HibernateTransactionManager the entityInterceptor property does not exist, making it impossible to use a state interceptor.

        Activity

        Hide
        Miguel Almeida added a comment - - edited

        The issue is in the following line of code of org.springframework.orm.hibernate4.SessionFactoryUtils

        SessionFactoryUtils
        	public static Session openSession(SessionFactory sessionFactory) {
        		return (Session) ReflectionUtils.invokeMethod(openSessionMethod, sessionFactory);
        }
        

        The problem is that the correct way to create the session-scoped interceptor changed to: sessionFactory.WithOptions.interceptor(someInterceptor).openSession().

        Since the code in the package hibernate3 is different (and doesn't use reflection) I fail to see why reflection is needed here.

        Show
        Miguel Almeida added a comment - - edited The issue is in the following line of code of org.springframework.orm.hibernate4.SessionFactoryUtils SessionFactoryUtils public static Session openSession(SessionFactory sessionFactory) { return (Session) ReflectionUtils.invokeMethod(openSessionMethod, sessionFactory); } The problem is that the correct way to create the session-scoped interceptor changed to: sessionFactory.WithOptions.interceptor(someInterceptor).openSession(). Since the code in the package hibernate3 is different (and doesn't use reflection) I fail to see why reflection is needed here.

          People

          • Assignee:
            Juergen Hoeller
            Reporter:
            Miguel Almeida
            Last updater:
            Chris Beams
          • Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Days since last comment:
              1 year, 22 weeks, 2 days ago