org.unitils.core.dbsupport
Class H2DbSupport

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

public class H2DbSupport
extends org.unitils.core.dbsupport.DbSupport

Implementation of DbSupport for a H2 database

Author:
Mark Thomas

Field Summary
 
Fields inherited from class org.unitils.core.dbsupport.DbSupport
PROPKEY_IDENTIFIER_QUOTE_STRING, PROPKEY_STORED_IDENTIFIER_CASE
 
Constructor Summary
H2DbSupport()
          Creates support for H2 databases.
 
Method Summary
protected  void disableCheckAndUniqueConstraints()
          Disables all check and unique constraints on all tables in the schema
protected  void disableNotNullConstraints()
          Disables all not null constraints on all tables in the schema
 void disableReferentialConstraints()
          Disables all referential constraints (e.g. foreign keys) on all tables in the schema
 void disableValueConstraints()
          Disables all value constraints (e.g. not null) on all tables in the schema
 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 primary columns of the given table.
 Set<String> getSequenceNames()
          Retrieves the names of all the sequences in the database schema.
 long getSequenceValue(String sequenceName)
          Returns the value of the sequence with the given name.
 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.
 void incrementSequenceToValue(String sequenceName, long newSequenceValue)
          Sets the next value of the sequence with the given sequence name to the given sequence value.
 boolean supportsCascade()
          Cascade are supported.
 boolean supportsIdentityColumns()
          Identity columns are supported.
 boolean supportsSequences()
          Sequences 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, getSQLHandler, getStoredIdentifierCase, getSynonymNames, getTextDataType, getTypeNames, init, qualified, quoted, supportsMaterializedViews, supportsSynonyms, supportsTypes, toCorrectCaseIdentifier
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

H2DbSupport

public H2DbSupport()
Creates support for H2 databases.

Method Detail

getTableNames

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

Specified by:
getTableNames in class org.unitils.core.dbsupport.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 org.unitils.core.dbsupport.DbSupport
Parameters:
tableName - The table, not null
Returns:
The names of the columns of the table with the given name

getIdentityColumnNames

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

Overrides:
getIdentityColumnNames in class org.unitils.core.dbsupport.DbSupport
Parameters:
tableName - The table, not null
Returns:
The names of the primary key 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 org.unitils.core.dbsupport.DbSupport
Returns:
The names of all views in the database

getSequenceNames

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

Overrides:
getSequenceNames in class org.unitils.core.dbsupport.DbSupport
Returns:
The names of all sequences in the database

getTriggerNames

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

Overrides:
getTriggerNames in class org.unitils.core.dbsupport.DbSupport
Returns:
The names of all triggers in the database

getSequenceValue

public long getSequenceValue(String sequenceName)
Returns the value of the sequence with the given name.

Note: this can have the side-effect of increasing the sequence value.

Overrides:
getSequenceValue in class org.unitils.core.dbsupport.DbSupport
Parameters:
sequenceName - The sequence, not null
Returns:
The value of the sequence with the given name

incrementSequenceToValue

public void incrementSequenceToValue(String sequenceName,
                                     long newSequenceValue)
Sets the next value of the sequence with the given sequence name to the given sequence value.

Overrides:
incrementSequenceToValue in class org.unitils.core.dbsupport.DbSupport
Parameters:
sequenceName - The sequence, not null
newSequenceValue - The value to set

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 org.unitils.core.dbsupport.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 tables in the schema

Specified by:
disableReferentialConstraints in class org.unitils.core.dbsupport.DbSupport

disableValueConstraints

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

Specified by:
disableValueConstraints in class org.unitils.core.dbsupport.DbSupport

disableCheckAndUniqueConstraints

protected void disableCheckAndUniqueConstraints()
Disables all check and unique constraints on all tables in the schema


disableNotNullConstraints

protected void disableNotNullConstraints()
Disables all not null constraints on all tables in the schema


supportsSequences

public boolean supportsSequences()
Sequences are supported.

Overrides:
supportsSequences in class org.unitils.core.dbsupport.DbSupport
Returns:
True

supportsTriggers

public boolean supportsTriggers()
Triggers are supported.

Overrides:
supportsTriggers in class org.unitils.core.dbsupport.DbSupport
Returns:
True

supportsIdentityColumns

public boolean supportsIdentityColumns()
Identity columns are supported.

Overrides:
supportsIdentityColumns in class org.unitils.core.dbsupport.DbSupport
Returns:
True

supportsCascade

public boolean supportsCascade()
Cascade are supported.

Overrides:
supportsCascade in class org.unitils.core.dbsupport.DbSupport
Returns:
True


Copyright © 2010-2013 Henix, henix.fr. All Rights Reserved.