Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-9020

Hibernate4 version of SpringSessionContext.currentSession() does not create a session if TransactionSynchronizationManager does not contain one

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Complete
    • 3.1 GA
    • 4.1 RC2
    • Core
    • true

    Description

      The Hibernate4 support of Spring 3.1 does not open and register a session in case of the method called is annotated with @Transactional(propagation = Propagation.SUPPORTS).
      In this case HibernateTransactionManager.doBegin() is never called which is the only place where hibernate session is opened. The result is, that all read operations which do not require a transaction will fail because the call to SessionFactory.currentSession() will result in an exception.

      The Hibernate3 implementation contains a fallback for this case in SessionFactoryUtils.doGetSession(...) which is missing in the corresponding Hibernate4 implementation of SpringSessionContext.currentSession().

      If the transaction propagation is changed to REQUIRES_NEW everything is working fine.

      Attachments

        Issue Links

          Activity

            People

              juergen.hoeller Juergen Hoeller
              urferr Reto Urfer
              Spring Issues Spring Issues
              Votes:
              19 Vote for this issue
              Watchers:
              28 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                3 years, 46 weeks ago