Interface AnnotationBasedGenerator<A extends Annotation>

Type Parameters:
A - The generator annotation type supported by an implementation
All Superinterfaces:
Generator, Serializable
All Known Implementing Classes:
NativeGenerator

public interface AnnotationBasedGenerator<A extends Annotation> extends Generator
A Generator which receives parameters from a custom generator annotation or id generator annotation.

Implementing this interface is the same as providing a constructor with the same signature as the initialize(A, java.lang.reflect.Member, org.hibernate.generator.GeneratorCreationContext) method. But implementing this interface is slightly more typesafe.

For example, implementing AnnotationBasedGenerator<AnnotationType> is the same as providing a constructor with this signature:

 public GeneratorClass(AnnotationType config, Member idMember,
                      GeneratorCreationContext creationContext)
 

where GeneratorClass is the class that implements Generator, and AnnotationType is the generator annotation type used to configure the generator.

Every instance of this class must implement either BeforeExecutionGenerator or OnExecutionGenerator.

Since:
6.2
See Also:
  • Method Details

    • initialize

      void initialize(A annotation, Member member, GeneratorCreationContext context)
      Initializes this generation strategy for the given annotation instance.
      Parameters:
      annotation - an instance of the strategy's annotation type. Typically, implementations will retrieve the annotation's attribute values and store them in fields.
      member - the Java member annotated with the generator annotation.
      context - a GeneratorCreationContext
      Throws:
      HibernateException - in case an error occurred during initialization, e.g. if an implementation can't create a value for the given property type.