PersistenceUnitInfo (Java EE 5)

Java EE API


javax.persistence.spi Interface PersistenceUnitInfo


public interface PersistenceUnitInfo


容器实现的接口,持久性提供者在创建 javax.persistence.EntityManagerFactory 时使用此接口。
英文文档:

Interface implemented by the container and used by the persistence provider when creating an EntityManagerFactory.

Since:
Java Persistence 1.0

Method Summary
 void
 boolean
 ClassLoader
 List<URL>
 DataSource
 List<String>
 List<String>
 ClassLoader
 DataSource
 String
 String
 URL
 Properties
 PersistenceUnitTransactionType
 

Method Detail

public String getPersistenceUnitName()
返回持久性单元的名称。对应于 persistence.xml 文件中的名称属性。
return 持久性单元的名称。对应于 persistence.xml 文件中的名称属性。
英文文档:

getPersistenceUnitName

String getPersistenceUnitName()
Returns the name of the persistence unit. Corresponds to the name attribute in the persistence.xml file.

Returns:
The name of the persistence unit. Corresponds to the name attribute in the persistence.xml file.

public String getPersistenceProviderClassName()
返回持久性提供者实现类的完全限定名称。对应于 persistence.xml 文件中的 <provider> 元素。
return 持久性提供者实现类的完全限定名称。对应于 persistence.xml 文件中的 <provider> 元素。
英文文档:

getPersistenceProviderClassName

String getPersistenceProviderClassName()
Returns the fully qualified name of the persistence provider implementation class. Corresponds to the <provider> element in the persistence.xml file.

Returns:
The fully qualified name of the persistence provider implementation class. Corresponds to the <provider> element in the persistence.xml file.

public PersistenceUnitTransactionType getTransactionType()
返回 EntityManagerFactory 创建的实体管理器的事务类型。事务类型对应于 persistence.xml 文件中的事务类型属性。
return EntityManagerFactory 创建的实体管理器的事务类型。事务类型对应于 persistence.xml 文件中的事务类型属性。
英文文档:

getTransactionType

PersistenceUnitTransactionType getTransactionType()
Returns the transaction type of the entity managers created by the EntityManagerFactory. The transaction type corresponds to the transaction-type attribute in the persistence.xml file.

Returns:
The transaction type of the entity managers created by the EntityManagerFactory. The transaction type corresponds to the transaction-type attribute in the persistence.xml file.

public javax.sql.DataSource getJtaDataSource()
返回持久性提供者要使用的支持 JTA 的数据源。数据源对应于 persistence.xml 文件中的 <jta-data-source> 元素,或者在部署时提供,也可能由容器提供。
return 持久性提供者要使用的支持 JTA 的数据源。数据源对应于 persistence.xml 文件中的 <jta-data-source> 元素,或者在部署时提供,也可能由容器提供。
英文文档:

getJtaDataSource

DataSource getJtaDataSource()
Returns the JTA-enabled data source to be used by the persistence provider. The data source corresponds to the <jta-data-source> element in the persistence.xml file or is provided at deployment or by the container.

Returns:
the JTA-enabled data source to be used by the persistence provider. The data source corresponds to the <jta-data-source> element in the persistence.xml file or is provided at deployment or by the container.

public javax.sql.DataSource getNonJtaDataSource()
返回持久性提供者要使用的不支持 JTA 的数据源。数据源对应于 persistence.xml 文件中的 <non-jta-data-source> 元素,或者在部署时提供,也可能由容器提供。
return 持久性提供者要使用的不支持 JTA 的数据源。数据源对应于 persistence.xml 文件中的 <non-jta-data-source> 元素,或者在部署时提供,也可能由容器提供。
英文文档:

getNonJtaDataSource

DataSource getNonJtaDataSource()
Returns the non-JTA-enabled data source to be used by the persistence provider for accessing data outside a JTA transaction. The data source corresponds to the named <non-jta-data-source> element in the persistence.xml file or provided at deployment or by the container.

