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'.
      • determineSequenceName

        protected QualifiedName determineSequenceName​(java.util.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​(java.util.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​(java.util.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​(java.util.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 java.lang.String determineOptimizationStrategy​(java.util.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​(java.lang.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,
                                                           java.util.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).
      • isPhysicalSequence

        protected boolean isPhysicalSequence​(JdbcEnvironment jdbcEnvironment,
                                             boolean forceTableUse)
      • generatorKey

        @Deprecated
        public java.lang.Object generatorKey()
        Deprecated.
        Description copied from interface: PersistentIdentifierGenerator
        Return a key unique to the underlying database objects. Prevents us from trying to create/remove them multiple times.
        Specified by:
        generatorKey in interface PersistentIdentifierGenerator
        Returns:
        Object an identifying key for this generator