Annotation Interface PortableSequenceGenerator


@Target({TYPE,METHOD,FIELD}) @Retention(RUNTIME) public @interface PortableSequenceGenerator
Defines a primary key generator that may be referenced by name when a generator element is specified for the GeneratedValue annotation.

A portable 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).

The term "portable" in this case indicates that native sequences will be used if the target database platform supports them. However, if it does not have native sequence support, then sequence-like behavior will be emulated using an appropriate strategy for the target platform.

   Examples:

   @PortableSequenceGenerator(name="EMP_SEQ")

   @PortableSequenceGenerator(name="EMP_SEQ", sequenceName="EMP_SEQ", initialValue = 1)
 

Current, in order for this annotation to work properly, the KradEclipseLinkCustomizer must be configured for the EclipseLink persistence unit. This can be done manually using PersistenceUnitProperties.SESSION_CUSTOMIZER, or it will be done automatically when using KradEclipseLinkEntityManagerFactoryBean.

Author:
Kuali Rice Team (rice.collab@kuali.org)
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    (Required) A unique generator name that can be referenced by one or more classes to be the generator for primary key values.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    int
    (Optional) The value from which the sequence object is to start generating.
    (Optional) The name of the database sequence object from which to obtain primary key values.
  • Element Details

    • name

      String name
      (Required) A unique generator name that can be referenced by one or more classes to be the generator for primary key values.
      Returns:
      the name of the sequence generator.
    • sequenceName

      String sequenceName
      (Optional) The name of the database sequence object from which to obtain primary key values. If not specified, will default to the name of this generator.
      Returns:
      the sequence name associated with the sequence generator.
      Default:
      ""
    • initialValue

      int initialValue
      (Optional) The value from which the sequence object is to start generating. Only used for generation of the sequence in the schema.

      If the sequence construct already exists in the database or schema generation is not enabled, then this value is effectively ignored.

      Returns:
      the initial value of the sequence.
      Default:
      1000