Package org.hibernate.generator
Interface AnnotationBasedGenerator<A extends Annotation>
-
- Type Parameters:
A
- The generator annotation type supported by an implementation
- All Superinterfaces:
Generator
,Serializable
- All Known Subinterfaces:
AnnotationValueGeneration<A>
- All Known Implementing Classes:
CreationTimestampGeneration
,UpdateTimestampGeneration
public interface AnnotationBasedGenerator<A extends Annotation> extends Generator
AGenerator
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, CustomIdGeneratorCreationContext creationContext)
where
GeneratorClass
is the class that implementsGenerator
, andAnnotationType
is the generator annotation type used to configure the generator.Every instance of this class must implement either
BeforeExecutionGenerator
orOnExecutionGenerator
.- Since:
- 6.2
- See Also:
ValueGenerationType
,IdGeneratorType
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
initialize(A annotation, Member member, GeneratorCreationContext context)
Initializes this generation strategy for the given annotation instance.-
Methods inherited from interface org.hibernate.generator.Generator
generatedOnExecution, generatesOnInsert, generatesOnUpdate, generatesSometimes, getEventTypes
-
-
-
-
Method Detail
-
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
- aGeneratorCreationContext
- Throws:
HibernateException
- in case an error occurred during initialization, e.g. if an implementation can't create a value for the given property type.
-
-