Package org.springframework.jdbc.core.metadata

# Class GenericTableMetaDataProvider

java.lang.Object
org.springframework.jdbc.core.metadata.GenericTableMetaDataProvider

All Implemented Interfaces:
  `TableMetaDataProvider`

Direct Known Subclasses:
  `DerbyTableMetaDataProvider`, `HsqlTableMetaDataProvider`, `MySQLTableMetaDataProvider`, `OracleTableMetaDataProvider`, `PostgresTableMetaDataProvider`

public class GenericTableMetaDataProvider extends Object implements TableMetaDataProvider
A generic implementation of the `TableMetaDataProvider` interface which should provide enough features for all supported databases.

Since:
  2.5
Author:
  Thomas Risberg, Juergen Hoeller, Sam Brannen

## Field Summary

Fields
Modifier and Type
Field
Description
`protected static final org.apache.commons.logging.Log`
`logger`
Logger available to subclasses.

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`GenericTableMetaDataProvider(DatabaseMetaData databaseMetaData)`
Constructor used to initialize with provided database meta-data.

## Method Summary

Modifier and Type
Method
Description
`String`
`catalogNameToUse(String catalogName)`
Get the catalog name formatted based on meta-data information.
`String`
`columnNameToUse(String columnName)`
Get the column name formatted based on meta-data information.
`protected String`
`getDatabaseVersion()`
Provide access to the version info for subclasses.
`protected String`
`getDefaultSchema()`
Provide access to the default schema for subclasses.
`String`
`getIdentifierQuoteString()`
Get the string used to quote SQL identifiers.
`String`
`getSimpleQueryForGetGeneratedKey(String tableName, String keyColumnName)`
Get the simple query to retrieve generated keys when the JDBC feature for retrieving generated keys is not supported.
`List<TableParameterMetaData>`
`getTableParameterMetaData()`
Get the table parameter meta-data that is currently used.
`void`
`initializeWithMetaData(DatabaseMetaData databaseMetaData)`
Initialize using the database meta-data provided.
`void`
`initializeWithTableColumnMetaData(DatabaseMetaData databaseMetaData, String catalogName, String schemaName, String tableName)`
Initialize using provided database meta-data, table and column information.
`boolean`
`isGeneratedKeysColumnNameArraySupported()`
Does this database support a column name String array for retrieving generated keys?
`boolean`
`isGetGeneratedKeysSimulated()`
Does this database support a simple query to retrieve generated keys when the JDBC feature for retrieving generated keys is not supported?
`boolean`
`isGetGeneratedKeysSupported()`
Does this database support the JDBC feature for retrieving generated keys?
`boolean`
`isStoresLowerCaseIdentifiers()`
`boolean`
`isStoresUpperCaseIdentifiers()`
`boolean`
`isTableColumnMetaDataUsed()`
Are we using the meta-data for the table columns?
`String`
`metaDataCatalogNameToUse(String catalogName)`
This implementation delegates to `catalogNameToUse(java.lang.String)`.
`String`
`metaDataSchemaNameToUse(String schemaName)`
This implementation delegates to `schemaNameToUse(java.lang.String)`.
`String`
`schemaNameToUse(String schemaName)`
Get the schema name formatted based on meta-data information.
`void`
`setGeneratedKeysColumnNameArraySupported(boolean generatedKeysColumnNameArraySupported)`
`void`
`setGetGeneratedKeysSupported(boolean getGeneratedKeysSupported)`
`void`
`setStoresLowerCaseIdentifiers(boolean storesLowerCaseIdentifiers)`
`void`
`setStoresUpperCaseIdentifiers(boolean storesUpperCaseIdentifiers)`
`String`
`tableNameToUse(String tableName)`
Get the table name formatted based on meta-data information.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### logger

protected static final org.apache.commons.logging.Log logger
Logger available to subclasses.

## Constructor Details

### 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 Details

### initializeWithMetaData

public void initializeWithMetaData(DatabaseMetaData databaseMetaData) throws SQLException
Description copied from interface: `TableMetaDataProvider`
Initialize using the database meta-data provided.

Specified by:
  `initializeWithMetaData` in interface `TableMetaDataProvider`
Parameters:
  `databaseMetaData` - used to retrieve database specific information
Throws:
  `SQLException` - in case of initialization failure

### initializeWithTableColumnMetaData

public void initializeWithTableColumnMetaData(DatabaseMetaData databaseMetaData, @Nullable String catalogName, @Nullable String schemaName, @Nullable String tableName) throws SQLException
Description copied from interface: `TableMetaDataProvider`
Initialize using provided database meta-data, table and column information.

