Class TableGenerator

    • Constructor Detail

      • TableGenerator

        public TableGenerator()
    • Method Detail

      • getIdentifierType

        public final Type getIdentifierType()
        Type mapping for the identifier.
        Returns:
        The identifier type mapping.
      • getTableName

        public final String getTableName()
        The name of the table in which we store this generator's persistent state.
        Returns:
        The table name.
      • getSegmentColumnName

        public final String getSegmentColumnName()
        The name of the column in which we store the segment to which each row belongs. The value here acts as PK.
        Returns:
        The segment column name
      • getSegmentValue

        public final String getSegmentValue()
        The value in segment column which corresponding to this generator instance. In other words this value indicates the row in which this generator instance will store values.
        Returns:
        The segment value for this generator instance.
      • getSegmentValueLength

        public final int getSegmentValueLength()
        The size of the segment column in the underlying table.

        NOTE : should really have been called 'segmentColumnLength' or even better 'segmentColumnSize'

        Returns:
        the column size.
      • getValueColumnName

        public final String getValueColumnName()
        The name of the column in which we store our persistent generator value.
        Returns:
        The name of the value column.
      • getInitialValue

        public final int getInitialValue()
        The initial value to use when we find no previous state in the generator table corresponding to our sequence.
        Returns:
        The initial value to use.
      • getIncrementSize

        public final int getIncrementSize()
        The amount of increment to use. The exact implications of this depends on the optimizer being used.
        Returns:
        The increment amount.
      • getOptimizer

        public final Optimizer getOptimizer()
        The optimizer being used by this generator.
        Returns:
        Out optimizer.
      • getTableAccessCount

        public final long getTableAccessCount()
        Getter for property 'tableAccessCount'. Only really useful for unit test assertions.
        Returns:
        Value for property 'tableAccessCount'.
      • configure

        public void configure​(Type type,
                              Properties params,
                              ServiceRegistry serviceRegistry)
                       throws MappingException
        Description copied from interface: Configurable
        Configure this instance, given the value of parameters specified by the user as <param> elements. This method is called just once, following instantiation.
        Specified by:
        configure in interface Configurable
        Parameters:
        type - The id property type descriptor
        params - param values, keyed by parameter name
        serviceRegistry - Access to service that may be needed.
        Throws:
        MappingException
      • determineGeneratorTableName

        protected QualifiedName determineGeneratorTableName​(Properties params,
                                                            JdbcEnvironment jdbcEnvironment,
                                                            ServiceRegistry serviceRegistry)
        Determine the table name to use for the generator values.

        Called during configuration.

        Parameters:
        params - The params supplied in the generator config (plus some standard useful extras).
        jdbcEnvironment - The JDBC environment
        Returns:
        The table name to use.
        See Also:
        getTableName()
      • determineSegmentColumnName

        protected String determineSegmentColumnName​(Properties params,
                                                    JdbcEnvironment jdbcEnvironment)
        Determine the name of the column used to indicate the segment for each row. This column acts as the primary key.

        Called during configuration.

        Parameters:
        params - The params supplied in the generator config (plus some standard useful extras).
        jdbcEnvironment - The JDBC environment
        Returns:
        The name of the segment column
        See Also:
        getSegmentColumnName()
      • determineValueColumnName

        protected String determineValueColumnName​(Properties params,
                                                  JdbcEnvironment jdbcEnvironment)
        Determine the name of the column in which we will store the generator persistent value.

        Called during configuration.

        Parameters:
        params - The params supplied in the generator config (plus some standard useful extras).
        jdbcEnvironment - The JDBC environment
        Returns:
        The name of the value column
        See Also:
        getValueColumnName()
      • determineSegmentValue

        protected String determineSegmentValue​(Properties params)
        Determine the segment value corresponding to this generator instance.

        Called during configuration.

        Parameters:
        params - The params supplied in the generator config (plus some standard useful extras).
        Returns:
        The name of the value column
        See Also:
        getSegmentValue()
      • determineDefaultSegmentValue

        protected String determineDefaultSegmentValue​(Properties params)
        Used in the cases where determineSegmentValue(java.util.Properties) is unable to determine the value to use.
        Parameters:
        params - The params supplied in the generator config (plus some standard useful extras).
        Returns:
        The default segment value to use.
      • determineSegmentColumnSize

        protected int determineSegmentColumnSize​(Properties params)
        Determine the size of the segment column

        Called during configuration.

        Parameters:
        params - The params supplied in the generator config (plus some standard useful extras).
        Returns:
        The size of the segment column
        See Also:
        getSegmentValueLength()
      • determineInitialValue

        protected int determineInitialValue​(Properties params)
      • determineIncrementSize

        protected int determineIncrementSize​(Properties params)
      • buildSelectQuery

        protected String buildSelectQuery​(Dialect dialect)
      • buildUpdateQuery

        protected String buildUpdateQuery()
      • buildInsertQuery

        protected String buildInsertQuery()
      • generateInsertInitCommand

        protected InitCommand generateInsertInitCommand()