javax.persistence

## 枚举 GenerationType

- java.lang.Object
- - java.lang.Enum<GenerationType>
  - - javax.persistence.GenerationType

- 所有已实现的接口:
    java.io.Serializable, java.lang.Comparable<GenerationType>

      public enum GenerationType
      extends java.lang.Enum<GenerationType>

  Defines the types of primary key generation strategies.
  从以下版本开始:
    Java Persistence 1.0
  另请参阅:
    `GeneratedValue`

- - ### 枚举常量概要

    枚举常量
    枚举常量和说明
    `AUTO` Indicates that the persistence provider should pick an appropriate strategy for the particular database.
    `IDENTITY` Indicates that the persistence provider must assign primary keys for the entity using a database identity column.
    `SEQUENCE` Indicates that the persistence provider must assign primary keys for the entity using a database sequence.
    `TABLE` Indicates that the persistence provider must assign primary keys for the entity using an underlying database table to ensure uniqueness.

  - ### 方法概要

    所有方法 静态方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `static GenerationType` | `valueOf(java.lang.String name)` 返回带有指定名称的该类型的枚举常量。
    `static GenerationType[]` | `values()` 按照声明该枚举类型的常量的顺序, 返回 包含这些常量的数组。

    - ### 从类继承的方法 java.lang.Enum

      `clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

    - ### 从类继承的方法 java.lang.Object

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### 枚举常量详细资料

    - #### TABLE

          public static final GenerationType TABLE

      Indicates that the persistence provider must assign primary keys for the entity using an underlying database table to ensure uniqueness.

    - #### SEQUENCE

          public static final GenerationType SEQUENCE

      Indicates that the persistence provider must assign primary keys for the entity using a database sequence.

    - #### IDENTITY

          public static final GenerationType IDENTITY

      Indicates that the persistence provider must assign primary keys for the entity using a database identity column.

    - #### AUTO

          public static final GenerationType AUTO

      Indicates that the persistence provider should pick an appropriate strategy for the particular database. The `AUTO` generation strategy may expect a database resource to exist, or it may attempt to create one. A vendor may provide documentation on how to create such resources in the event that it does not support schema generation or cannot create the schema resource at runtime.

  - ### 方法详细资料

    - #### values

          public static GenerationType[] values()

      按照声明该枚举类型的常量的顺序, 返回 包含这些常量的数组。该方法可用于迭代 常量, 如下所示:

          for (GenerationType c : GenerationType.values())
              System.out.println(c);

      返回:
        按照声明该枚举类型的常量的顺序返回的包含这些常量的数组

    - #### valueOf

          public static GenerationType valueOf(java.lang.String name)

      返回带有指定名称的该类型的枚举常量。 字符串必须与用于声明该类型的枚举常量的 标识符完全匹配。(不允许有多余 的空格字符。)
      参数:
        `name` - 要返回的枚举常量的名称。
      返回:
        返回带有指定名称的枚举常量
      抛出:
        `java.lang.IllegalArgumentException` - 如果该枚举类型没有带有指定名称的常量
        `java.lang.NullPointerException` - 如果参数为空值