66. No EntityManager with actual transaction available for current thread
2017-01-03 15:42
477 查看
【从零开始学习SpirngBoot—常见异常汇总】
具体异常信息:
org.springframework.dao.InvalidDataAccessApiUsageException:
No EntityManager with actual transactionavailable for current thread - cannot reliably process 'persist' call;
nested exception isjavax.persistence.TransactionRequiredException: No EntityManager with actualtransaction available for current thread - cannot reliably process 'persist'call
以上这个异常可能是由于在需要事务的方法上,没有开启事务,结果就操作需要事务的方法比如保存,修改数据库数据方法。
修复方式也特别简单,在需要事务的方法上加入加上注解:@Transactional即可。
具体异常信息:
org.springframework.dao.InvalidDataAccessApiUsageException:
No EntityManager with actual transactionavailable for current thread - cannot reliably process 'persist' call;
nested exception isjavax.persistence.TransactionRequiredException: No EntityManager with actualtransaction available for current thread - cannot reliably process 'persist'call
以上这个异常可能是由于在需要事务的方法上,没有开启事务,结果就操作需要事务的方法比如保存,修改数据库数据方法。
修复方式也特别简单,在需要事务的方法上加入加上注解:@Transactional即可。
相关文章推荐
- Springboot No EntityManager with actual transaction available for current thread
- No EntityManager with actual transaction available for current thread - cannot reliably process 'mer
- No EntityManager with actual transaction available for current thread - cann
- javax.persistence.TransactionRequiredException: No EntityManager with actual transaction available f
- javax.persistence.TransactionRequiredException: No EntityManager with actual transaction available..
- Could not obtain transaction-synchronized Session for current thread
- org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thread
- 关于Hibernate Could not obtain transaction-synchronized Session for current thread
- ssh整合 出现Could not obtain transaction-synchronized Session for current thread
- Could not open JPA EntityManager for transaction; nested exception is javax.pers
- Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread原因及解决方案
- HibernateException: Could not obtain transaction-synchronized Session for current thread
- 事务配置不对导致:•Could not obtain transaction-synchronized Session for current thread
- SSH整合时出现Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- Struts Problem Report :Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- Could not obtain transaction-synchronized Session for current thread
- Could not open JPA EntityManager for transaction; nested exception is java.lang.NullPointerException