org.unitils.core.dbsupport
Class DerbyDbSupport

java.lang.Object
  extended by org.unitils.core.dbsupport.DbSupport
      extended by org.unitils.core.dbsupport.DerbyDbSupport

public class DerbyDbSupport
extends DbSupport

Implementation of DbSupport for a Derby database.

Special thanks to Scott Prater who donated the initial version of the Derby support code.

Author:
Scott Prater, Tim Ducheyne, Filip Neven

Field Summary
 
Fields inherited from class org.unitils.core.dbsupport.DbSupport
PROPKEY_IDENTIFIER_QUOTE_STRING, PROPKEY_STORED_IDENTIFIER_CASE
 
Constructor Summary
DerbyDbSupport()
          Creates support for Derby databases.
 
Method Summary
 void disableReferentialConstraints()
          Disables all referential constraints (e.g. foreign keys) on all table in the schema
protected  void disableReferentialConstraints(String tableName)
           
 void disableValueConstraints()
          Disables all value constraints (e.g. not null) on all tables in the schema
protected  void disableValueConstraints(String tableName)
           
 Set<String> getColumnNames(String tableName)
          Gets the names of all columns of the given table.
 Set<String> getIdentityColumnNames(String tableName)
          Gets the names of all identity columns of the given table.
protected  Set<String> getNotNullColummnNames(String tableName)
          Returns the names of all columns that have a 'not-null' constraint on them.
protected  Set<String> getPrimaryKeyColumnNames(String tableName)
          Gets the names of all primary columns of the given table.
 Set<String> getSynonymNames()
          Retrieves the names of all the synonyms in the database schema.
 Set<String> getTableNames()
          Returns the names of all tables in the database.
 Set<String> getTriggerNames()
          Retrieves the names of all the triggers in the database schema.
 Set<String> getViewNames()
          Retrieves the names of all the views in the database schema.
 void incrementIdentityColumnToValue(String tableName, String identityColumnName, long identityValue)
          Increments the identity value for the specified identity column on the specified table to the given value.
 boolean supportsIdentityColumns()
          Identity columns are supported.
 boolean supportsSynonyms()
          Synonyms are supported.
 boolean supportsTriggers()
          Triggers are supported.
 
Methods inherited from class org.unitils.core.dbsupport.DbSupport
dropMaterializedView, dropSequence, dropSynonym, dropTable, dropTrigger, dropType, dropView, getDatabaseDialect, getIdentifierQuoteString, getLongDataType, getMaterializedViewNames, getSchemaName, getSequenceNames, getSequenceValue, getSQLHandler, getStoredIdentifierCase, getTextDataType, getTypeNames, incrementSequenceToValue, init, qualified, quoted, supportsCascade, supportsMaterializedViews, supportsSequences, supportsTypes, toCorrectCaseIdentifier
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DerbyDbSupport

public DerbyDbSupport()
Creates support for Derby databases.

Method Detail

getTableNames

public Set<String> getTableNames()
Returns the names of all tables in the database.

Specified by:
getTableNames in class DbSupport
Returns:
The names of all tables in the database

getColumnNames

public Set<String> getColumnNames(String tableName)
Gets the names of all columns of the given table.

Specified by:
getColumnNames in class DbSupport
Parameters:
tableName - The table, not null
Returns:
The names of the columns of the table with the given name

getViewNames

public Set<String> getViewNames()
Retrieves the names of all the views in the database schema.

Specified by:
getViewNames in class DbSupport
Returns:
The names of all views in the database

getSynonymNames

public Set<String> getSynonymNames()
Retrieves the names of all the synonyms in the database schema.

Overrides:
getSynonymNames in class DbSupport
Returns:
The names of all synonyms in the database

getTriggerNames

public Set<String> getTriggerNames()
Retrieves the names of all the triggers in the database schema.

Overrides:
getTriggerNames in class DbSupport
Returns:
The names of all triggers in the database

getIdentityColumnNames

public Set<String> getIdentityColumnNames(String tableName)
Gets the names of all identity columns of the given table.

todo check, at this moment the PK columns are returned

Overrides:
getIdentityColumnNames in class DbSupport
Parameters:
tableName - The table, not null
Returns:
The names of the identity columns of the table with the given name

incrementIdentityColumnToValue

public void incrementIdentityColumnToValue(String tableName,
                                           String identityColumnName,
                                           long identityValue)
Increments the identity value for the specified identity column on the specified table to the given value.

Overrides:
incrementIdentityColumnToValue in class DbSupport
Parameters:
tableName - The table with the identity column, not null
identityColumnName - The column, not null
identityValue - The new value

disableReferentialConstraints

public void disableReferentialConstraints()
Disables all referential constraints (e.g. foreign keys) on all table in the schema

Specified by:
disableReferentialConstraints in class DbSupport

disableReferentialConstraints

protected void disableReferentialConstraints(String tableName)

disableValueConstraints

public void disableValueConstraints()
Disables all value constraints (e.g. not null) on all tables in the schema

Specified by:
disableValueConstraints in class DbSupport

disableValueConstraints

protected void disableValueConstraints(String tableName)

supportsSynonyms

public boolean supportsSynonyms()
Synonyms are supported.

Overrides:
supportsSynonyms in class DbSupport
Returns:
True

supportsTriggers

public boolean supportsTriggers()
Triggers are supported.

Overrides:
supportsTriggers in class DbSupport
Returns:
True

supportsIdentityColumns

public boolean supportsIdentityColumns()
Identity columns are supported.

Overrides:
supportsIdentityColumns in class DbSupport
Returns:
True

getPrimaryKeyColumnNames

protected Set<String> getPrimaryKeyColumnNames(String tableName)
Gets the names of all primary columns of the given table.

This info is not available in the Derby sys tables. The database meta data is used instead to retrieve it.

Parameters:
tableName - The table, not null
Returns:
The names of the primary key columns of the table with the given name

getNotNullColummnNames

protected Set<String> getNotNullColummnNames(String tableName)
Returns the names of all columns that have a 'not-null' constraint on them.

This info is not available in the Derby sys tables. The database meta data is used instead to retrieve it.

Parameters:
tableName - The table, not null
Returns:
The set of column names, not null


Copyright © 2011. All Rights Reserved.