PersistenceUnit (Java EE 5)

Java EE API


javax.persistence Annotation Type PersistenceUnit


@Target(value={TYPE,METHOD,FIELD})
@Retention(value=RUNTIME)
public @interface PersistenceUnit

Implements: Annotation
@Target(value={TYPE, METHOD, FIELD})
@Retention(value=RUNTIME)

表示对 EntityManagerFactory 的依赖性。
英文文档:

Expresses a dependency on an EntityManagerFactory.

Since:
Java Persistence 1.0

Optional Element Summary
 String
 String
 

abstract public String name()
在环境引用上下文中访问实体管理器工厂所使用的名称,使用依赖关系注入时不需要此名称。
英文文档:

name

public abstract String name
The name by which the entity manager factory is to be accessed in the environment referencing context, and is not needed when dependency injection is used.

Default:
""

abstract public String unitName()
persistence.xml 文件中定义的持久性单元的名称。如果指定,则可以在 JNDI 中访问的实体管理器工厂的持久性单元必须拥有相同的名称。
英文文档:

unitName

public abstract String unitName
The name of the persistence unit as defined in the persistence.xml file. If specified, the persistence unit for the entity manager factory that is accessible in JNDI must have the same name.

Default:
""


Submit a bug or feature

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

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

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