org.dbmaintain.database.impl
Class HsqldbDatabase

java.lang.Object
  extended by org.dbmaintain.database.Database
      extended by org.dbmaintain.database.impl.HsqldbDatabase

public class HsqldbDatabase
extends Database

Implementation of Database for a hsqldb database

Author:
Filip Neven, Tim Ducheyne, Faisal Feroz

Field Summary
 
Fields inherited from class org.dbmaintain.database.Database
databaseConnection, identifierProcessor, schemaNames
 
Constructor Summary
HsqldbDatabase(DatabaseConnection databaseConnection, IdentifierProcessor identifierProcessor)
           
 
Method Summary
protected  void disableCheckAndUniqueConstraints(String schemaName)
          Disables all check and unique constraints on all tables in the schema
protected  void disableNotNullConstraints(String schemaName)
          Disables all not null constraints on all tables in the schema
 void disableReferentialConstraints(String schemaName)
          Disables all referential constraints (e.g. foreign keys) on all table in the schema
 void disableValueConstraints(String schemaName)
          Disables all value constraints (e.g. not null) on all tables in the schema
 Set<String> getColumnNames(String schemaName, String tableName)
          Gets the names of all columns of the given table.
protected  Integer getHsqldbMajorVersionNumber()
           
 Set<String> getIdentityColumnNames(String schemaName, String tableName)
          Gets the names of all identity columns of the given table.
 Set<String> getSequenceNames(String schemaName)
          Retrieves the names of all the sequences in the database schema.
 long getSequenceValue(String schemaName, String sequenceName)
          Returns the value of the sequence with the given name.
 String getSupportedDatabaseDialect()
           
 Set<String> getTableNames(String schemaName)
          Returns the names of all tables in the database.
 Set<String> getTriggerNames(String schemaName)
          Retrieves the names of all the triggers in the database schema.
 Set<String> getViewNames(String schemaName)
          Retrieves the names of all the views in the database schema.
 void incrementIdentityColumnToValue(String schemaName, 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 schemaName, String sequenceName, long newSequenceValue)
          Sets the next value of the sequence with the given sequence name to the given sequence value.
 void setDatabaseDefaultSchema()
          Sets the current schema of the database.
 void setSettingIdentityColumnValueEnabled(String schemaName, String tableName, boolean enabled)
          Enables or disables the setting of identity value in insert and update statements.
 boolean supportsCascade()
          Cascade are supported.
 boolean supportsIdentityColumns()
          Identity columns are supported.
 boolean supportsSequences()
          Sequences are supported.
 boolean supportsSetDatabaseDefaultSchema()
          Setting the default schema is supported.
 boolean supportsTriggers()
          Triggers are supported.
 
Methods inherited from class org.dbmaintain.database.Database
disableReferentialConstraints, disableValueConstraints, dropMaterializedView, dropMaterializedView, dropRule, dropSequence, dropSequence, dropStoredProcedure, dropStoredProcedure, dropSynonym, dropSynonym, dropTable, dropTable, dropTrigger, dropTrigger, dropType, dropType, dropView, dropView, getColumnNames, getDatabaseInfo, getDatabaseName, getDataSource, getDefaultSchemaName, getIdentifierQuoteString, getIdentityColumnNames, getLongDataType, getMaterializedViewNames, getMaterializedViewNames, getRuleNames, getSchemaNames, getSequenceNames, getSequenceValue, getSQLHandler, getStoredIdentifierCase, getStoredProcedureNames, getStoredProcedureNames, getSynonymNames, getSynonymNames, getTableNames, getTextDataType, getTriggerNames, getTypeNames, getTypeNames, getViewNames, incrementIdentityColumnToValue, incrementSequenceToValue, isQuoted, qualified, qualified, quoted, removeIdentifierQuotes, setSettingIdentityColumnValueEnabled, supportsMaterializedViews, supportsRules, supportsStoredProcedures, supportsSynonyms, supportsTypes, toCorrectCaseIdentifier
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HsqldbDatabase

