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

public Class CurrentTimestampGeneration

extends Object
implements BeforeExecutionGenerator, OnExecutionGenerator
Class Inheritance
All Implemented Interfaces
org.hibernate.generator.OnExecutionGenerator, org.hibernate.generator.Generator, java.io.Serializable, org.hibernate.generator.BeforeExecutionGenerator
Imports
org.hibernate.AssertionFailure, org.hibernate.annotations.CreationTimestamp, .CurrentTimestamp, .SourceType, .UpdateTimestamp, org.hibernate.dialect.Dialect, org.hibernate.engine.jdbc.Size, org.hibernate.engine.spi.SharedSessionContractImplementor, org.hibernate.generator.EventType, .OnExecutionGenerator, .BeforeExecutionGenerator, .GeneratorCreationContext, org.hibernate.internal.util.ReflectHelper, org.hibernate.mapping.BasicValue, org.hibernate.tuple.GenerationTiming, org.hibernate.type.descriptor.java.ClockHelper, java.lang.reflect.Member, java.sql.Time, .Timestamp, java.time.Clock, .Instant, .LocalDate, .LocalDateTime, .LocalTime, .MonthDay, .OffsetDateTime, .OffsetTime, .Year, .YearMonth, .ZoneId, .ZonedDateTime, java.util.Calendar, .Date, .EnumSet, .HashMap, .Map, java.util.concurrent.ConcurrentHashMap, java.util.function.IntFunction

Value generation strategy which produces a timestamp using the database current_timestamp function or the JVM current instant.

Underlies the CurrentTimestamp, CreationTimestamp, and UpdateTimestamp annotations.

Authors
Steve Ebersole, Gavin King
Since
6.0
See Also
CurrentTimestamp, CreationTimestamp, UpdateTimestamp

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static interface
private static class

Field Summary

Modifier and TypeField and Description
private final CurrentTimestampGeneration.CurrentTimestampGeneratorDelegate
private final EnumSet<EventType>
private static final Map<CurrentTimestampGeneration.Key, CurrentTimestampGeneration.CurrentTimestampGeneratorDelegate>
private static final Map<Class<?>, IntFunction<CurrentTimestampGeneration.CurrentTimestampGeneratorDelegate>>

Constructor Summary

AccessConstructor and Description
public
public
public

Method Summary

Modifier and TypeMethod and Description
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.
public boolean
generatedOnExecution()

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

Determines if the property value is generated when a row is written to the database, or in Java code that executes before the row is written.
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 CurrentTimestampGeneration.CurrentTimestampGeneratorDelegate
pack-priv static CurrentTimestampGeneration.CurrentTimestampGeneratorDelegate
public 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 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 boolean
writePropertyValue()

Implements org.hibernate.generator.OnExecutionGenerator.writePropertyValue.

Determines if the property values are written to JDBC as the argument of a JDBC ?
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegateback to summary
private final CurrentTimestampGeneration.CurrentTimestampGeneratorDelegate delegate
eventTypesback to summary
private final EnumSet<EventType> eventTypes
GENERATOR_DELEGATESback to summary
private static final Map<CurrentTimestampGeneration.Key, CurrentTimestampGeneration.CurrentTimestampGeneratorDelegate> GENERATOR_DELEGATES
GENERATOR_PRODUCERSback to summary
private static final Map<Class<?>, IntFunction<CurrentTimestampGeneration.CurrentTimestampGeneratorDelegate>> GENERATOR_PRODUCERS

Constructor Detail

CurrentTimestampGenerationback to summary
public CurrentTimestampGeneration(CurrentTimestamp annotation, Member member, GeneratorCreationContext context)
CurrentTimestampGenerationback to summary
public CurrentTimestampGeneration(CreationTimestamp annotation, Member member, GeneratorCreationContext context)
CurrentTimestampGenerationback to summary
public CurrentTimestampGeneration(UpdateTimestamp annotation, Member member, GeneratorCreationContext context)

Method Detail

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
generatedOnExecutionback to summary
public boolean generatedOnExecution()

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

Doc from org.hibernate.generator.Generator.generatedOnExecution.

Determines if the property value is generated when a row is written to the database, or in Java code that executes before the row is written.

  • Generators which only implement BeforeExecutionGenerator must result false.
  • Generators which only implement OnExecutionGenerator must result true.
  • Generators which implement both subinterfaces may decide at runtime what value to return.
Returns:boolean

true if the value is generated by the database as a side effect of the execution of an insert or update statement, or false if it is generated in Java code before the statement is executed via JDBC.

Annotations
@Override
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>

a set of EventTypes.

Annotations
@Override
getGeneratorDelegateback to summary
private static CurrentTimestampGeneration.CurrentTimestampGeneratorDelegate getGeneratorDelegate(SourceType source, Member member, GeneratorCreationContext context)
getGeneratorDelegateback to summary
pack-priv static CurrentTimestampGeneration.CurrentTimestampGeneratorDelegate getGeneratorDelegate(SourceType source, Class<?> propertyType, GeneratorCreationContext context)
getReferencedColumnValuesback to summary
public 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
referenceColumnsInSqlback to summary
public 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 boolean writePropertyValue()

Implements org.hibernate.generator.OnExecutionGenerator.writePropertyValue.

Doc from org.hibernate.generator.OnExecutionGenerator.writePropertyValue.

Determines if the property values are written to JDBC as the argument of a JDBC ? parameter.

Annotations
@Override
org.hibernate.generator.internal back to summary

pack-priv Interface CurrentTimestampGeneration.CurrentTimestampGeneratorDelegate


Method Summary

Modifier and TypeMethod and Description
public Object

Method Detail

generateback to summary
public Object generate()
org.hibernate.generator.internal back to summary

private Class CurrentTimestampGeneration.Key

extends Object
Class Inheritance
  • java.lang.Object
  • org.hibernate.generator.internal.CurrentTimestampGeneration.Key

Field Summary

Modifier and TypeField and Description
private final Class<?>
private final int

Constructor Summary

AccessConstructor and Description
public
Key(Class<?> clazz, int precision)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

clazzback to summary
private final Class<?> clazz
precisionback to summary
private final int precision

Constructor Detail

Keyback to summary
public Key(Class<?> clazz, int precision)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override