Class OpenBasePkGenerator

    • Constructor Detail

      • OpenBasePkGenerator

        public OpenBasePkGenerator()
        Used by DI
        Since:
        4.1
      • OpenBasePkGenerator

        protected OpenBasePkGenerator​(JdbcAdapter adapter)
    • Method Detail

      • longPkFromDatabase

        protected long longPkFromDatabase​(DataNode node,
                                          DbEntity entity)
                                   throws Exception
        Generates new (unique and non-repeating) primary key for specified DbEntity. Executed SQL looks like this:
          NEWID FOR Table Column
         

        COLUMN must be marked as UNIQUE in order for this to work properly.

        Overrides:
        longPkFromDatabase in class JdbcPkGenerator
        Throws:
        Exception
        Since:
        3.0
      • newIDString

        protected String newIDString​(DbEntity ent)
        Returns SQL string that can generate new (unique and non-repeating) primary key for specified DbEntity. No actual database operations are performed.
        Since:
        1.2
      • createAutoPk

        public void createAutoPk​(DataNode node,
                                 List<DbEntity> dbEntities)
                          throws Exception
        Description copied from interface: PkGenerator
        Generates necessary database objects to provide automatic primary key support.
        Specified by:
        createAutoPk in interface PkGenerator
        Overrides:
        createAutoPk in class JdbcPkGenerator
        Parameters:
        node - node that provides access to a DataSource.
        dbEntities - a list of entities that require primary key auto-generation support
        Throws:
        Exception
      • canCreatePK

        protected boolean canCreatePK​(DbEntity entity)
      • createPKString

        protected String createPKString​(DbEntity entity)
        Returns a String to create PK support for an entity.
      • createUniquePKIndexString

        protected String createUniquePKIndexString​(DbEntity entity)
        Returns a String to create a unique index on table primary key columns per OpenBase recommendations.
      • reset

        public void reset()
        Description copied from interface: PkGenerator
        Resets any cached primary keys forcing generator to go to the database next time id generation is requested. May not be applicable for all generator implementations.
        Specified by:
        reset in interface PkGenerator
        Overrides:
        reset in class JdbcPkGenerator
      • getPkCacheSize

        public int getPkCacheSize()
        Returns zero, since PK caching is not feasible with OpenBase PK generation mechanism.
        Overrides:
        getPkCacheSize in class JdbcPkGenerator
      • setPkCacheSize

        public void setPkCacheSize​(int pkCacheSize)
        Description copied from class: JdbcPkGenerator
        Sets the size of the entity primary key cache. If pkCacheSize parameter is less than 1, cache size is set to "one".

        Note that our tests show that setting primary key cache value to anything much bigger than 20 does not give any significant performance increase. Therefore it does not make sense to use bigger values, since this may potentially create big gaps in the database primary key sequences in cases like application crashes or restarts.

        Overrides:
        setPkCacheSize in class JdbcPkGenerator