jparesourcebean.java
来自「用JAVA编写的EJB」· Java 代码 · 共 28 行
JAVA
28 行
package oracle.toplink.jpa.example.inventory.services.impl;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
/**
* This is an Application Scoped bean that holds the JPA
* EntityManagerFactory. By making this bean Applciation scoped the
* EntityManagerFactory resource will be created only once for the application
* and cached here.
*
*@author Gordon Yorke
*/
public class JPAResourceBean {
protected EntityManagerFactory emf;
/*
* Lazily acquire the EntityManagerFactory and cache it.
*/
public EntityManagerFactory getEMF (){
if (emf == null){
emf = Persistence.createEntityManagerFactory("default", new java.util.HashMap());
}
return emf;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?