Annotation Type GenericGenerator


  • @Target({PACKAGE,TYPE,METHOD,FIELD})
    @Retention(RUNTIME)
    @Repeatable(GenericGenerators.class)
    public @interface GenericGenerator
    Defines a named identifier generator, usually an instance of the interface IdentifierGenerator. This allows the use of custom identifier generation strategies beyond those provided by the four basic JPA-defined generation types.

    A named generator may be associated with an entity class by:

    • defining a named generator using this annotation, specifying an implementation of IdentifierGenerator using type(), then
    • annotating the identifier property of the entity with the JPA-defined @GeneratedValue annotation, and
    • using generator to specify the name() of the generator defined using this annotation.
    If neither type() not strategy() is specified, Hibernate asks the dialect to decide an appropriate strategy. This is equivalent to using AUTO in JPA.

    For example, if we define a generator using:

    {@code
    See Also:
    GeneratedValue