public HsqldbDatabase(DatabaseConnection databaseConnection,
                      IdentifierProcessor identifierProcessor)
Method Detail

getSupportedDatabaseDialect

public String getSupportedDatabaseDialect()
Specified by:
getSupportedDatabaseDialect in class Database
Returns:
the database dialect supported by this db support class, not null

getTableNames

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

Specified by:
getTableNames in class Database
Parameters:
schemaName - The schema, not null
Returns:
The names of all tables in the database

getColumnNames

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

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

getViewNames

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

Specified by:
getViewNames in class Database
Parameters:
schemaName - The schema, not null
Returns:
The names of all views in the database

getSequenceNames

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

Overrides:
getSequenceNames in class Database
Parameters:
schemaName - The schema, not null
Returns:
The names of all sequences in the database

getTriggerNames

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

Overrides:
getTriggerNames in class Database
Parameters:
schemaName - The schema, not null
Returns:
The names of all triggers in the database

disableReferentialConstraints

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

Specified by:
disableReferentialConstraints in class Database
Parameters:
schemaName - The schema name, not null

disableValueConstraints

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

Specified by:
disableValueConstraints in class Database
Parameters:
schemaName - The schema name, not null

disableCheckAndUniqueConstraints

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

Parameters:
schemaName - The schema name, not null

disableNotNullConstraints

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

Parameters:
schemaName - The schema name, not null

getSequenceValue

public long getSequenceValue(String schemaName,
                             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 Database
Parameters:
sequenceName - The sequence, not null
schemaName - The schema, not null
Returns:
The value of the sequence with the given name

incrementSequenceToValue

public void incrementSequenceToValue(String schemaName,
                                     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 Database
Parameters:
sequenceName - The sequence, not null
newSequenceValue - The value to set
schemaName - The schema, not null

getIdentityColumnNames

public Set<String> getIdentityColumnNames(String schemaName,
                                          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 Database
Parameters:
tableName - The table, not null
schemaName - The schema, not null
Returns:
The names of the identity columns of the table with the given name

incrementIdentityColumnToValue

public void incrementIdentityColumnToValue(String schemaName,
                                           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 Database
Parameters:
tableName - The table with the identity column, not null
identityColumnName - The column, not null
identityValue - The new value
schemaName - The schema, not null

setDatabaseDefaultSchema

public void setDatabaseDefaultSchema()
Sets the current schema of the database. If a current schema is set, it does not need to be specified explicitly in the scripts.

Overrides:
setDatabaseDefaultSchema in class Database

setSettingIdentityColumnValueEnabled

public void setSettingIdentityColumnValueEnabled(String schemaName,
                                                 String tableName,
                                                 boolean enabled)
Enables or disables the setting of identity value in insert and update statements. By default some databases do not allow to set values of identity columns directly from insert/update statements. If supported, this method will enable/disable this behavior.

Overrides:
setSettingIdentityColumnValueEnabled in class Database
Parameters:
schemaName - The schema name, not null
tableName - The table with the identity column, not null
enabled - True to enable, false to disable

supportsSequences

public boolean supportsSequences()
Sequences are supported.

Overrides:
supportsSequences in class Database
Returns:
True

supportsTriggers

public boolean supportsTriggers()
Triggers are supported.

Overrides:
supportsTriggers in class Database
Returns:
True

supportsIdentityColumns

public boolean supportsIdentityColumns()
Identity columns are supported.

Overrides:
supportsIdentityColumns in class Database
Returns:
True

supportsCascade

public boolean supportsCascade()
Cascade are supported.

Overrides:
supportsCascade in class Database
Returns:
True

supportsSetDatabaseDefaultSchema

public boolean supportsSetDatabaseDefaultSchema()
Setting the default schema is supported.

Overrides:
supportsSetDatabaseDefaultSchema in class Database
Returns:
True

getHsqldbMajorVersionNumber

protected Integer getHsqldbMajorVersionNumber()
Returns:
The major version number of the Hsql database server that is used (e.g. for Hsql version 1.8.0, 1 is returned


Copyright © 2011. All Rights Reserved.