I am getting below exception when running a groovy testcase. I use hibernate 5.4.14 and Spring version 4.3
javax.persistence.TransactionRequiredException: Executing an update/delete query at org.hibernate.internal.AbstractSharedSessionContract.checkTransactionNeededForUpdateOperation(AbstractSharedSessionContract.java:413) at org.hibernate.query.internal.AbstractProducedQuery.executeUpdate(AbstractProducedQuery.java:1608) at com.test.portal.example.service.CleanDataSpecification.cleanup(CleanDataSpecification.groovy:35)
Here is the transactionManager Configuration
<tx:annotation-driven transaction-manager=“exampleTM” />
<bean id="exampleSF"
class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<qualifier value="example"/>
<property name="dataSource" ref="exampleDS"/>
<property name="hibernateProperties">
<props>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.H2Dialect</prop>
<!--<prop key="hibernate.current_session_context_class">thread</prop>-->
<prop key="jadira.usertype.autoRegisterUserTypes">true</prop>
<prop key="hibernate.hbm2ddl.auto">create-drop</prop>
<prop key="hibernate.cache.region.factory_class">
org.hibernate.cache.ehcache.EhCacheRegionFactory
</prop>
<prop key="hibernate.cache.use_second_level_cache">false</prop>
<prop key="hibernate.cache.use_query_cache">false</prop>
<prop key="net.sf.ehcache.configurationResourceName">hibernate/example-ehcache.xml</prop>
</props>
</property>
<property name="packagesToScan">
<value>com.test.portal.example.model</value>
</property>
</bean>
<bean id="exampleTM"
class =
"org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="exampleSF"/>
<qualifier value="example"/>
</bean>