org.springframework.jdbc.core.metadata
Class GenericTableMetaDataProvider

java.lang.Object
  extended by org.springframework.jdbc.core.metadata.GenericTableMetaDataProvider
All Implemented Interfaces:
TableMetaDataProvider
Direct Known Subclasses:
DerbyTableMetaDataProvider, HsqlTableMetaDataProvider, OracleTableMetaDataProvider, PostgresTableMetaDataProvider

public class GenericTableMetaDataProvider
extends Object
implements TableMetaDataProvider

A generic implementation of the TableMetaDataProvider that should provide enough features for all supported databases.

Since:
2.5
Author:
Thomas Risberg

Field Summary
protected static Log logger
          Logger available to subclasses
 
Constructor Summary
protected GenericTableMetaDataProvider(DatabaseMetaData databaseMetaData)
          Constructor used to initialize with provided database meta data.
 
Method Summary
 String catalogNameToUse(String catalogName)
          Get the catalog name formatted based on metadata information.
protected  String getDatabaseVersion()
          Provide access to version info for subclasses.
protected  String getDefaultSchema()
          Provide access to default schema for subclasses.
protected  NativeJdbcExtractor getNativeJdbcExtractor()
           
 String getSimpleQueryForGetGeneratedKey(String tableName, String keyColumnName)
          Get the simple query to retrieve a generated key
 List<TableParameterMetaData> getTableParameterMetaData()
          Get the table parameter metadata that is currently used.
 void initializeWithMetaData(DatabaseMetaData databaseMetaData)
          Initialize using the database metedata provided
 void initializeWithTableColumnMetaData(DatabaseMetaData databaseMetaData, String catalogName, String schemaName, String tableName)
          Initialize using provided database metadata, table and column information.
 boolean isGeneratedKeysColumnNameArraySupported()
          Does this database support a column name String array for retreiving generated keys Connection.createStruct(String, Object[])
 boolean isGetGeneratedKeysSimulated()
          Does this database support a simple quey to retrieve the generated key whe the JDBC 3.0 feature of retreiving generated keys is not supported DatabaseMetaData.supportsGetGeneratedKeys()
 boolean isGetGeneratedKeysSupported()
          Does this database support the JDBC 3.0 feature of retreiving generated keys DatabaseMetaData.supportsGetGeneratedKeys()
 boolean isStoresLowerCaseIdentifiers()
          Get whether identifiers use lower case
 boolean isStoresUpperCaseIdentifiers()
          Get whether identifiers use upper case
 boolean isTableColumnMetaDataUsed()
          Are we using the meta data for the table columns?
 String metaDataCatalogNameToUse(String catalogName)
          Provide any modification of the catalog name passed in to match the meta data currently used.
 String metaDataSchemaNameToUse(String schemaName)
          Provide any modification of the schema name passed in to match the meta data currently used.
 String schemaNameToUse(String schemaName)
          Get the schema name formatted based on metadata information.
 void setGeneratedKeysColumnNameArraySupported(boolean generatedKeysColumnNameArraySupported)
          Specify whether a column name array is supported for generated keys
 void setGetGeneratedKeysSupported(boolean getGeneratedKeysSupported)
          Specify whether a column name array is supported for generated keys
 void setNativeJdbcExtractor(NativeJdbcExtractor nativeJdbcExtractor)
          Set the NativeJdbcExtractor to use to retrieve the native connection if necessary
 void setStoresLowerCaseIdentifiers(boolean storesLowerCaseIdentifiers)
          Specify whether identifiers use lower case.
 void setStoresUpperCaseIdentifiers(boolean storesUpperCaseIdentifiers)
          Specify whether identifiers use upper case
 String tableNameToUse(String tableName)
          Get the table name formatted based on metadata information.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final Log logger
Logger available to subclasses

Constructor Detail

GenericTableMetaDataProvider

protected GenericTableMetaDataProvider(DatabaseMetaData databaseMetaData)
                                throws SQLException
Constructor used to initialize with provided database meta data.

Parameters:
databaseMetaData - meta data to be used
Throws:
SQLException
Method Detail

setStoresUpperCaseIdentifiers

public void setStoresUpperCaseIdentifiers(boolean storesUpperCaseIdentifiers)
Specify whether identifiers use upper case


isStoresUpperCaseIdentifiers

public boolean isStoresUpperCaseIdentifiers()
Get whether identifiers use upper case


setStoresLowerCaseIdentifiers

public void setStoresLowerCaseIdentifiers(boolean storesLowerCaseIdentifiers)
Specify whether identifiers use lower case.


isStoresLowerCaseIdentifiers

public boolean isStoresLowerCaseIdentifiers()
Get whether identifiers use lower case


isTableColumnMetaDataUsed

public boolean isTableColumnMetaDataUsed()
Description copied from interface: TableMetaDataProvider
Are we using the meta data for the table columns?

Specified by:
isTableColumnMetaDataUsed in interface TableMetaDataProvider

getTableParameterMetaData

public List<TableParameterMetaData> getTableParameterMetaData()
Description copied from interface: TableMetaDataProvider
Get the table parameter metadata that is currently used.

