我正在編寫一個在WebSphere Liberty Profile 8.5.5中運行的JEE7應用程序。我們正在使用JPA(通過WLP中的Eclipselink實現)。如何獲得多個持久性單元的EntityManager(s)
我在同一個'persistence.xml'文件中有多個持久單元。我還需要訪問同一班級中的兩個單元。
我得到一個運行時錯誤,當我嘗試使用第二的EntityManager:
@PersistenceContext(unitName = "wwer-list")
private EntityManager entityManagerWwerList;
@PersistenceContext(unitName = "main-dashboard")
private EntityManager entityManagerMainDashboard;
E WTRN0062E: An illegal attempt to use multiple resources that have only one-phase capability has occurred within a global transaction.
如何擺脫這種錯誤的?
此外,我使用的所有表格僅用於閱讀。那麼如何指定我只需要只讀JPA訪問?
我從錯誤消息中獲得了此信息。 http://www-01.ibm.com/support/docview.wss?uid=swg21247192。我的理解是,你需要分佈式事務處理跨兩個持久單元。你可能不得不使用像Bitronix事務管理器這樣的東西來實現 – kjsebastian
你的persistence.xml是什麼樣的? –