Top Description Fields Constructors Methods
org.hibernate.generator.internal

public Class SourceGeneration

extends Object
implements BeforeExecutionGenerator
Class Inheritance
All Implemented Interfaces
org.hibernate.generator.BeforeExecutionGenerator, org.hibernate.generator.Generator, java.io.Serializable
Annotations
@Deprecated
since:6.2
@Internal
Imports
org.hibernate.Internal, org.hibernate.annotations.Source, .SourceType, org.hibernate.dialect.Dialect, org.hibernate.engine.jdbc.spi.JdbcCoordinator, org.hibernate.engine.spi.SharedSessionContractImplementor, org.hibernate.generator.EventType, .EventTypeSets, .GeneratorCreationContext, .BeforeExecutionGenerator, org.hibernate.internal.CoreMessageLogger, org.hibernate.type.descriptor.java.JavaType, org.jboss.logging.Logger, java.lang.reflect.Member, java.sql.CallableStatement, .PreparedStatement, .ResultSet, .SQLException, .Timestamp, java.util.EnumSet

Deprecated

since 6.2.

because both Source and hbm.xml are deprecated, though this implementation is instructive

Value generation strategy using the query Dialect#getCurrentTimestampSelectString(). This is a select that occurs before the insert or update, whereas with CurrentTimestampGeneration the select happens afterward.

Underlies the @Source annotation, and <timestamp source="db"/> in hbm.xml mapping documents.

Author
Gavin King
See Also
Source, CurrentTimestampGeneration

Field Summary

Modifier and TypeField and Description
private static final CoreMessageLogger
private final JavaType<?>
private final CurrentTimestampGeneration.CurrentTimestampGeneratorDelegate

Constructor Summary

AccessConstructor and Description
public
SourceGeneration(Source annotation, Member member, GeneratorCreationContext context)

Deprecated as a consequence of Source being deprecated.
public
SourceGeneration(SourceType sourceType, Class<?> propertyType, GeneratorCreationContext context)

Method Summary

Modifier and TypeMethod and Description
private static Timestamp
private static Timestamp
public 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.
private Timestamp
public EnumSet<EventType>
getEventTypes()

Implements org.hibernate.generator.Generator.getEventTypes.

The event types for which this generator should be called to produce a new value.
private static void
private static PreparedStatement
prepareStatement(JdbcCoordinator coordinator, String timestampSelectString, boolean callable)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

logback to summary
private static final CoreMessageLogger log
propertyTypeback to summary
private final JavaType<?> propertyType
valueGeneratorback to summary
private final CurrentTimestampGeneration.CurrentTimestampGeneratorDelegate valueGenerator

Constructor Detail

SourceGenerationback to summary
public SourceGeneration(Source annotation, Member member, GeneratorCreationContext context)

Deprecated

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

SourceGenerationback to summary
public SourceGeneration(SourceType sourceType, Class<?> propertyType, GeneratorCreationContext context)

Method Detail

extractCalledResultback to summary
private static Timestamp extractCalledResult(PreparedStatement statement, JdbcCoordinator coordinator, String sql) throws SQLException
extractResultback to summary
private static Timestamp extractResult(PreparedStatement statement, JdbcCoordinator coordinator, String sql) throws SQLException
generateback to summary
public 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
getCurrentTimestampback to summary
private Timestamp getCurrentTimestamp(SharedSessionContractImplementor session)
getEventTypesback to summary
public 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>

EventTypeSets#INSERT_ONLY

Annotations
@Override
logResultback to summary
private static void logResult(Timestamp ts)
prepareStatementback to summary
private static PreparedStatement prepareStatement(JdbcCoordinator coordinator, String timestampSelectString, boolean callable)