001/*
002 * Copyright (c) 2008, 2009, 2011 Oracle, Inc. All rights reserved.
003 *
004 * This program and the accompanying materials are made available under the
005 * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
006 * which accompanies this distribution.  The Eclipse Public License is available
007 * at http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution License
008 * is available at http://www.eclipse.org/org/documents/edl-v10.php.
009 */
010package javax.persistence;
011
012import java.lang.annotation.Retention;
013import java.lang.annotation.Target;
014
015import static java.lang.annotation.ElementType.*;
016import static java.lang.annotation.RetentionPolicy.RUNTIME;
017
018/**
019 * Defines a primary key generator that may be referenced by name when a generator element is specified for
020 * the {@link GeneratedValue} annotation. A sequence generator may be specified on the
021 * primary key field.
022 * <p>
023 * <pre>
024 *   Example:
025 *
026 *   &#064;SequenceGenerator(name="EMP_SEQ", allocationSize=25)
027 * </pre>
028 *
029 * @since Java Persistence 1.0
030 */
031@Target({FIELD})
032@Retention(RUNTIME)
033public @interface SequenceGenerator {
034  /**
035   * (Required) A unique generator name that can be referenced by one or more classes to be the generator
036   * for primary key values.
037   *
038   * @return name
039   */
040  String name();
041
042  /**
043   * (Optional) The name of the database sequence object from which to obtain primary key values.
044   * <p>
045   * Defaults to a provider-chosen value.
046   *
047   * @return seq name
048   */
049  String sequenceName() default "";
050
051  /**
052   * (Optional) The catalog of the sequence generator.
053   *
054   * @return catalog
055   * @since Java Persistence 2.0
056   */
057  String catalog() default "";
058
059  /**
060   * (Optional) The schema of the sequence generator.
061   *
062   * @return schema
063   * @since Java Persistence 2.0
064   */
065  String schema() default "";
066
067  /**
068   * (Optional) The value from which the sequence object is to start generating.
069   *
070   * @return init value
071   */
072  int initialValue() default 1;
073
074  /**
075   * (Optional) The amount to increment by when allocating sequence numbers from the sequence.
076   *
077   * @return alloc size
078   */
079  int allocationSize() default 50;
080}