|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.unitils.core.dbsupport.DbSupport
public abstract class DbSupport
Helper class that implements a number of common operations on a database schema. Operations that can be implemented using general JDBC or ANSI SQL constructs, are impelemented in this base abstract class. Operations that are DBMS specific are abstract, and their implementation is left to DBMS specific subclasses.
Field Summary | |
---|---|
static String |
PROPKEY_IDENTIFIER_QUOTE_STRING
Property key for the default identifier quote string (empty value for not supported, auto) |
static String |
PROPKEY_STORED_IDENTIFIER_CASE
Property key for the default identifier casing (lower_case, upper_case, mixed_case, auto) |
Constructor Summary | |
---|---|
protected |
DbSupport(String databaseDialect)
Creates a new, unconfigured instance. |
Method Summary | |
---|---|
abstract void |
disableReferentialConstraints()
Disables all referential constraints (e.g. foreign keys) on all table in the schema |
abstract void |
disableValueConstraints()
Disables all value constraints (e.g. not null) on all tables in the schema |
void |
dropMaterializedView(String viewName)
Removes the materialized view with the given name from the database Note: the view name is surrounded with quotes, making it case-sensitive. |
void |
dropSequence(String sequenceName)
Drops the sequence with the given name from the database Note: the sequence name is surrounded with quotes, making it case-sensitive. |
void |
dropSynonym(String synonymName)
Removes the synonym with the given name from the database Note: the synonym name is surrounded with quotes, making it case-sensitive. |
void |
dropTable(String tableName)
Removes the table with the given name from the database. |
void |
dropTrigger(String triggerName)
Drops the trigger with the given name from the database Note: the trigger name is surrounded with quotes, making it case-sensitive. |
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. |
abstract Set<String> |
getColumnNames(String tableName)
Gets the names of all columns of the given table. |
String |
getDatabaseDialect()
Gets the database dialect. |
String |
getIdentifierQuoteString()
Gets the identifier quote string. |
Set<String> |
getIdentityColumnNames(String tableName)
Gets the names of all identity 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. |
String |
getSchemaName()
Gets the schema name. |
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. |
SQLHandler |
getSQLHandler()
Gets the sql handler. |
StoredIdentifierCase |
getStoredIdentifierCase()
Gets the stored identifier case. |
Set<String> |
getSynonymNames()
Retrieves the names of all synonyms in the database schema. |
abstract 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 types in the database schema. |
abstract 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. |
void |
init(Properties configuration,
SQLHandler sqlHandler,
String schemaName)
Initializes this DbSupport object with the given schemaName and dataSource. |
String |
qualified(String databaseObjectName)
Qualifies the given database object name with the name of the database schema. |
String |
quoted(String databaseObjectName)
Put quotes around the given databaseObjectName, if the underlying DBMS supports quoted database object names. |
boolean |
supportsCascade()
Indicates whether the underlying DBMS supports the cascade option for dropping tables and views. |
boolean |
supportsIdentityColumns()
Indicates whether the underlying DBMS supports identity columns |
boolean |
supportsMaterializedViews()
Indicates whether the underlying DBMS supports materialized views |
boolean |
supportsSequences()
Indicates whether the underlying DBMS supports sequences |
boolean |
supportsSynonyms()
Indicates whether the underlying DBMS supports synonyms |
boolean |
supportsTriggers()
Indicates whether the underlying DBMS supports triggers |
boolean |
supportsTypes()
Indicates whether the underlying DBMS supports database types |
String |
toCorrectCaseIdentifier(String identifier)
Converts the given identifier to uppercase/lowercase depending on the DBMS. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String PROPKEY_STORED_IDENTIFIER_CASE
public static final String PROPKEY_IDENTIFIER_QUOTE_STRING
Constructor Detail |
---|
protected DbSupport(String databaseDialect)
init(java.util.Properties, org.unitils.core.dbsupport.SQLHandler, java.lang.String)
method must be
called first.
databaseDialect
- The name of the DBMS implementation that is supported by this implementation, not nullMethod Detail |
---|
public void init(Properties configuration, SQLHandler sqlHandler, String schemaName)
configuration
- The config, not nullsqlHandler
- The sql handler, not nullschemaName
- The name of the database schemapublic String getDatabaseDialect()
public String getSchemaName()
public String getIdentifierQuoteString()
public StoredIdentifierCase getStoredIdentifierCase()
public SQLHandler getSQLHandler()
public abstract Set<String> getTableNames()
public abstract Set<String> getColumnNames(String tableName)
tableName
- The table, not null
public abstract Set<String> getViewNames()
public Set<String> getMaterializedViewNames()
public Set<String> getSynonymNames()
public Set<String> getSequenceNames()
public Set<String> getTriggerNames()
public Set<String> getTypeNames()
public void dropTable(String tableName)
tableName
- The table to drop (case-sensitive), not nullpublic void dropView(String viewName)
viewName
- The view to drop (case-sensitive), not nullpublic void dropMaterializedView(String viewName)
viewName
- The view to drop (case-sensitive), not nullpublic void dropSynonym(String synonymName)
synonymName
- The synonym to drop (case-sensitive), not nullpublic void dropSequence(String sequenceName)
sequenceName
- The sequence to drop (case-sensitive), not nullpublic void dropTrigger(String triggerName)
triggerName
- The trigger to drop (case-sensitive), not nullpublic void dropType(String typeName)
typeName
- The type to drop (case-sensitive), not nullpublic abstract void disableReferentialConstraints()
public abstract void disableValueConstraints()
public long getSequenceValue(String sequenceName)
sequenceName
- The sequence, not null
public void incrementSequenceToValue(String sequenceName, long newSequenceValue)
sequenceName
- The sequence, not nullnewSequenceValue
- The value to setpublic Set<String> getIdentityColumnNames(String tableName)
tableName
- The table, not null
public void incrementIdentityColumnToValue(String tableName, String identityColumnName, long identityValue)
tableName
- The table with the identity column, not nullidentityColumnName
- The column, not nullidentityValue
- The new valuepublic String getLongDataType()
java.lang.Long
type.
public String getTextDataType(int length)
length
- The nr of characters.
public String qualified(String databaseObjectName)
databaseObjectName
- The database object name to be qualified
public String quoted(String databaseObjectName)
databaseObjectName
- The name, not null
public String toCorrectCaseIdentifier(String identifier)
identifier
- The identifier, not null
public boolean supportsSynonyms()
public boolean supportsSequences()
public boolean supportsTriggers()
public boolean supportsTypes()
public boolean supportsIdentityColumns()
public boolean supportsMaterializedViews()
public boolean supportsCascade()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |