Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.8, 2.0 RC3
    • Fix Version/s: General Backlog
    • Component/s: Data
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      Hello,

      since Hibernate 3.1 has a 'StatelessSession' class to use for batch jobs (bulk inserts / updates), it wourld be nice, if a helper class like 'HibernateDaoSupport' could support that new feature.

      best regards,
      Wolf-Dieter Angerer

        Activity

        Hide
        Juergen Hoeller added a comment -

        I'll add documentation on how to use Hibernate's StatelessSession API to Spring's documentation: using the StatelessSession API via the native Hibernate SessionFactory, but integrating with Spring's transaction management.

        Further potential for explicit support to be explored for Spring 3.0.

        Juergen

        Show
        Juergen Hoeller added a comment - I'll add documentation on how to use Hibernate's StatelessSession API to Spring's documentation: using the StatelessSession API via the native Hibernate SessionFactory, but integrating with Spring's transaction management. Further potential for explicit support to be explored for Spring 3.0. Juergen
        Hide
        Josh Moore added a comment -

        +1 Am currently running into this in 2.5.x with JTA issues:

        [CODE]
        2009-01-02 20:51:32,160 WARN [ bitronix.tm.BitronixTransaction] ( main) Synchronization.beforeCompletion() call failed for org.hibernate.transaction.CacheSynchronization, marking transaction as rollback only
        org.hibernate.SessionException: Session is closed!
        at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:49)
        at org.hibernate.impl.StatelessSessionImpl.managedFlush(StatelessSessionImpl.java:300)
        at org.hibernate.transaction.CacheSynchronization.beforeCompletion(CacheSynchronization.java:59)
        at bitronix.tm.BitronixTransaction.fireBeforeCompletionEvent(BitronixTransaction.java:372)
        at bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:146)
        at bitronix.tm.BitronixTransactionManager.commit(BitronixTransactionManager.java:96)
        at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:1028)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:709)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:678)
        at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)
        at ome.services.util.Executor$Impl.executeStateless(Executor.java:234)
        [/CODE]

        and unfortunately StatelessSession shares no common interface with Session for dealing with deferred closes (as noted elsewhere).

        For anyone who may update this ticket, the following forum entries are all looking for the same thing:

        and

        Show
        Josh Moore added a comment - +1 Am currently running into this in 2.5.x with JTA issues: [CODE] 2009-01-02 20:51:32,160 WARN [ bitronix.tm.BitronixTransaction] ( main) Synchronization.beforeCompletion() call failed for org.hibernate.transaction.CacheSynchronization, marking transaction as rollback only org.hibernate.SessionException: Session is closed! at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:49) at org.hibernate.impl.StatelessSessionImpl.managedFlush(StatelessSessionImpl.java:300) at org.hibernate.transaction.CacheSynchronization.beforeCompletion(CacheSynchronization.java:59) at bitronix.tm.BitronixTransaction.fireBeforeCompletionEvent(BitronixTransaction.java:372) at bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:146) at bitronix.tm.BitronixTransactionManager.commit(BitronixTransactionManager.java:96) at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:1028) at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:709) at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:678) at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140) at ome.services.util.Executor$Impl.executeStateless(Executor.java:234) [/CODE] and unfortunately StatelessSession shares no common interface with Session for dealing with deferred closes (as noted elsewhere). For anyone who may update this ticket, the following forum entries are all looking for the same thing: http://forum.springframework.org/showthread.php?t=32028 http://forum.springframework.org/showthread.php?t=49650 http://forum.springframework.org/showthread.php?t=58229 http://forum.springframework.org/showthread.php?t=53764 http://forum.springframework.org/showthread.php?t=62835 and http://jira.springframework.org/browse/SPR-2899
        Hide
        Morten Andersen-Gott added a comment -

        Can't find the documentation that was supposed to be added according to Juergen's comments. Might be me that's unable to locate it though. Would be nice to have a way of managing the StatelessSession in the same way as the Session (closing session automatically etc).

        Show
        Morten Andersen-Gott added a comment - Can't find the documentation that was supposed to be added according to Juergen's comments. Might be me that's unable to locate it though. Would be nice to have a way of managing the StatelessSession in the same way as the Session (closing session automatically etc).
        Hide
        Andrew Goode added a comment -

        See SPR-6202 for proposed patch introducing callback template for StatelessSessions. Perhaps the community could help refine the implementation to make it more robust.

        Show
        Andrew Goode added a comment - See SPR-6202 for proposed patch introducing callback template for StatelessSessions. Perhaps the community could help refine the implementation to make it more robust.
        Hide
        Willem Dekker added a comment -

        For my current project we needed to use the StatelessSession to achieve better performance. I have build some framework code so we are able to use the StatelessSession together with a (Stateful) HibernateEntityManager and let it join the same transaction. This works more or less the same as how you can mix an EntityManager together with the JdbcTemplate (use the same connection).

        Since there are many requests on the web for this kind of behavior I would like to give our solution to the community in the hope you could benefit from it. The code is attached to this issue and is tested using spring 3.2.0.RELEASE and hibernate 4.1.9.Final.
        To use this just add the bean to your existing context configuration:

        <bean class="com.acme.spring.data.support.hibernate.StatelessSessionFactoryBean" />

        And @AutoWired the StatelessSession in you DAO's:

        @AutoWired private StatelessSession statelessSession;

        Please note that this code will only work with the JpaTransactionManager and (of-course) Hibernate as the Jpa implementation. It also doesn't support suspending of transactions (i.e.: PROPAGATION_REQUIRES_NEW, PROPAGATION_NOT_SUPPORTED).

        Show
        Willem Dekker added a comment - For my current project we needed to use the StatelessSession to achieve better performance. I have build some framework code so we are able to use the StatelessSession together with a (Stateful) HibernateEntityManager and let it join the same transaction. This works more or less the same as how you can mix an EntityManager together with the JdbcTemplate (use the same connection). Since there are many requests on the web for this kind of behavior I would like to give our solution to the community in the hope you could benefit from it. The code is attached to this issue and is tested using spring 3.2.0.RELEASE and hibernate 4.1.9.Final . To use this just add the bean to your existing context configuration: <bean class= "com.acme.spring.data.support.hibernate.StatelessSessionFactoryBean" /> And @AutoWired the StatelessSession in you DAO's: @AutoWired private StatelessSession statelessSession; Please note that this code will only work with the JpaTransactionManager and (of-course) Hibernate as the Jpa implementation. It also doesn't support suspending of transactions (i.e.: PROPAGATION_REQUIRES_NEW, PROPAGATION_NOT_SUPPORTED).

          People

          • Assignee:
            Juergen Hoeller
            Reporter:
            WDA
            Last updater:
            Juergen Hoeller
          • Votes:
            18 Vote for this issue
            Watchers:
            19 Start watching this issue

            Dates

            • Created:
              Updated:
              Days since last comment:
              1 year, 13 weeks, 3 days ago