Class SequenceStyleGenerator

    • Constructor Detail

      • SequenceStyleGenerator

        public SequenceStyleGenerator()
    • Method Detail

      • getDatabaseStructure

        public DatabaseStructure getDatabaseStructure()
        Getter for property 'databaseStructure'.
        Returns:
        Value for property 'databaseStructure'.
      • getOptimizer

        public Optimizer getOptimizer()
        Getter for property 'optimizer'.
        Returns:
        Value for property 'optimizer'.
      • getIdentifierType

        public Type getIdentifierType()
        Getter for property 'identifierType'.
        Returns:
        Value for property 'identifierType'.
      • 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
      • determineSequenceName

        protected QualifiedName determineSequenceName​(Properties params,
                                                      Dialect dialect,
                                                      JdbcEnvironment jdbcEnv,
                                                      ServiceRegistry serviceRegistry)
        Determine the name of the sequence (or table if this resolves to a physical table) to use.

        Called during configuration.

        Parameters:
        params - The params supplied in the generator config (plus some standard useful extras).
        dialect - The dialect in effect
        jdbcEnv - The JdbcEnvironment
        Returns:
        The sequence name
      • determineValueColumnName

        protected Identifier determineValueColumnName​(Properties params,
                                                      JdbcEnvironment jdbcEnvironment)
        Determine the name of the column used to store the generator value in the db.

        Called during configuration when resolving to a physical table.

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

        protected int determineInitialValue​(Properties params)
        Determine the initial sequence value to use. This value is used when initializing the database structure (i.e. sequence/table).

        Called during configuration.

        Parameters:
        params - The params supplied in the generator config (plus some standard useful extras).
        Returns:
        The initial value
      • determineIncrementSize

        protected int determineIncrementSize​(Properties params)
        Determine the increment size to be applied. The exact implications of this value depends on the optimizer being used.

        Called during configuration.

        Parameters:
        params - The params supplied in the generator config (plus some standard useful extras).
        Returns:
        The increment size
      • determineOptimizationStrategy

        protected String determineOptimizationStrategy​(Properties params,
                                                       int incrementSize)
        Determine the optimizer to use.

        Called during configuration.

        Parameters:
        params - The params supplied in the generator config (plus some standard useful extras).
        incrementSize - The determined increment size
        Returns:
        The optimizer strategy (name)
      • determineAdjustedIncrementSize

        protected int determineAdjustedIncrementSize​(String optimizationStrategy,
                                                     int incrementSize)
        In certain cases we need to adjust the increment size based on the selected optimizer. This is the hook to achieve that.
        Parameters:
        optimizationStrategy - The optimizer strategy (name)
        incrementSize - The determined increment size
        Returns:
        The adjusted increment size.
      • buildDatabaseStructure

        protected DatabaseStructure buildDatabaseStructure​(Type type,
                                                           Properties params,
                                                           JdbcEnvironment jdbcEnvironment,
                                                           boolean forceTableUse,
                                                           QualifiedName sequenceName,
                                                           int initialValue,
                                                           int incrementSize)
        Build the database structure.
        Parameters:
        type - The Hibernate type of the identifier property
        params - The params supplied in the generator config (plus some standard useful extras).
        jdbcEnvironment - The JDBC environment in which the sequence will be used.
        forceTableUse - Should a table be used even if the dialect supports sequences?
        sequenceName - The name to use for the sequence or table.
        initialValue - The initial value.
        incrementSize - the increment size to use (after any adjustments).
        Returns:
        An abstraction for the actual database structure in use (table vs. sequence).