【发布时间】:2012-07-21 09:38:14
【问题描述】:
我在 WebSphere Application Server 上使用 OpenJPA。 我的 WebApplication 使用 JSF 2(没有 EJB)。
我想知道是否有在 JSF 中使用 JPA 的最佳实践。
我发现 EntityManagerFactory (EMF) 应该是应用程序范围的。 此外,EMF 应该(仅)在应用程序停止时被销毁。
但我的来源不是最新的:
Java Notepad: JPA EMF in web applications 从 2007 年开始
Best way to use JPA in web-tier 从 2010 年开始
How to close a JPA EntityManger in web applications 从 2007 年开始
在 JSF 中是否有其他实践或更好的方法来处理 JPA? 尤其是 EMF 和 DAO 的范围。
最好的问候,投票
【问题讨论】:
-
你使用像 Spring 或 CDI 这样的框架吗?
-
不,我不使用这样的框架。
标签: jsf jpa entitymanager