Package org.hibernate.annotations
Annotation Type GeneratorType
@Retention(RUNTIME)@Target({FIELD,METHOD})@Deprecated(since="6.0")public @interfaceGeneratorType
Deprecated.ValueGenerationTypeandAnnotationValueGenerationnow provide a much more powerful and typesafe alternativeMarks a field or property of an entity as automatically generated by code written in Java, before any SQL statement toinsertorupdatethe entity is executed, specifying an implementation ofValueGeneratorused for generating its values.It is the responsibility of the client to ensure that a specifiedgenerator type produces values which are assignable to the annotated property.
This annotation is only useful for values generated in the Java code, and it is not used for generating the values of entity identifiers:
- For identifier generators, use
GenericGeneratororIdGeneratorType. - If the value of a field or property is generated by the database when an
insertorupdatestatement is executed, use theGeneratedannotation.
- For identifier generators, use
Required Element Summary
Required Elements Modifier and Type Required Element Description Class<? extendsValueGenerator<?>>typeDeprecated.A class that implementsValueGenerator, which will be called togenerate values of the annotated field or property.
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description GenerationTimewhenDeprecated.Specifies when values should be generated: IfGenerationTime.INSERT, the value will be generated before each SQLinsertstatement is executed.
Element Detail
type
Class<? extendsValueGenerator<?>> type
Deprecated.A class that implementsValueGenerator, which will be called togenerate values of the annotated field or property.- Returns:
- the value generator type
when
GenerationTime when
Deprecated.Specifies when values should be generated:- If
GenerationTime.INSERT, the value will be generated before each SQLinsertstatement is executed. - If
GenerationTime.UPDATE, the value will be generated before each SQLupdatestatement is executed. - If
GenerationTime.ALWAYS, the value will be generated before each SQLinsertorupdatestatement is executed.
- Default:
- org.hibernate.annotations.GenerationTime.ALWAYS
- If