Interface PkGenerator

All Known Implementing Classes:
DB2PkGenerator, DerbyPkGenerator, FrontBasePkGenerator, H2PkGenerator, IngresPkGenerator, JdbcPkGenerator, MySQLPkGenerator, OraclePkGenerator, PostgresPkGenerator, SequencePkGenerator, SQLServerPkGenerator, SybasePkGenerator

public interface PkGenerator
Defines methods to support automatic primary key generation.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    createAutoPk(DataNode node, List<DbEntity> dbEntities)
    Generates necessary database objects to provide automatic primary key support.
    Returns a list of SQL strings needed to generates database objects to provide automatic primary support for the list of entities.
    void
    dropAutoPk(DataNode node, List<DbEntity> dbEntities)
    Drops any common database objects associated with automatic primary key generation process.
    Returns SQL string needed to drop database objects associated with automatic primary key generation.
    Generates a unique and non-repeating primary key for the specified PK attribute, as a value of the attribute's JDBC type: a byte array for a binary PK, a Long for a BIGINT, an Integer for any other numeric PK.
    Get an adapter associated with current PkGenerator
    void
    Resets any cached primary keys forcing generator to go to the database next time id generation is requested.
  • Method Details

    • createAutoPk

      void createAutoPk(DataNode node, List<DbEntity> dbEntities)
      Generates necessary database objects to provide automatic primary key support.
      Parameters:
      node - node that provides access to a DataSource.
      dbEntities - a list of entities that require primary key auto-generation support
    • createAutoPkStatements

      List<String> createAutoPkStatements(List<DbEntity> dbEntities)
      Returns a list of SQL strings needed to generates database objects to provide automatic primary support for the list of entities. No actual database operations are performed.
    • dropAutoPk

      void dropAutoPk(DataNode node, List<DbEntity> dbEntities)
      Drops any common database objects associated with automatic primary key generation process. This may be lookup tables, special stored procedures or sequences.
      Parameters:
      node - node that provides access to a DataSource.
      dbEntities - a list of entities whose primary key auto-generation support should be dropped.
    • dropAutoPkStatements

      List<String> dropAutoPkStatements(List<DbEntity> dbEntities)
      Returns SQL string needed to drop database objects associated with automatic primary key generation. No actual database operations are performed.
    • generatePk

      Object generatePk(DataNode dataNode, DbAttribute pk)
      Generates a unique and non-repeating primary key for the specified PK attribute, as a value of the attribute's JDBC type: a byte array for a binary PK, a Long for a BIGINT, an Integer for any other numeric PK. Converting the key to the Java type of a mapped ObjAttribute is up to the caller.
    • getAdapter

      DbAdapter getAdapter()
      Get an adapter associated with current PkGenerator
      Since:
      4.1
    • reset

      void reset()
      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.