Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cayenne.dba.db2
Class DB2PkGenerator

    java.lang.Object
      org.apache.cayenne.dba.JdbcPkGenerator
          org.apache.cayenne.dba.db2.DB2PkGenerator

All Implemented Interfaces:
  PkGenerator

    public class DB2PkGenerator

extends JdbcPkGenerator

A sequence-based PK generator used by `DB2Adapter`.

Field Summary

Fields inherited from class org.apache.cayenne.dba.JdbcPkGenerator
`adapter, DEFAULT_PK_CACHE_SIZE, pkCache, pkCacheSize`

Method Summary
`void` | `createAutoPk(DataNode node, java.util.List<DbEntity> dbEntities)` Generates necessary database objects to provide automatic primary key support.
`java.util.List<java.lang.String>` | `createAutoPkStatements(java.util.List<DbEntity> dbEntities)` Creates a list of CREATE SEQUENCE statements for the list of DbEntities.
`protected java.lang.String` | `createSequenceString(DbEntity entity)` Returns CREATE SEQUENCE statement for entity.
`void` | `dropAutoPk(DataNode node, java.util.List<DbEntity> dbEntities)` Drops PK sequences for all specified DbEntities.
`java.util.List<java.lang.String>` | `dropAutoPkStatements(java.util.List<DbEntity> dbEntities)` Creates a list of DROP SEQUENCE statements for the list of DbEntities.
`protected java.lang.String` | `dropSequenceString(DbEntity entity)` Returns DROP SEQUENCE statement.
`protected java.util.List<java.lang.String>` | `getExistingSequences(DataNode node)` Fetches a list of existing sequences that might match Cayenne generated ones.
`protected long` | `longPkFromDatabase(DataNode node, DbEntity entity)` Performs primary key generation ignoring cache.
`protected java.lang.String` | `sequenceName(DbEntity entity)` Returns default sequence name for DbEntity.

Methods inherited from class org.apache.cayenne.dba.JdbcPkGenerator
`autoPkTableExists, dropAutoPkString, generatePk, getAdapter, getPkCacheSize, pkCreateString, pkDeleteString, pkSelectString, pkTableCreateString, pkUpdateString, reset, runUpdate, setPkCacheSize`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### longPkFromDatabase

    protected long longPkFromDatabase(DataNode node,
                                      DbEntity entity)
                               throws java.lang.Exception

  Description copied from class: `JdbcPkGenerator`
  Performs primary key generation ignoring cache. Generates a range of primary keys as specified by "pkCacheSize" bean property.

  This method is called internally from "generatePkForDbEntity" and then generated range of key values is saved in cache for performance. Subclasses that implement different primary key generation solutions should override this method, not "generatePkForDbEntity".

  Overrides:
    `longPkFromDatabase` in class `JdbcPkGenerator`
  Throws:
    `java.lang.Exception`
  Since:
    3.0

### createAutoPk

    public void createAutoPk(DataNode node,
                             java.util.List<DbEntity> dbEntities)
                      throws java.lang.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:
    `java.lang.Exception`

### createAutoPkStatements

    public java.util.List<java.lang.String> createAutoPkStatements(java.util.List<DbEntity> dbEntities)

  Creates a list of CREATE SEQUENCE statements for the list of DbEntities.

  Specified by:
    `createAutoPkStatements` in interface `PkGenerator`
  Overrides:
    `createAutoPkStatements` in class `JdbcPkGenerator`

### dropAutoPk

    public void dropAutoPk(DataNode node,
                           java.util.List<DbEntity> dbEntities)
                    throws java.lang.Exception

  Drops PK sequences for all specified DbEntities.

  Specified by:
    `dropAutoPk` in interface `PkGenerator`
  Overrides:
    `dropAutoPk` in class `JdbcPkGenerator`
  Parameters:
    `node` - node that provides access to a DataSource.
    `dbEntities` - a list of entities whose primary key auto-generation support should be dropped.
  Throws:
    `java.lang.Exception`

### dropAutoPkStatements

    public java.util.List<java.lang.String> dropAutoPkStatements(java.util.List<DbEntity> dbEntities)

  Creates a list of DROP SEQUENCE statements for the list of DbEntities.

  Specified by:
    `dropAutoPkStatements` in interface `PkGenerator`
  Overrides:
    `dropAutoPkStatements` in class `JdbcPkGenerator`

### getExistingSequences

    protected java.util.List<java.lang.String> getExistingSequences(DataNode node)
                                                             throws java.sql.SQLException

  Fetches a list of existing sequences that might match Cayenne generated ones.

  Throws:
    `java.sql.SQLException`

### sequenceName

    protected java.lang.String sequenceName(DbEntity entity)

  Returns default sequence name for DbEntity.

### dropSequenceString

    protected java.lang.String dropSequenceString(DbEntity entity)

  Returns DROP SEQUENCE statement.

### createSequenceString

    protected java.lang.String createSequenceString(DbEntity entity)

  Returns CREATE SEQUENCE statement for entity.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2011 Apache Cayenne. All Rights Reserved.