PersistenceContext (Java EE 5)

Java EE API


javax.persistence Annotation Type PersistenceContext


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

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

表示对 EntityManager 持久性上下文的依赖性。
英文文档:

Expresses a dependency on an EntityManager persistence context.

Since:
Java Persistence 1.0

Optional Element Summary
 String
 PersistenceProperty[]
 PersistenceContextType
 String
 

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

name

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

Default:
""

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

unitName

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

Default:
""

abstract public PersistenceContextType type()
指定这是事务范围的持久性上下文还是扩展的持久性上下文。
英文文档:

type

public abstract PersistenceContextType type
Specifies whether this is a transaction-scoped persistence context or an extended persistence context.

Default:
TRANSACTION

abstract public PersistenceProperty[] properties()
用于指定容器或持久性提供者的属性。此属性集中可以包含特定于供应商的属性。供应商无法识别的属性将被忽略。
英文文档:

properties

public abstract PersistenceProperty[] properties
Used to specify properties for the container or persistence provider. Vendor specific properties may be included in this set of properties. Properties that are not recognized by a vendor are ignored.

Default:
{}


Submit a bug or feature

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

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

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