# Class DerbyPkGenerator

java.lang.Object
org.apache.cayenne.dba.JdbcPkGenerator
org.apache.cayenne.dba.SequencePkGenerator
org.apache.cayenne.dba.derby.DerbyPkGenerator

All Implemented Interfaces:
  `PkGenerator`

public class DerbyPkGenerator extends SequencePkGenerator
PK generator for Derby that uses sequences.

Since:
  4.0 (old one used AUTO_PK_SUPPORT table)

- ## Field Summary

  ### Fields inherited from class JdbcPkGenerator

  `adapter, DEFAULT_PK_CACHE_SIZE, pkCache, pkCacheSize, pkStartValue`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DerbyPkGenerator(JdbcAdapter adapter)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected String`
  `createSequenceString(DbEntity entity)`
  `protected String`
  `dropSequenceString(DbEntity entity)`
  Returns a SQL string needed to drop any database objects associated with automatic primary key generation process for a specific DbEntity.
  `protected String`
  `selectAllSequencesQuery()`
  Returns a database-specific query that lists the names of all existing sequences.
  `protected String`
  `selectNextValQuery(String pkGeneratingSequenceName)`
  Returns a database-specific query to fetch the next value of the named sequence.
  `protected String`
  `sequenceName(DbEntity entity)`

  ### Methods inherited from class SequencePkGenerator

  `createAutoPk, createAutoPkStatements, dropAutoPk, dropAutoPkStatements, getExistingSequences, getSequencePrefix, longPkFromDatabase, pkCacheSize`

  ### Methods inherited from class JdbcPkGenerator

  `autoPkTableExists, dropAutoPkString, generatePk, getAdapter, getPkCacheSize, pkCreateString, pkDeleteString, pkSelectString, pkTableCreateString, pkUpdateString, reset, runUpdate, setPkCacheSize`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface PkGenerator

  `generatePk`

- ## Constructor Details

  - ### DerbyPkGenerator

    public DerbyPkGenerator(JdbcAdapter adapter)

- ## Method Details

  - ### sequenceName

    protected String sequenceName(DbEntity entity)
    Overrides:
      `sequenceName` in class `SequencePkGenerator`

  - ### selectNextValQuery

    protected String selectNextValQuery(String pkGeneratingSequenceName)
    Description copied from class: `SequencePkGenerator`
    Returns a database-specific query to fetch the next value of the named sequence.
    Specified by:
      `selectNextValQuery` in class `SequencePkGenerator`

  - ### selectAllSequencesQuery

    protected String selectAllSequencesQuery()
    Description copied from class: `SequencePkGenerator`
    Returns a database-specific query that lists the names of all existing sequences.
    Specified by:
      `selectAllSequencesQuery` in class `SequencePkGenerator`

  - ### dropSequenceString

    protected String dropSequenceString(DbEntity entity)
    Description copied from class: `SequencePkGenerator`
    Returns a SQL string needed to drop any database objects associated with automatic primary key generation process for a specific DbEntity.
    Overrides:
      `dropSequenceString` in class `SequencePkGenerator`

  - ### createSequenceString

    protected String createSequenceString(DbEntity entity)
    Overrides:
      `createSequenceString` in class `SequencePkGenerator`