Returns:
The non-JTA-enabled data source to be used by the persistence provider for accessing data outside a JTA transaction. The data source corresponds to the named <non-jta-data-source> element in the persistence.xml file or provided at deployment or by the container.

public java.util.List<E> getMappingFileNames()
返回持久性提供者必须加载以确定实体类映射的映射文件名称列表。映射文件必须是标准的 XML 映射格式,是惟一指定的,并且可通过应用程序类路径加载资源。如果没有指定,则此列表将不会包含在 orm.xml 文件中。每个映射文件名都对应于 persistence.xml 文件中的 <mapping-file> 元素。
return 持久性提供者必须加载以确定实体类映射的映射文件名称列表。映射文件必须是标准的 XML 映射格式,是惟一指定的,并且可通过应用程序类路径加载资源。如果没有指定,则此列表将不会包含在 orm.xml 文件中。每个映射文件名都对应于 persistence.xml 文件中的 <mapping-file> 元素。
英文文档:

getMappingFileNames

List<String> getMappingFileNames()
Returns the list of mapping file names that the persistence provider must load to determine the mappings for the entity classes. The mapping files must be in the standard XML mapping format, be uniquely named and be resource-loadable from the application classpath. This list will not include the orm.xml file if one was specified. Each mapping file name corresponds to a <mapping-file> element in the persistence.xml file.

Returns:
The list of mapping file names that the persistence provider must load to determine the mappings for the entity classes. The mapping files must be in the standard XML mapping format, be uniquely named and be resource-loadable from the application classpath. This list will not include the orm.xml file if one was specified. Each mapping file name corresponds to a <mapping-file> element in the persistence.xml file.

public java.util.List<E> getJarFileUrls()
返回 jar 文件或解压 jar 文件目录的 URL 列表,持久性提供者必须在这些文件(或目录)中寻找持久性单元的管理类。每个 URL 对应于 persistence.xml 文件中指定的 元素。URL 可以是引用 jar 文件或包含解压 jar 文件的目录的 file:URL,也可以是可从中获取 jar 格式的 InputStream 的 URL。
return 引用 jar 文件或目录的 URL 对象列表。
英文文档:

getJarFileUrls

List<URL> getJarFileUrls()
Returns a list of URLs for the jar files or exploded jar file directories that the persistence provider must examine for managed classes of the persistence unit. Each URL corresponds to a named element in the persistence.xml file. A URL will either be a file: URL referring to a jar file or referring to a directory that contains an exploded jar file, or some other URL from which an InputStream in jar format can be obtained.

Returns:
a list of URL objects referring to jar files or directories.

public java.net.URL getPersistenceUnitRootUrl()
返回作为持久性单元的根 jar 文件或根目录的 URL。(如果持久性单元以 WEB-INF/classes 目录为根,则返回该目录的 URL。)URL 可以是引用 jar 文件或包含解压 jar 文件的目录的 file:URL,也可以是可从中获取 jar 格式的 InputStream 的 URL。
return 引用 jar 文件或目录的 URL。
英文文档:

getPersistenceUnitRootUrl

URL getPersistenceUnitRootUrl()
Returns the URL for the jar file or directory that is the root of the persistence unit. (If the persistence unit is rooted in the WEB-INF/classes directory, this will be the URL of that directory.) The URL will either be a file: URL referring to a jar file or referring to a directory that contains an exploded jar file, or some other URL from which an InputStream in jar format can be obtained.

Returns:
a URL referring to a jar file or directory.

public java.util.List<E> getManagedClassNames()
返回类名称列表,持久性提供者必须将该列表中的类添加到其管理类集合。每个名称对应于 persistence.xml 文件中指定的 <class> 元素。
return 类名称列表,持久性提供者必须将该列表中的类添加到其管理类集合。每个名称对应于 persistence.xml 文件中指定的 <class> 元素。
英文文档:

getManagedClassNames

List<String> getManagedClassNames()
Returns the list of the names of the classes that the persistence provider must add it to its set of managed classes. Each name corresponds to a named <class> element in the persistence.xml file.