This initialization 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` if none)
  `schemaName` - name of schema name to use (or `null` if none)
  `tableName` - name of the table
Throws:
  `SQLException` - in case of initialization failure

### getTableParameterMetaData

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

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

### tableNameToUse

@Nullable public String tableNameToUse(@Nullable String tableName)
Description copied from interface: `TableMetaDataProvider`
Get the table name formatted based on meta-data information.

This could include altering the case.

Specified by:
  `tableNameToUse` in interface `TableMetaDataProvider`

### columnNameToUse

@Nullable public String columnNameToUse(@Nullable String columnName)
Description copied from interface: `TableMetaDataProvider`
Get the column name formatted based on meta-data information.

This could include altering the case.

Specified by:
  `columnNameToUse` in interface `TableMetaDataProvider`

### catalogNameToUse

@Nullable public String catalogNameToUse(@Nullable String catalogName)
Description copied from interface: `TableMetaDataProvider`
Get the catalog name formatted based on meta-data information.

This could include altering the case.

Specified by:
  `catalogNameToUse` in interface `TableMetaDataProvider`

### schemaNameToUse

@Nullable public String schemaNameToUse(@Nullable String schemaName)
Description copied from interface: `TableMetaDataProvider`
Get the schema name formatted based on meta-data information.

This could include altering the case.

Specified by:
  `schemaNameToUse` in interface `TableMetaDataProvider`

### metaDataCatalogNameToUse

@Nullable public String metaDataCatalogNameToUse(@Nullable String catalogName)
This implementation delegates to `catalogNameToUse(java.lang.String)`.

Specified by:
  `metaDataCatalogNameToUse` in interface `TableMetaDataProvider`

### metaDataSchemaNameToUse

@Nullable public String metaDataSchemaNameToUse(@Nullable String schemaName)
This implementation delegates to `schemaNameToUse(java.lang.String)`.

Specified by:
  `metaDataSchemaNameToUse` in interface `TableMetaDataProvider`
See Also:
  - `getDefaultSchema()`

### getDefaultSchema

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

### getDatabaseVersion

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

### 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`

### setGetGeneratedKeysSupported

public void setGetGeneratedKeysSupported(boolean getGeneratedKeysSupported)

### isGetGeneratedKeysSupported

public boolean isGetGeneratedKeysSupported()
Description copied from interface: `TableMetaDataProvider`
Does this database support the JDBC feature for retrieving generated keys?

Specified by:
  `isGetGeneratedKeysSupported` in interface `TableMetaDataProvider`
See Also:
  - `DatabaseMetaData.supportsGetGeneratedKeys()`

### isGetGeneratedKeysSimulated

public boolean isGetGeneratedKeysSimulated()
Description copied from interface: `TableMetaDataProvider`
Does this database support a simple query to retrieve generated keys when the JDBC feature for retrieving generated keys is not supported?

Specified by:
  `isGetGeneratedKeysSimulated` in interface `TableMetaDataProvider`
See Also:
  - `TableMetaDataProvider.isGetGeneratedKeysSupported()`
  - `TableMetaDataProvider.getSimpleQueryForGetGeneratedKey(String, String)`

### getSimpleQueryForGetGeneratedKey

@Nullable public String getSimpleQueryForGetGeneratedKey(String tableName, String keyColumnName)
Description copied from interface: `TableMetaDataProvider`
Get the simple query to retrieve generated keys when the JDBC feature for retrieving generated keys is not supported.

Specified by:
  `getSimpleQueryForGetGeneratedKey` in interface `TableMetaDataProvider`
See Also:
  - `TableMetaDataProvider.isGetGeneratedKeysSimulated()`

### setGeneratedKeysColumnNameArraySupported

public void setGeneratedKeysColumnNameArraySupported(boolean generatedKeysColumnNameArraySupported)

### isGeneratedKeysColumnNameArraySupported

public boolean isGeneratedKeysColumnNameArraySupported()
Description copied from interface: `TableMetaDataProvider`
Does this database support a column name String array for retrieving generated keys?

Specified by:
  `isGeneratedKeysColumnNameArraySupported` in interface `TableMetaDataProvider`
See Also:
  - `Connection.createStruct(String, Object[])`

### setStoresUpperCaseIdentifiers

public void setStoresUpperCaseIdentifiers(boolean storesUpperCaseIdentifiers)

### isStoresUpperCaseIdentifiers

public boolean isStoresUpperCaseIdentifiers()

### setStoresLowerCaseIdentifiers

public void setStoresLowerCaseIdentifiers(boolean storesLowerCaseIdentifiers)

### isStoresLowerCaseIdentifiers

public boolean isStoresLowerCaseIdentifiers()

### getIdentifierQuoteString

public String getIdentifierQuoteString()
Description copied from interface: `TableMetaDataProvider`
Get the string used to quote SQL identifiers.

This method returns a space (`" "`) if identifier quoting is not supported.

Specified by:
  `getIdentifierQuoteString` in interface `TableMetaDataProvider`
Returns:
  database identifier quote string
See Also:
  - `DatabaseMetaData.getIdentifierQuoteString()`