org.hibernate.HibernateException: save is not valid without active transaction

Posted by

This issue had caused me lots of troubles in my projects. Finally I have found out the main reason is that in spring application context within session factory definition you need to remove hibernate.current_session_context_class entry the below is full code

Projects tested Spring 3 Hibernate 3 and 4

<!– Hibernate configuration settings –>
<bean id=”sessionFactory”
class=”org.springframework.orm.hibernate4.LocalSessionFactoryBean”>
<property name=”dataSource” ref=”dataSource” />
<property name=”packagesToScan” value=”com.tugrulaslan.domain” />
<property name=”hibernateProperties”>
<props>
<prop key=”hibernate.dialect”>${orm.dialect}</prop>
<prop key=”hibernate.pool_size”>”${orm.pool_size}</prop>
<prop key=”hibernate.show_sql”>${orm.show_sql}</prop>
<prop key=”hibernate.hbm2ddl.auto”>${orm.hbm2ddl.auto}</prop>
</props>
</property>
</bean>

Leave a Reply

Your email address will not be published. Required fields are marked *