No transaction in progress exception with Spring 3.1 and JPA 2

不问归期 提交于 2019-12-05 17:20:35
@Transactional(propagation=Propagation.MANDATORY)

Quoting Spring JavaDoc on MANDATORY:

Support a current transaction, throw an exception if none exists. Analogous to EJB transaction attribute of the same name.

Just change it to:

@Transactional

to use default (REQUIRED) propagation. Alternatively call AccountDaoJpaImpl.createUser() from external transaction, e.g. wrap AccountServiceImpl.createUser() with @Transactional (with default propagation).

I actually found out what the issues were. First a proxy was not getting wrapped around my object. So no transaction was ever getting started. Once I added aspectj to my transaction manager declaration I started getting a different error.

That turned out to be that my pointcut was not defined right.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!