Interface ValueGeneration
-
- All Superinterfaces:
BeforeExecutionGenerator
,Generator
,OnExecutionGenerator
,Serializable
- All Known Subinterfaces:
AnnotationValueGeneration<A>
- All Known Implementing Classes:
CreationTimestampGeneration
,UpdateTimestampGeneration
@Deprecated(since="6.2", forRemoval=true) public interface ValueGeneration extends BeforeExecutionGenerator, OnExecutionGenerator
Deprecated, for removal: This API element is subject to removal in a future version.Replaced byGenerator
A value generator that can adapt to both Java value generation and database value generation.This is an older API that predates
Generator
. It's often cleaner to implement eitherBeforeExecutionGenerator
orOnExecutionGenerator
directly.- See Also:
AnnotationValueGeneration
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default Object
generate(SharedSessionContractImplementor session, Object owner, Object currentValue, EventType eventType)
Deprecated, for removal: This API element is subject to removal in a future version.Generate a value.default boolean
generatedOnExecution()
Deprecated, for removal: This API element is subject to removal in a future version.Determines if the property value is generated in Java, or by the database.String
getDatabaseGeneratedReferencedColumnValue()
Deprecated, for removal: This API element is subject to removal in a future version.A SQL expression indicating how to calculate the generated value when the property value is generated in the database and the mapped column is included in the SQL statement.default String
getDatabaseGeneratedReferencedColumnValue(Dialect dialect)
Deprecated, for removal: This API element is subject to removal in a future version.A SQL expression indicating how to calculate the generated value when the property value is generated in the database and the mapped column is included in the SQL statement.default EnumSet<EventType>
getEventTypes()
Deprecated, for removal: This API element is subject to removal in a future version.The event types for which this generator should be called to produce a new value.GenerationTiming
getGenerationTiming()
Deprecated, for removal: This API element is subject to removal in a future version.Specifies that the property value is generated: when the entity is inserted, when the entity is updated, whenever the entity is inserted or updated, or never.default String[]
getReferencedColumnValues(Dialect dialect)
Deprecated, for removal: This API element is subject to removal in a future version.A SQL expression indicating how to calculate the generated values when the mapped columns are included in the SQL statement.ValueGenerator<?>
getValueGenerator()
Deprecated, for removal: This API element is subject to removal in a future version.Obtain the Java value generator, if the value is generated in Java, or returnnull
if the value is generated by the database.boolean
referenceColumnInSql()
Deprecated, for removal: This API element is subject to removal in a future version.Determines if the column whose value is generated is included in the column list of the SQLinsert
orupdate
statement, in the case where the value is generated by the database.default boolean
referenceColumnsInSql(Dialect dialect)
Deprecated, for removal: This API element is subject to removal in a future version.Determines if the columns whose values are generated are included in the column list of the SQLinsert
orupdate
statement.default boolean
writePropertyValue()
Deprecated, for removal: This API element is subject to removal in a future version.Determines if the property value is written to JDBC as the argument of a JDBC?
parameter.-
Methods inherited from interface org.hibernate.generator.Generator
allowAssignedIdentifiers, generatedOnExecution, generatesOnInsert, generatesOnUpdate, generatesSometimes
-
Methods inherited from interface org.hibernate.generator.OnExecutionGenerator
getGeneratedIdentifierDelegate, getUniqueKeyPropertyNames
-
-
-
-
Method Detail
-
getGenerationTiming
GenerationTiming getGenerationTiming()
Deprecated, for removal: This API element is subject to removal in a future version.Specifies that the property value is generated:- Returns:
- The
GenerationTiming
specifying when the value is generated.
-
getEventTypes
default EnumSet<EventType> getEventTypes()
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:Generator
The event types for which this generator should be called to produce a new value.Identifier generators must return
EventTypeSets.INSERT_ONLY
.- Specified by:
getEventTypes
in interfaceGenerator
- Returns:
- a set of
EventType
s.
-
getValueGenerator
ValueGenerator<?> getValueGenerator()
Deprecated, for removal: This API element is subject to removal in a future version.Obtain the Java value generator, if the value is generated in Java, or returnnull
if the value is generated by the database.- Returns:
- The value generator
-
generate
default Object generate(SharedSessionContractImplementor session, Object owner, Object currentValue, EventType eventType)
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:BeforeExecutionGenerator
Generate a value.- Specified by:
generate
in interfaceBeforeExecutionGenerator
- Parameters:
session
- The session from which the request originates.owner
- The instance of the object owning the attribute for which we are generating a value.currentValue
- The current value assigned to the property, ornull
eventType
- The type of event that has triggered generation of a new value- Returns:
- The generated value
-
referenceColumnInSql
boolean referenceColumnInSql()
Deprecated, for removal: This API element is subject to removal in a future version.Determines if the column whose value is generated is included in the column list of the SQLinsert
orupdate
statement, in the case where the value is generated by the database. For example, this method should return:true
if the value is generated by calling a SQL function likecurrent_timestamp
, orfalse
if the value is generated by a trigger, bygenerated always as
, or using a column default value.
If the value is generated in Java, this method is not called, and so for backward compatibility with Hibernate 5 it is permitted to return any value. On the other hand, when a property value is generated in Java, the column certainly must be included in the column list, and so it's most correct for this method to return
true
!- Returns:
true
if the column is included in the column list of the SQL statement.
-
getDatabaseGeneratedReferencedColumnValue
String getDatabaseGeneratedReferencedColumnValue()
Deprecated, for removal: This API element is subject to removal in a future version.A SQL expression indicating how to calculate the generated value when the property value is generated in the database and the mapped column is included in the SQL statement. The SQL expression might be:- a function call like
current_timestamp
ornextval('mysequence')
, or - a syntactic marker like
default
.
When the property value is generated in Java, this method is not called, and its value is implicitly the string
"?"
, that is, a JDBC parameter to which the generated value is bound.- Returns:
- The column value to be used in the generated SQL statement.
- a function call like
-
getDatabaseGeneratedReferencedColumnValue
default String getDatabaseGeneratedReferencedColumnValue(Dialect dialect)
Deprecated, for removal: This API element is subject to removal in a future version.A SQL expression indicating how to calculate the generated value when the property value is generated in the database and the mapped column is included in the SQL statement. The SQL expression might be:- a function call like
current_timestamp
ornextval('mysequence')
, or - a syntactic marker like
default
.
When the property value is generated in Java, this method is not called, and its value is implicitly the string
"?"
, that is, a JDBC parameter to which the generated value is bound.- Parameters:
dialect
- The SQL dialect, allowing generation of an expression in dialect-specific SQL.- Returns:
- The column value to be used in the generated SQL statement.
- a function call like
-
getReferencedColumnValues
default String[] getReferencedColumnValues(Dialect dialect)
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:OnExecutionGenerator
A SQL expression indicating how to calculate the generated values when the mapped columns are included in the SQL statement. The SQL expressions might be:- function calls like
current_timestamp
ornextval('mysequence')
, or - syntactic markers like
default
.
- Specified by:
getReferencedColumnValues
in interfaceOnExecutionGenerator
- Parameters:
dialect
- The SQL dialect, allowing generation of an expression in dialect-specific SQL.- Returns:
- The column value to be used in the generated SQL statement.
- function calls like
-
referenceColumnsInSql
default boolean referenceColumnsInSql(Dialect dialect)
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:OnExecutionGenerator
Determines if the columns whose values are generated are included in the column list of the SQLinsert
orupdate
statement. For example, this method should return:true
if the value is generated by calling a SQL function likecurrent_timestamp
, orfalse
if the value is generated by a trigger, bygenerated always as
, or using a column default value.
- Specified by:
referenceColumnsInSql
in interfaceOnExecutionGenerator
- Returns:
true
if the column is included in the column list of the SQL statement.
-
generatedOnExecution
default boolean generatedOnExecution()
Deprecated, for removal: This API element is subject to removal in a future version.Determines if the property value is generated in Java, or by the database.This default implementation returns true if the Java value generator is
null
.- Specified by:
generatedOnExecution
in interfaceBeforeExecutionGenerator
- Specified by:
generatedOnExecution
in interfaceGenerator
- Specified by:
generatedOnExecution
in interfaceOnExecutionGenerator
- Returns:
true
if the value is generated by the database, or false if it is generated in Java using aValueGenerator
.
-
writePropertyValue
default boolean writePropertyValue()
Deprecated, for removal: This API element is subject to removal in a future version.Determines if the property value is written to JDBC as the argument of a JDBC?
parameter. This is the case when either:- the value is generated in Java, or
referenceColumnInSql()
istrue
andgetDatabaseGeneratedReferencedColumnValue()
returnsnull
.
- Specified by:
writePropertyValue
in interfaceOnExecutionGenerator
- See Also:
Generated.writable()
-
-