EntityManagerFactory (Java EE 5)

Java EE API


javax.persistence Interface EntityManagerFactory


public interface EntityManagerFactory


应用程序使用 EntityManagerFactory 接口获取应用程序管理的实体管理器。使用实体管理器工厂完成应用程序和/或应用程序关闭时,应用程序应该关闭实体管理器工厂。关闭 EntityManagerFactory 后,它的所有实体管理器应该视为处于已关闭状态。
英文文档:

The EntityManagerFactory interface is used by the application to obtain an application-managed entity manager. When the application has finished using the entity manager factory, and/or at application shutdown, the application should close the entity manager factory. Once an EntityManagerFactory has been closed, all its entity managers are considered to be in the closed state.

Since:
Java Persistence 1.0

Method Summary
 void
 EntityManager
 EntityManager
 boolean
 

Method Detail

public EntityManager createEntityManager()
创建新的 EntityManager。每次调用此方法时都返回一个新的 EntityManager 实例。isOpen 方法将对返回的实例返回 true。
英文文档:

createEntityManager

EntityManager createEntityManager()
Create a new EntityManager. This method returns a new EntityManager instance each time it is invoked. The isOpen method will return true on the returned instance.


public EntityManager createEntityManager(java.util.Map<K, V> map)
创建带指定属性 Map 的新 EntityManager。每次调用此方法时都返回一个新的 EntityManager 实例。isOpen 方法将对返回的实例返回 true。
英文文档:

createEntityManager

EntityManager createEntityManager(Map map)
Create a new EntityManager with the specified Map of properties. This method returns a new EntityManager instance each time it is invoked. The isOpen method will return true on the returned instance.


public void close()
关闭工厂,释放它占用的所有资源。关闭工厂实例之后,对其调用的所有方法都将抛出 IllegalStateException(isOpen 除外,它返回 false)。关闭 EntityManagerFactory 后,它的所有实体管理器应该视为处于已关闭状态。
英文文档:

close

void close()
Close the factory, releasing any resources that it holds. After a factory instance is closed, all methods invoked on it will throw an IllegalStateException, except for isOpen, which will return false. Once an EntityManagerFactory has been closed, all its entity managers are considered to be in the closed state.


public boolean isOpen()
指示此工厂是否处于打开状态。在调用 close 之前返回 true。
英文文档:

isOpen

boolean isOpen()
Indicates whether or not this factory is open. Returns true until a call to close has been made.



Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!