Cannot inject RESOURCE_LOCAL container managed EntityManager using @PersistenceContext

前端 未结 1 1505
抹茶落季
抹茶落季 2020-12-16 01:06

I am using JBoss AS 7.1.1 and able to configure a new JTA datasource and wire it to my EJB using

@PersistenceContext(unitName=\"TestPU\")
private EntityMana         


        
相关标签:
1条回答
  • 2020-12-16 02:07

    JTA : In Java EE environment, transactions are managed by the container & by default its JTA transaction. You can get entity manager by lookup or injection.

    RESOURCE_LOCAL : In Java SE, application have to manage transactions explicitly & resource local transactions are native transactions. You have to create EntityManagerFactory & then can create entity manager from it.

    As you are deploying it in application server, change the transaction-type to JTA in persistence.xml.

    0 讨论(0)
提交回复
热议问题