Class GeneratedGeneration

java.lang.Object
org.hibernate.generator.internal.GeneratedGeneration
All Implemented Interfaces:
Serializable, Generator, OnExecutionGenerator

public class GeneratedGeneration extends Object implements OnExecutionGenerator
A fairly generic OnExecutionGenerator which marks a property as generated in the database with semantics given explicitly by a @Generated annotation.
See Also:
  • Constructor Details

    • GeneratedGeneration

      public GeneratedGeneration(EnumSet<EventType> eventTypes)
    • GeneratedGeneration

      public GeneratedGeneration(Generated annotation)
  • Method Details

    • getEventTypes

      public EnumSet<EventType> getEventTypes()
      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 interface Generator
      Returns:
      a set of EventTypes.
    • referenceColumnsInSql

      public boolean referenceColumnsInSql(Dialect dialect)
      Description copied from interface: OnExecutionGenerator
      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:
      Specified by:
      referenceColumnsInSql in interface OnExecutionGenerator
      Returns:
      true if the column is included in the column list of the SQL statement.
    • getReferencedColumnValues

      public String[] getReferencedColumnValues(Dialect dialect)
      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 or nextval('mysequence'), or
      • syntactic markers like default.
      Specified by:
      getReferencedColumnValues in interface OnExecutionGenerator
      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.
    • writePropertyValue

      public boolean writePropertyValue()
      Description copied from interface: OnExecutionGenerator
      Determines if the property values are written to JDBC as the argument of a JDBC ? parameter.
      Specified by:
      writePropertyValue in interface OnExecutionGenerator
    • generatedOnExecution

      public boolean generatedOnExecution(Object entity, SharedSessionContractImplementor session)
      Description copied from interface: Generator
      Determines if the property value is generated when a row is written to the database.

      Defaults to Generator.generatedOnExecution(), but may be overridden to allow conditional on-execution value generation based on the current state of the owner entity.

      Specified by:
      generatedOnExecution in interface Generator
      Parameters:
      entity - The instance of the entity owning the attribute for which we are generating a value.
      session - The session from which the request originates.
      Returns:
      true if the value is generated by the database as a side effect of the execution of an insert or update statement.
      See Also:
    • allowAssignedIdentifiers

      public boolean allowAssignedIdentifiers()
      Description copied from interface: Generator
      Determine if this generator allows identifier values to be manually assigned to the entity instance before persisting it. This is useful when, for example, needing existing assigned values to be used as identifiers and falling back to generated values by default.
      Specified by:
      allowAssignedIdentifiers in interface Generator
      Returns:
      true if this generator allows pre-assigned identifier values, false otherwise (default).
    • allowMutation

      public boolean allowMutation()
      Description copied from interface: Generator
      Determine if this generator allows generated fields to be manually assigned a value on events which do not trigger value generation.
      Specified by:
      allowMutation in interface Generator
      Returns:
      true if this generator allows manually assigned values, false otherwise (default).