Specified by:
getTableParameterMetaData in interface TableMetaDataProvider
Returns:
List of TableParameterMetaData

isGetGeneratedKeysSupported

public boolean isGetGeneratedKeysSupported()
Description copied from interface: TableMetaDataProvider
Does this database support the JDBC 3.0 feature of retreiving generated keys DatabaseMetaData.supportsGetGeneratedKeys()

Specified by:
isGetGeneratedKeysSupported in interface TableMetaDataProvider

isGetGeneratedKeysSimulated

public boolean isGetGeneratedKeysSimulated()
Description copied from interface: TableMetaDataProvider
Does this database support a simple quey to retrieve the generated key whe the JDBC 3.0 feature of retreiving generated keys is not supported DatabaseMetaData.supportsGetGeneratedKeys()

Specified by:
isGetGeneratedKeysSimulated in interface TableMetaDataProvider

getSimpleQueryForGetGeneratedKey

public String getSimpleQueryForGetGeneratedKey(String tableName,
                                               String keyColumnName)
Description copied from interface: TableMetaDataProvider
Get the simple query to retrieve a generated key

Specified by:
getSimpleQueryForGetGeneratedKey in interface TableMetaDataProvider

setGetGeneratedKeysSupported

public void setGetGeneratedKeysSupported(boolean getGeneratedKeysSupported)
Specify whether a column name array is supported for generated keys


setGeneratedKeysColumnNameArraySupported

public void setGeneratedKeysColumnNameArraySupported(boolean generatedKeysColumnNameArraySupported)
Specify whether a column name array is supported for generated keys


isGeneratedKeysColumnNameArraySupported

public boolean isGeneratedKeysColumnNameArraySupported()
Description copied from interface: TableMetaDataProvider
Does this database support a column name String array for retreiving generated keys Connection.createStruct(String, Object[])

Specified by:
isGeneratedKeysColumnNameArraySupported in interface TableMetaDataProvider

setNativeJdbcExtractor

public void setNativeJdbcExtractor(NativeJdbcExtractor nativeJdbcExtractor)
Description copied from interface: TableMetaDataProvider
Set the NativeJdbcExtractor to use to retrieve the native connection if necessary

Specified by:
setNativeJdbcExtractor in interface TableMetaDataProvider

getNativeJdbcExtractor

protected NativeJdbcExtractor getNativeJdbcExtractor()

initializeWithMetaData

public void initializeWithMetaData(DatabaseMetaData databaseMetaData)
                            throws SQLException
Description copied from interface: TableMetaDataProvider
Initialize using the database metedata provided

Specified by:
initializeWithMetaData in interface TableMetaDataProvider
Throws:
SQLException

initializeWithTableColumnMetaData

public void initializeWithTableColumnMetaData(DatabaseMetaData databaseMetaData,
                                              String catalogName,
                                              String schemaName,
                                              String tableName)
                                       throws SQLException
Description copied from interface: TableMetaDataProvider
Initialize using provided database metadata, table and column information. This initalization can be turned off by specifying that column meta data should not be used.

Specified by:
initializeWithTableColumnMetaData in interface TableMetaDataProvider
Parameters:
databaseMetaData - used to retrieve database specific information
catalogName - name of catalog to use or null
schemaName - name of schema name to use or null
tableName - name of the table
Throws:
SQLException

tableNameToUse

public String tableNameToUse(String tableName)
Description copied from interface: TableMetaDataProvider
Get the table name formatted based on metadata information. This could include altering the case.

Specified by:
tableNameToUse in interface TableMetaDataProvider
Returns:
table name formatted

catalogNameToUse

public String catalogNameToUse(String catalogName)
Description copied from interface: TableMetaDataProvider
Get the catalog name formatted based on metadata information. This could include altering the case.

Specified by:
catalogNameToUse in interface TableMetaDataProvider
Returns:
catalog name formatted

schemaNameToUse

public String schemaNameToUse(String schemaName)
Description copied from interface: TableMetaDataProvider
Get the schema name formatted based on metadata information. This could include altering the case.

Specified by:
schemaNameToUse in interface TableMetaDataProvider
Returns:
schema name formatted

metaDataCatalogNameToUse

public String metaDataCatalogNameToUse(String catalogName)
Description copied from interface: TableMetaDataProvider
Provide any modification of the catalog name passed in to match the meta data currently used. The reyurned value will be used for meta data lookups. This could include alterig the case used or providing a base catalog if mone provided.

Specified by:
metaDataCatalogNameToUse in interface TableMetaDataProvider
Returns:
catalog name to use

metaDataSchemaNameToUse

public String metaDataSchemaNameToUse(String schemaName)
Description copied from interface: TableMetaDataProvider
Provide any modification of the schema name passed in to match the meta data currently used. The reyurned value will be used for meta data lookups. This could include alterig the case used or providing a base schema if mone provided.

Specified by:
metaDataSchemaNameToUse in interface TableMetaDataProvider
Returns:
schema name to use

getDefaultSchema

protected String getDefaultSchema()
Provide access to default schema for subclasses.


getDatabaseVersion

protected String getDatabaseVersion()
Provide access to version info for subclasses.