I an using Spring 3.1 + Hibernate 4.x in my web application. In my DAO, i am saving User type object as following
sessionFactory.getCurren
Using your working version of the Spring XML, and the @Transactional annotated DAO class, are you defining the DAO in your Spring XML ? (Perhaps as a prototype) Because if you're not, then so far as I can see, your DAO is not going to be AOP'ed for transactional aspects. I think that's the easiest way. This example is from the Spring 3 Doc, section 10.5.6 Using @Transactional.
<!-- this is the service object that we want to make transactional -->
<bean id="fooService" class="x.y.service.DefaultFooService"/>
<!-- enable the configuration of transactional behavior based on annotations -->
<tx:annotation-driven transaction-manager="txManager"/>
...where you might substitute DefaultFooService for your DAO.
i think you are using Hibernate 4.x then why you are using hibernate 3 transaction manager in application context file?
<bean id="txManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
i think it should be
<bean id="txManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
just try to use hibernate 4 transaction manager along with @Transactional attribute it should work.
Basically what needs to be done is to remove from the applicationContext.xml file the following line for Hibernate properties:
<prop key="hibernate.current_session_context_class">thread</prop>
Once that is remove, Hibernate makes use of Spring for transaction management
Good luck to you all.