org.apache.cayenne.dba.db2
Class DB2PkGenerator

java.lang.Object
  extended by org.apache.cayenne.dba.JdbcPkGenerator
      extended by org.apache.cayenne.dba.db2.DB2PkGenerator
All Implemented Interfaces:
PkGenerator

public class DB2PkGenerator
extends JdbcPkGenerator

PK Generator for IBM DB2 using sequences.

Author:
Mario Linke, Holger Hoffstaette

Field Summary
static java.lang.String SEQUENCE_PREFIX
           
 
Fields inherited from class org.apache.cayenne.dba.JdbcPkGenerator
DEFAULT_PK_CACHE_SIZE, NEXT_ID, objDesc, pkCache, pkCacheSize, resultDesc
 
Constructor Summary
DB2PkGenerator()
           
 
Method Summary
 void createAutoPk(DataNode node, java.util.List dbEntities)
          Generates necessary database objects to provide automatic primary key support.
 java.util.List createAutoPkStatements(java.util.List dbEntities)
          Returns a list of SQL strings needed to generates database objects to provide automatic primary support for the list of entities.
protected  java.lang.String createSequenceString(DbEntity ent)
          Creates SQL needed for creating a sequence.
 void dropAutoPk(DataNode node, java.util.List dbEntities)
          Drops table named "AUTO_PK_SUPPORT" if it exists in the database.
 java.util.List dropAutoPkStatements(java.util.List dbEntities)
          Returns SQL string needed to drop database objects associated with automatic primary key generation.
protected  java.lang.String dropSequenceString(DbEntity ent)
          Creates SQL needed for dropping a sequence.
protected  java.util.List getExistingSequences(DataNode node)
          Returns a List of all existing, accessible sequences.
protected  int pkFromDatabase(DataNode node, DbEntity ent)
          Creates a new PK from a sequence returned by SELECT NEXTVAL FOR sequence_name FROM SYSIBM.SYSDUMMY1 SYSIBM.SYSDUMMY1 corresponds to DUAL in Oracle.
protected  java.lang.String sequenceName(DbEntity ent)
          Returns the sequence name for a given table name.
 
Methods inherited from class org.apache.cayenne.dba.JdbcPkGenerator
autoPkTableExists, binaryPK, dropAutoPkString, generatePkForDbEntity, generatePkForDbEntityString, 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
 

Field Detail

SEQUENCE_PREFIX

public static final java.lang.String SEQUENCE_PREFIX
See Also:
Constant Field Values
Constructor Detail

DB2PkGenerator

public DB2PkGenerator()
Method Detail

createAutoPk

public void createAutoPk(DataNode node,
                         java.util.List 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 autogeneration support
Throws:
java.lang.Exception

createAutoPkStatements

public java.util.List createAutoPkStatements(java.util.List dbEntities)
Description copied from interface: PkGenerator
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.

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

dropAutoPk

public void dropAutoPk(DataNode node,
                       java.util.List dbEntities)
                throws java.lang.Exception
Description copied from class: JdbcPkGenerator
Drops table named "AUTO_PK_SUPPORT" if it exists in the database.

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 autogeneration support should be dropped.
Throws:
java.lang.Exception

dropAutoPkStatements

public java.util.List dropAutoPkStatements(java.util.List dbEntities)
Description copied from interface: PkGenerator
Returns SQL string needed to drop database objects associated with automatic primary key generation. No actual database operations are performed.

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

sequenceName

protected java.lang.String sequenceName(DbEntity ent)
Returns the sequence name for a given table name.


createSequenceString

protected java.lang.String createSequenceString(DbEntity ent)
Creates SQL needed for creating a sequence.


dropSequenceString

protected java.lang.String dropSequenceString(DbEntity ent)
Creates SQL needed for dropping a sequence.


pkFromDatabase

protected int pkFromDatabase(DataNode node,
                             DbEntity ent)
                      throws java.lang.Exception
Creates a new PK from a sequence returned by SELECT NEXTVAL FOR sequence_name FROM SYSIBM.SYSDUMMY1 SYSIBM.SYSDUMMY1 corresponds to DUAL in Oracle.

Overrides:
pkFromDatabase in class JdbcPkGenerator
Throws:
java.lang.Exception

getExistingSequences

protected java.util.List getExistingSequences(DataNode node)
                                       throws java.sql.SQLException
Returns a List of all existing, accessible sequences.

Throws:
java.sql.SQLException


Copyright © 2001-2006 Apache.org All Rights Reserved.