Top Description Methods
org.hibernate.tuple

public Interface ValueGeneration

extends BeforeExecutionGenerator, OnExecutionGenerator
Known Direct Subinterfaces
org.hibernate.tuple.AnnotationValueGeneration
Annotations
@Deprecated
since:6.2
forRemoval:true
Imports
java.util.EnumSet, org.hibernate.dialect.Dialect, org.hibernate.engine.spi.SharedSessionContractImplementor, org.hibernate.generator.EventType, .Generator, .OnExecutionGenerator, .BeforeExecutionGenerator

Deprecated

for removal since 6.2.

Replaced by Generator

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 either BeforeExecutionGenerator or OnExecutionGenerator directly.

Authors
Steve Ebersole, Gavin King
See Also
AnnotationValueGeneration

Method Summary

Modifier and TypeMethod and Description
public default Object
generate(SharedSessionContractImplementor
The session from which the request originates.
session
,
Object
The instance of the object owning the attribute for which we are generating a value.
owner
,
Object
The current value assigned to the property, or null
currentValue
,
EventType
The type of event that has triggered generation of a new value
eventType
)

Implements org.hibernate.generator.BeforeExecutionGenerator.generate.

Generate a value.
public default boolean

Returns:

true if the value is generated by the database, or false if it is generated in Java using a ValueGenerator.
generatedOnExecution
()

Overrides default org.hibernate.generator.BeforeExecutionGenerator.generatedOnExecution, org.hibernate.generator.OnExecutionGenerator.generatedOnExecution.

Determines if the property value is generated in Java, or by the database.
public String

Returns:

The column value to be used in the generated SQL statement.
getDatabaseGeneratedReferencedColumnValue
()

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.

public default String

Returns:

The column value to be used in the generated SQL statement.
getDatabaseGeneratedReferencedColumnValue
(Dialect
The SQL dialect, allowing generation of an expression in dialect-specific SQL.
dialect
)

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.

public default EnumSet<EventType>
getEventTypes()

Implements org.hibernate.generator.Generator.getEventTypes.

The event types for which this generator should be called to produce a new value.
public GenerationTiming

Returns:

The GenerationTiming specifying when the value is generated.
getGenerationTiming
()

Deprecated as a consequence of GenerationTiming being deprecated.
Specifies that the property value is generated:
public default String[]
getReferencedColumnValues(Dialect
The SQL dialect, allowing generation of an expression in dialect-specific SQL.
dialect
)

Implements org.hibernate.generator.OnExecutionGenerator.getReferencedColumnValues.

A SQL expression indicating how to calculate the generated values when the mapped columns are included in the SQL statement.
public ValueGenerator<?>

Returns:

The value generator
getValueGenerator
()

Deprecated as a consequence of ValueGenerator being deprecated.
Obtain the Java value generator, if the value is generated in Java, or return null if the value is generated by the database.
public boolean

Returns:

true if the column is included in the column list of the SQL statement.
referenceColumnInSql
()

Determines if the column whose value is generated is included in the column list of the SQL insert or update statement, in the case where the value is generated by the database.

public default boolean
referenceColumnsInSql(Dialect dialect)

Implements org.hibernate.generator.OnExecutionGenerator.referenceColumnsInSql.

Determines if the columns whose values are generated are included in the column list of the SQL insert or update statement.
public default boolean
writePropertyValue()

Implements org.hibernate.generator.OnExecutionGenerator.writePropertyValue.

Determines if the property value is written to JDBC as the argument of a JDBC ?
Inherited from org.hibernate.generator.OnExecutionGenerator:
getGeneratedIdentifierDelegategetUniqueKeyPropertyNames

Method Detail

generateback to summary
public default Object generate(SharedSessionContractImplementor session, Object owner, Object currentValue, EventType eventType)

Implements org.hibernate.generator.BeforeExecutionGenerator.generate.

