Top Description Methods
org.hibernate.generator

public Interface AnnotationBasedGenerator<A extends java.lang.annotation.Annotation>

extends Generator
Known Direct Subinterfaces
org.hibernate.tuple.AnnotationValueGeneration
Type Parameters
<A>
The generator annotation type supported by an implementation
Imports
java.lang.annotation.Annotation, java.lang.reflect.Member

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 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 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.

Author
Gavin King
Since
6.2
See Also
org.hibernate.annotations.ValueGenerationType, org.hibernate.annotations.IdGeneratorType

Method Summary

Modifier and TypeMethod and Description
public void
initialize(A
an instance of the strategy's annotation type. Typically, implementations will retrieve the annotation's attribute values and store them in fields.
annotation
,
Member
the Java member annotated with the generator annotation.
member
,
GeneratorCreationContext context)

Initializes this generation strategy for the given annotation instance.

Inherited from org.hibernate.generator.Generator:
generatedOnExecutiongeneratedOnExecutiongeneratesOnInsertgeneratesOnUpdategeneratesSometimesgetEventTypes

Method Detail

initializeback to summary
public void initialize(A annotation, Member member, GeneratorCreationContext context)

Initializes this generation strategy for the given annotation instance.

Parameters
annotation:A

an instance of the strategy's annotation type. Typically, implementations will retrieve the annotation's attribute values and store them in fields.

member:Member

the Java member annotated with the generator annotation.

context:GeneratorCreationContext

a GeneratorCreationContext

Exceptions
HibernateException:
in case an error occurred during initialization, e.g. if an implementation can't create a value for the given property type.