What are the causes for
javax.persistence.TransactionRequiredException: no transaction is in progress at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:971)
Even after having
-
<tx:annotation-driven/>in applicationContext -
methods annotated with @Transactional
In Spring 3.1.1 + Hibernate 4.1
You must surround calling code with a transaction. In Spring you can use
@Transactionalannotation or AOP transaction demarcation. It’s a very broad topic, start from 11. Transaction Management in official documentation.For starters define JPA transaction manager bean (chances are you already have one), add
<tx:annotation-driven/>and annotate your method with@Transactional.