Doc from org.hibernate.generator.BeforeExecutionGenerator.generate.

Generate a value.

Parameters
session:SharedSessionContractImplementor

The session from which the request originates.

owner:Object

The instance of the object owning the attribute for which we are generating a value.

currentValue:Object

The current value assigned to the property, or null

eventType:EventType

The type of event that has triggered generation of a new value

Returns:Object

The generated value

Annotations
@Override
generatedOnExecutionback to summary
public default boolean generatedOnExecution()

Overrides default org.hibernate.generator.BeforeExecutionGenerator.generatedOnExecution, org.hibernate.generator.OnExecutionGenerator.generatedOnExecution.

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.

Returns:boolean

true if the value is generated by the database, or false if it is generated in Java using a ValueGenerator.

Annotations
@Override
getDatabaseGeneratedReferencedColumnValueback to summary
public String getDatabaseGeneratedReferencedColumnValue()

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 or nextval('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:String

The column value to be used in the generated SQL statement.

getDatabaseGeneratedReferencedColumnValueback to summary
public default String getDatabaseGeneratedReferencedColumnValue(Dialect dialect)

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 or nextval('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:Dialect

The SQL dialect, allowing generation of an expression in dialect-specific SQL.

Returns:String

The column value to be used in the generated SQL statement.

getEventTypesback to summary
public default EnumSet<EventType> getEventTypes()

Implements org.hibernate.generator.Generator.getEventTypes.

Doc from org.hibernate.generator.Generator.getEventTypes.

The event types for which this generator should be called to produce a new value.

Identifier generators must return EventTypeSets#INSERT_ONLY.

Returns:EnumSet<EventType>

a set of EventTypes.

Annotations
@Override
getGenerationTimingback to summary
public GenerationTiming getGenerationTiming()

Deprecated

as a consequence of GenerationTiming being deprecated. See corresponding docs for further information.

Specifies that the property value is generated:

Returns:GenerationTiming

The GenerationTiming specifying when the value is generated.

getReferencedColumnValuesback to summary
public default String[] getReferencedColumnValues(Dialect dialect)

Implements org.hibernate.generator.OnExecutionGenerator.getReferencedColumnValues.

Doc from org.hibernate.generator.OnExecutionGenerator.getReferencedColumnValues.

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 or nextval('mysequence'), or
  • syntactic markers like default.
Parameters
dialect:Dialect

The SQL dialect, allowing generation of an expression in dialect-specific SQL.

Returns:String[]

The column value to be used in the generated SQL statement.

Annotations
@Override
getValueGeneratorback to summary
public ValueGenerator<?> getValueGenerator()

Deprecated

as a consequence of ValueGenerator being deprecated. See corresponding docs for further information.

Obtain the Java value generator, if the value is generated in Java, or return null if the value is generated by the database.

Returns:ValueGenerator<?>

The value generator

referenceColumnInSqlback to summary
public boolean referenceColumnInSql()

Determines if the column whose value is generated is included in the column list of the SQL insert or update statement, in the case where the value is generated by the database. For example, this method should return:

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:boolean

true if the column is included in the column list of the SQL statement.

referenceColumnsInSqlback to summary
public default boolean referenceColumnsInSql(Dialect dialect)

Implements org.hibernate.generator.OnExecutionGenerator.referenceColumnsInSql.

Doc from org.hibernate.generator.OnExecutionGenerator.referenceColumnsInSql.

Determines if the columns whose values are generated are included in the column list of the SQL insert or update statement. For example, this method should return:

Returns:boolean

true if the column is included in the column list of the SQL statement.

Annotations
@Override
writePropertyValueback to summary
public default boolean writePropertyValue()

Implements org.hibernate.generator.OnExecutionGenerator.writePropertyValue.

Determines if the property value is written to JDBC as the argument of a JDBC ? parameter. This is the case when either:

Annotations
@Override
See Also
org.hibernate.annotations.Generated#writable()