SequenceGenerator (Java EE 5)

Java EE API


javax.persistence Annotation Type SequenceGenerator


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

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

此注释定义为 GeneratedValue 注释指定生成器元素时可以通过名称引用的主键生成器。可以对实体类或主键字段或属性指定序列生成器。生成器名称的范围对于持久性单元是全局的(跨所有生成器类型)。
示例:

 @SequenceGenerator(name="EMP_SEQ", allocationSize=25)
 
英文文档:

This annotation defines a primary key generator that may be referenced by name when a generator element is specified for the GeneratedValue annotation. A sequence generator may be specified on the entity class or on the primary key field or property. The scope of the generator name is global to the persistence unit (across all generator types).

   Example:

   @SequenceGenerator(name="EMP_SEQ", allocationSize=25)
 

Since:
Java Persistence 1.0

Required Element Summary
 String
 
Optional Element Summary
 int
 int
 String
 

Element Detail

abstract public String name()
(必需)可以被将用作主键值生成器的一个或多个类引用的唯一生成器名称。
英文文档:

name

public abstract String name
(Required) A unique generator name that can be referenced by one or more classes to be the generator for primary key values.

abstract public String sequenceName()
(可选)可以从中获取主键值的数据库序列对象名称。

默认为提供者选择的值。

英文文档:

sequenceName

public abstract String sequenceName
(Optional) The name of the database sequence object from which to obtain primary key values.

Defaults to a provider-chosen value.

Default:
""

abstract public int initialValue()
(可选)开始生成序列对象的值。
英文文档:

initialValue

public abstract int initialValue
(Optional) The value from which the sequence object is to start generating.

Default:
1

abstract public int allocationSize()
(可选)从序列分配序列号时递增的量。
英文文档:

allocationSize

public abstract int allocationSize
(Optional) The amount to increment by when allocating sequence numbers from the sequence.

Default:
50


Submit a bug or feature

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

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

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