Returns:
The list of the names of the classes that the persistence provider must add it to its set of managed classes. Each name corresponds to a named <class> element in the persistence.xml file.

public boolean excludeUnlistedClasses()
返回管理类集合中是否要包含持久性单元的根中没有显式列出的类。此值对应于 persistence.xml 文件中的 <exclude-unlisted-classes> 元素。
return 管理类集合中是否要包含持久性单元的根中没有显式列出的类。此值对应于 persistence.xml 文件中的 <exclude-unlisted-classes> 元素。
英文文档:

excludeUnlistedClasses

boolean excludeUnlistedClasses()
Returns whether classes in the root of the persistence unit that have not been explicitly listed are to be included in the set of managed classes. This value corresponds to the <exclude-unlisted-classes> element in the persistence.xml file.

Returns:
Whether classes in the root of the persistence unit that have not been explicitly listed are to be included in the set of managed classes. This value corresponds to the <exclude-unlisted-classes> element in the persistence.xml file.

public java.util.Properties getProperties()
返回属性对象。每个属性对应于 persistence.xml 文件中的一个 <property> 元素
return 属性对象。每个属性对应于 persistence.xml 文件中一个 <property> 元素
英文文档:

getProperties

Properties getProperties()
Returns properties object. Each property corresponds to a <property> element in the persistence.xml file

Returns:
Properties object. Each property corresponds to a <property> element in the persistence.xml file

public ClassLoader getClassLoader()
返回提供者可以用来加载任何类、资源或开放 URL 的 ClassLoader。
return 提供者可以用来加载任何类、资源或开放 URL 的 ClassLoader。
英文文档:

getClassLoader

ClassLoader getClassLoader()
Returns ClassLoader that the provider may use to load any classes, resources, or open URLs.

Returns:
ClassLoader that the provider may use to load any classes, resources, or open URLs.

public void addTransformer(ClassTransformer transformer)
添加提供者供应的转换器,PersistenceUnitInfo#getClassLoader 方法所返回的加载器加载的每个新类定义或类重定义都将调用此转换器。此转换器对 PersistenceUnitInfo#getNewTempClassLoader 方法返回的结果无效。在同一个类加载作用域内,不管有多少个持久性单元包含此类,它都仅转换一次。
transformer Container 在类定义(重定义)时调用的提供者供应的转换器
英文文档:

addTransformer

void addTransformer(ClassTransformer transformer)
Add a transformer supplied by the provider that will be called for every new class definition or class redefinition that gets loaded by the loader returned by the getClassLoader() method. The transformer has no effect on the result returned by the getNewTempClassLoader() method. Classes are only transformed once within the same classloading scope, regardless of how many persistence units they may be a part of.

Parameters:
transformer - A provider-supplied transformer that the Container invokes at class-(re)definition time

public ClassLoader getNewTempClassLoader()
返回提供者可以用来临时加载任何类、资源或开放 URL 的 ClassLoader 新实例。此加载器的作用域和类路径与 PersistenceUnitInfo#getClassLoader 返回的加载器的作用域和类路径完全相同。此类加载器加载的任何类对于应用程序组件都不可见。提供者只能在 PersistenceProvider#createContainerEntityManagerFactory 调用的作用域内使用此 ClassLoader。
return 与当前加载器具有相同可见性的临时 ClassLoader
英文文档:

getNewTempClassLoader

ClassLoader getNewTempClassLoader()
Return a new instance of a ClassLoader that the provider may use to temporarily load any classes, resources, or open URLs. The scope and classpath of this loader is exactly the same as that of the loader returned by getClassLoader(). None of the classes loaded by this class loader will be visible to application components. The provider may only use this ClassLoader within the scope of the PersistenceProvider.createContainerEntityManagerFactory(javax.persistence.spi.PersistenceUnitInfo, java.util.Map) call.

Returns:
Temporary ClassLoader with same visibility as current loader


Submit a bug or feature

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

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

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