MySQLPkGenerator (cayenne-doc: Cayenne Documentation 5.0-M2 API)
Description: declaration: package: org.apache.cayenne.dba.mysql, class: MySQLPkGenerator

# Class MySQLPkGenerator

java.lang.Object
org.apache.cayenne.dba.JdbcPkGenerator
org.apache.cayenne.dba.mysql.MySQLPkGenerator

All Implemented Interfaces:
  `PkGenerator`

public class MySQLPkGenerator extends JdbcPkGenerator

- ## Field Summary

  ### Fields inherited from class JdbcPkGenerator

  `adapter, DEFAULT_PK_CACHE_SIZE, pkCache, pkCacheSize, pkStartValue`
  Modifier and Type
  Field
  Description
  `protected JdbcAdapter`
  `adapter`
  `static final int`
  `DEFAULT_PK_CACHE_SIZE`
  `protected ConcurrentMap<String, Queue<Long>>`
  `pkCache`
  `protected int`
  `pkCacheSize`
  `protected long`
  `pkStartValue`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MySQLPkGenerator()`
  Used by DI

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected String`
  `dropAutoPkString()`
  `protected long`
  `getLongPrimaryKey(Statement statement, String entityName)`
  `protected long`
  `longPkFromDatabase(DataNode node, DbEntity entity)`
  Overrides superclass's implementation to perform locking of the primary key lookup table.
  `protected String`
  `pkTableCreateString()`
  `protected SQLException`
  `processSQLException(SQLException exception, SQLException parent)`
  Appends a new SQLException to the chain.

  ### Methods inherited from class JdbcPkGenerator

  `autoPkTableExists, createAutoPk, createAutoPkStatements, dropAutoPk, dropAutoPkStatements, generatePk, getAdapter, getPkCacheSize, pkCreateString, pkDeleteString, pkSelectString, pkUpdateString, reset, runUpdate, setAdapter, setPkCacheSize`
  Modifier and Type
  Method
  Description
  `protected boolean`
  `autoPkTableExists(DataNode node)`
  Checks if AUTO_PK_TABLE already exists in the database.
  `void`
  `createAutoPk(DataNode node, List<DbEntity> dbEntities)`
  Generates necessary database objects to provide automatic primary key support.
  `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.
  `void`
  `dropAutoPk(DataNode node, List<DbEntity> dbEntities)`
  Drops table named "AUTO_PK_SUPPORT" if it exists in the database.
  `List<String>`
  `dropAutoPkStatements(List<DbEntity> dbEntities)`
  Returns SQL string needed to drop database objects associated with automatic primary key generation.
  `Object`
  `generatePk(DataNode node, DbAttribute pk)`
  Generates a unique and non-repeating primary key for specified dbEntity.
  `JdbcAdapter`
  `getAdapter()`
  Get an adapter associated with current PkGenerator
  `int`
  `getPkCacheSize()`
  Returns a size of the entity primary key cache.
  `protected String`
  `pkCreateString(String entName)`
  `protected String`
  `pkDeleteString(List<DbEntity> dbEntities)`
  `protected String`
  `pkSelectString(String entName)`
  `protected String`
  `pkUpdateString(String entName)`
  `void`
  `reset()`
  Resets any cached primary keys forcing generator to go to the database next time id generation is requested.
  `int`
  `runUpdate(DataNode node, String sql)`
  Runs JDBC update over a Connection obtained from DataNode.
  `void`
  `setAdapter(DbAdapter adapter)`
  Install the adapter associated with current PkGenerator
  `void`
  `setPkCacheSize(int pkCacheSize)`
  Sets the size of the entity primary key cache.

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### MySQLPkGenerator

    public MySQLPkGenerator()
    Used by DI
    Since:
      4.1

- ## Method Details

  - ### longPkFromDatabase

    protected long longPkFromDatabase(DataNode node, DbEntity entity) throws Exception
    Overrides superclass's implementation to perform locking of the primary key lookup table.
    Overrides:
      `longPkFromDatabase` in class `JdbcPkGenerator`
    Throws:
      `Exception`
    Since:
      3.0

  - ### processSQLException

    protected SQLException processSQLException(SQLException exception, SQLException parent)
    Appends a new SQLException to the chain. If parent is null, uses the exception as the chain root.

  - ### dropAutoPkString

    protected String dropAutoPkString()
    Overrides:
      `dropAutoPkString` in class `JdbcPkGenerator`

  - ### pkTableCreateString

    protected String pkTableCreateString()
    Overrides:
      `pkTableCreateString` in class `JdbcPkGenerator`

  - ### getLongPrimaryKey

    protected long getLongPrimaryKey(Statement statement, String entityName) throws SQLException
    Throws:
      `SQLException`
    Since:
      3.0