org.unitils.core.dbsupport
Class OracleDbSupport

java.lang.Object
  extended by org.unitils.core.dbsupport.DbSupport
      extended by org.unitils.core.dbsupport.OracleDbSupport
Direct Known Subclasses:
Oracle10DbSupport, Oracle9DbSupport

public class OracleDbSupport
extends DbSupport

Implementation of DbSupport for an Oracle database.

Author:
Filip Neven, Tim Ducheyne

Field Summary
 
Fields inherited from class org.unitils.core.dbsupport.DbSupport
PROPKEY_IDENTIFIER_QUOTE_STRING, PROPKEY_STORED_IDENTIFIER_CASE
 
Constructor Summary
OracleDbSupport()
          Creates support for Oracle databases.
 
Method Summary
 void disableReferentialConstraints()
          Disables all referential constraints (e.g. foreign keys) on all table in the schema
 void disableValueConstraints()
          Disables all value constraints (e.g. not null) on all tables in the schema
 void dropMaterializedView(String materializedViewName)
          Removes the materialized view with the given name from the database Note: the view name is surrounded with quotes, making it case-sensitive.
 void dropTable(String tableName)
          Removes the table with the given name from the database.
 void dropType(String typeName)
          Drops the type with the given name from the database Note: the type name is surrounded with quotes, making it case-sensitive.
 void dropView(String viewName)
          Removes the view with the given name from the database Note: the view name is surrounded with quotes, making it case-sensitive.
 Set<String> getColumnNames(String tableName)
          Gets the names of all columns of the given table.
 String getLongDataType()
          Gets the column type suitable to store values of the Java java.lang.Long type.
 Set<String> getMaterializedViewNames()
          Retrieves the names of all materialized views in the database schema.
protected  Integer getOracleMajorVersionNumber()
           
 Set<String> getSequenceNames()
          Retrieves the names of all sequences in the database schema.
 long getSequenceValue(String sequenceName)
          Returns the value of the sequence with the given name.
 Set<String> getSynonymNames()
          Retrieves the names of all synonyms in the database schema.
 Set<String> getTableNames()
          Returns the names of all tables in the database.
 String getTextDataType(int length)
          Gets the column type suitable to store text values.
 Set<String> getTriggerNames()
          Retrieves the names of all triggers in the database schema.
 Set<String> getTypeNames()
          Retrieves the names of all the types in the database schema.
 Set<String> getViewNames()
          Retrieves the names of all views in the database schema.
 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 supportsMaterializedViews()
          Materialized views are supported
protected  boolean supportsPurge()
           
 boolean supportsSequences()
          Sequences are supported.
 boolean supportsSynonyms()
          Synonyms are supported
 boolean supportsTriggers()
          Triggers are supported.
 boolean supportsTypes()
          Types are supported
 
Methods inherited from class org.unitils.core.dbsupport.DbSupport
dropSequence, dropSynonym, dropTrigger, getDatabaseDialect, getIdentifierQuoteString, getIdentityColumnNames, getSchemaName, getSQLHandler, getStoredIdentifierCase, incrementIdentityColumnToValue, init, qualified, quoted, supportsIdentityColumns, toCorrectCaseIdentifier
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OracleDbSupport

public OracleDbSupport()
Creates support for Oracle 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 views in the database schema.

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

getMaterializedViewNames

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

Overrides:
getMaterializedViewNames in class DbSupport
Returns:
The names of all materialized views in the database

getSynonymNames

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

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

getSequenceNames

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

Overrides:
getSequenceNames in class DbSupport
Returns:
The names of all sequences in the database

getTriggerNames

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

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

getTypeNames

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

Overrides:
getTypeNames in class DbSupport
Returns:
The names of all types in the database

dropTable

public void dropTable(String tableName)
Removes the table with the given name from the database. Note: the table name is surrounded with quotes, making it case-sensitive.

Overrides:
dropTable in class DbSupport
Parameters:
tableName - The table to drop (case-sensitive), not null

dropView

public void dropView(String viewName)
Removes the view with the given name from the database Note: the view name is surrounded with quotes, making it case-sensitive.

Overrides:
dropView in class DbSupport
Parameters:
viewName - The view to drop (case-sensitive), not null

dropMaterializedView

public void dropMaterializedView(String materializedViewName)
Removes the materialized view with the given name from the database Note: the view name is surrounded with quotes, making it case-sensitive.

Overrides:
dropMaterializedView in class DbSupport
Parameters:
materializedViewName - The view to drop (case-sensitive), not null

dropType

public void dropType(String typeName)
Drops the type with the given name from the database Note: the type name is surrounded with quotes, making it case-sensitive.

Overriden to add the force option. This will make sure that super-types can also be dropped.

Overrides:
dropType in class DbSupport
Parameters:
typeName - The type to drop (case-sensitive), not null

disableReferentialConstraints

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

Specified by:
disableReferentialConstraints in class DbSupport

disableValueConstraints

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

Specified by:
disableValueConstraints in class DbSupport

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 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 DbSupport
Parameters:
sequenceName - The sequence, not null
newSequenceValue - The value to set

getLongDataType

public String getLongDataType()
Gets the column type suitable to store values of the Java java.lang.Long type.

Overrides:
getLongDataType in class DbSupport
Returns:
The column type

getTextDataType

public String getTextDataType(int length)
Gets the column type suitable to store text values.

Overrides:
getTextDataType in class DbSupport
Parameters:
length - The nr of characters.
Returns:
The column type, not null

supportsSynonyms

public boolean supportsSynonyms()
Synonyms are supported

Overrides:
supportsSynonyms in class DbSupport
Returns:
True

supportsSequences

public boolean supportsSequences()
Sequences are supported.

Overrides:
supportsSequences in class DbSupport
Returns:
True

supportsTriggers

public boolean supportsTriggers()
Triggers are supported.

Overrides:
supportsTriggers in class DbSupport
Returns:
True

supportsTypes

public boolean supportsTypes()
Types are supported

Overrides:
supportsTypes in class DbSupport
Returns:
true

supportsMaterializedViews

public boolean supportsMaterializedViews()
Materialized views are supported

Overrides:
supportsMaterializedViews in class DbSupport
Returns:
true

supportsCascade

public boolean supportsCascade()
Cascade are supported.

Overrides:
supportsCascade in class DbSupport
Returns:
True

supportsPurge

protected boolean supportsPurge()
Returns:
Whether or not this version of the Oracle database that is used supports the purge keyword. This is, whether or not an Oracle database of version 10 or higher is used.

getOracleMajorVersionNumber

protected Integer getOracleMajorVersionNumber()
Returns:
The major version number of the Oracle database server that is used (e.g. for Oracle version 9.2.0.1, 9 is returned


Copyright © 2011. All Rights Reserved.