Getting error java.lang.IllegalStateException: No transactional EntityManager available

huangapple 未分类评论76阅读模式
英文:

Getting error java.lang.IllegalStateException: No transactional EntityManager available

问题

我甚至在使用 @Transactional 进行标记时仍然遇到了这个错误:

@Service
@EnableConfigurationProperties
@Transactional
public class Test{

    protected void getAAA() {
        List<X> list = getxxx();
    }

    @SuppressWarnings("unchecked")
    @Transactional
    public List getxxx(){

        Session session = entityManager.unwrap(Session.class);
        NativeQuery query = session.createNativeQuery("select * from table");

    }
}

错误信息:Caused by: java.lang.IllegalStateException: 没有可用的事务性 EntityManager。

英文:

I am getting this error even when I have Tagged it with @Transactional:

@Service
@EnableConfigurationProperties
@Transactional
Public class Test{
 
   
   protected void getAAA() {
      List&lt;X&gt; list = getxxx();
   }
   
    @SuppressWarnings(&quot;unchecked&quot;)
    @Transactional
   public List getxxx(){
   
     Session session = entityManager.unwrap(Session.class);
        NativeQuery query = session.createNativeQuery(&quot;select * from table&quot;);
		
		}
}

Error:Caused by: java.lang.IllegalStateException: No transactional EntityManager available

huangapple
  • 本文由 发表于 2020年8月14日 18:54:09
  • 转载请务必保留本文链接:https://java.coder-hub.com/63411401.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定