Results 1 to 2 of 2

Thread: @Transactional not flushing through a Hibernate session

  1. #1

    Default @Transactional not flushing through a Hibernate session

    Hi,

    I'm sure this has been encountered several times before, but unfortunately I haven't been able to locate the solution in this forum.

    My context contains the following:

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="mappingResources">
    <list>
    <value>hbm.xml</value>
    </list>
    </property>
    <property name="hibernateProperties">
    <value>
    hibernate.dialect=org.hibernate.dialect.Oracle10gD ialect
    </value>
    </property>
    </bean>

    <bean id="transactionManager" class="org.springframework.orm.hibernate3.Hibernat eTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"/>
    </bean>

    <tx:annotation-driven transaction-manager="transactionManager"/>

    And the method that is called is as follows:

    @Transactional
    public void save(T t) {
    Session session = sessionFactory.openSession();
    session.save(t);
    }

    After my annotated method returns, a previously unsaved "t" now contains the proper ID, but the changes are never flushed through. I don't believe the transaction is ever committed. What could be the causes of this?

    Thanks!

  2. #2
    Join Date
    Apr 2008
    Location
    Seville, Spain
    Posts
    133

    Default

    Change sessionFactory.openSession() to sessionFactory.getCurrentSession()
    Jose Luis Martin
    Freelance Senior Consultant
    JDAL - Java Database Application Library

Tags for this Thread

Posting Permissions

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