Top Description Inners Fields Constructors Methods
org.springframework.jdbc.core.metadata

public Class GenericTableMetaDataProvider

extends Object
implements TableMetaDataProvider
Class Inheritance
All Implemented Interfaces
org.springframework.jdbc.core.metadata.TableMetaDataProvider
Known Direct Subclasses
org.springframework.jdbc.core.metadata.HsqlTableMetaDataProvider, org.springframework.jdbc.core.metadata.OracleTableMetaDataProvider, org.springframework.jdbc.core.metadata.PostgresTableMetaDataProvider, org.springframework.jdbc.core.metadata.DerbyTableMetaDataProvider
Imports
java.sql.DatabaseMetaData, .ResultSet, .SQLException, .Types, java.util.ArrayList, .Arrays, .HashMap, .List, .Map, org.apache.commons.logging.Log, .LogFactory, org.springframework.dao.DataAccessResourceFailureException, org.springframework.jdbc.support.JdbcUtils, org.springframework.lang.Nullable

A generic implementation of the TableMetaDataProvider interface which should provide enough features for all supported databases.
Authors
Thomas Risberg, Juergen Hoeller, Sam Brannen
Since
2.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static record
GenericTableMetaDataProvider.TableMetaData

Record representing table meta-data.

Field Summary

Modifier and TypeField and Description
private String
databaseVersion

The version of the database.

private boolean
generatedKeysColumnNameArraySupported

Indicates whether the use of a String[] for generated keys is supported.

private boolean
getGeneratedKeysSupported

Indicates whether generated keys retrieval is supported.

private String
identifierQuoteString

The string used to quote SQL identifiers.

protected static final Log
logger

Logger available to subclasses.

private static final List<String>
productsNotSupportingGeneratedKeysColumnNameArray

Database products we know not supporting the use of a String[] for generated keys.

private boolean
storesLowerCaseIdentifiers

Indicates whether the identifiers are lowercased.

private boolean
storesUpperCaseIdentifiers

Indicates whether the identifiers are uppercased.

private boolean
tableColumnMetaDataUsed

Indicates whether column meta-data has been used.

private final List<TableParameterMetaData>
tableParameterMetaData

Collection of TableParameterMetaData objects.

private final String
userName

The name of the user currently connected.

Constructor Summary

AccessConstructor and Description
protected
GenericTableMetaDataProvider(DatabaseMetaData
meta-data to be used
databaseMetaData
)

Constructor used to initialize with provided database meta-data.

Method Summary

Modifier and TypeMethod and Description
public String
catalogNameToUse(String catalogName)

Implements org.springframework.jdbc.core.metadata.TableMetaDataProvider.catalogNameToUse.

Get the catalog name formatted based on meta-data information.

public String
columnNameToUse(String columnName)

Implements org.springframework.jdbc.core.metadata.TableMetaDataProvider.columnNameToUse.

Get the column name formatted based on meta-data information.

private GenericTableMetaDataProvider.TableMetaData
protected String
getDatabaseVersion()

Provide access to the version info for subclasses.

protected String
getDefaultSchema()

Provide access to the default schema for subclasses.

public String
public String
getSimpleQueryForGetGeneratedKey(String tableName, String keyColumnName)

Implements org.springframework.jdbc.core.metadata.TableMetaDataProvider.getSimpleQueryForGetGeneratedKey.

Get the simple query to retrieve generated keys when the JDBC feature for retrieving generated keys is not supported.

public List<TableParameterMetaData>
private String
identifierNameToUse(String identifierName)

public void
initializeWithMetaData(DatabaseMetaData
used to retrieve database specific information
databaseMetaData
)

Implements org.springframework.jdbc.core.metadata.TableMetaDataProvider.initializeWithMetaData.

Initialize using the database meta-data provided.

public void
initializeWithTableColumnMetaData(DatabaseMetaData
used to retrieve database specific information
databaseMetaData
,
String
name of catalog to use (or null if none)
catalogName
,
String
name of schema name to use (or null if none)
schemaName
,
String
name of the table
tableName
)

Implements org.springframework.jdbc.core.metadata.TableMetaDataProvider.initializeWithTableColumnMetaData.

Initialize using provided database meta-data, table and column information.

public boolean
isGeneratedKeysColumnNameArraySupported()

Implements org.springframework.jdbc.core.metadata.TableMetaDataProvider.isGeneratedKeysColumnNameArraySupported.

Does this database support a column name String array for retrieving generated keys?

public boolean
isGetGeneratedKeysSimulated()

Implements org.springframework.jdbc.core.metadata.TableMetaDataProvider.isGetGeneratedKeysSimulated.

Does this database support a simple query to retrieve generated keys when the JDBC feature for retrieving generated keys is not supported?

public boolean
isGetGeneratedKeysSupported()

Implements org.springframework.jdbc.core.metadata.TableMetaDataProvider.isGetGeneratedKeysSupported.

Does this database support the JDBC feature for retrieving generated keys?

public boolean
public boolean
public boolean
private void
locateTableAndProcessMetaData(DatabaseMetaData databaseMetaData, String catalogName, String schemaName, String tableName)

Method supporting the meta-data processing for a table.

public String
metaDataCatalogNameToUse(String catalogName)

Implements org.springframework.jdbc.core.metadata.TableMetaDataProvider.metaDataCatalogNameToUse.

Provide any modification of the catalog name passed in to match the meta-data currently used.

public String
metaDataSchemaNameToUse(String schemaName)

Implements org.springframework.jdbc.core.metadata.TableMetaDataProvider.metaDataSchemaNameToUse.

Provide any modification of the schema name passed in to match the meta-data currently used.

private void
processTableColumns(DatabaseMetaData databaseMetaData, GenericTableMetaDataProvider.TableMetaData tmd)

Method supporting the meta-data processing for a table's columns.

public String
schemaNameToUse(String schemaName)

Implements org.springframework.jdbc.core.metadata.TableMetaDataProvider.schemaNameToUse.

Get the schema name formatted based on meta-data information.

public void
setGeneratedKeysColumnNameArraySupported(boolean generatedKeysColumnNameArraySupported)

public void
setGetGeneratedKeysSupported(boolean getGeneratedKeysSupported)

public void
setStoresLowerCaseIdentifiers(boolean storesLowerCaseIdentifiers)

public void
setStoresUpperCaseIdentifiers(boolean storesUpperCaseIdentifiers)

public String
tableNameToUse(String tableName)

Implements org.springframework.jdbc.core.metadata.TableMetaDataProvider.tableNameToUse.

Get the table name formatted based on meta-data information.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

databaseVersionback to summary
private String databaseVersion

The version of the database.

Annotations
@Nullable
generatedKeysColumnNameArraySupportedback to summary
private boolean generatedKeysColumnNameArraySupported

Indicates whether the use of a String[] for generated keys is supported.

getGeneratedKeysSupportedback to summary
private boolean getGeneratedKeysSupported

Indicates whether generated keys retrieval is supported.

identifierQuoteStringback to summary
private String identifierQuoteString

The string used to quote SQL identifiers.

loggerback to summary
protected static final Log logger

Logger available to subclasses.

productsNotSupportingGeneratedKeysColumnNameArrayback to summary
private static final List<String> productsNotSupportingGeneratedKeysColumnNameArray

Database products we know not supporting the use of a String[] for generated keys.

storesLowerCaseIdentifiersback to summary
private boolean storesLowerCaseIdentifiers

Indicates whether the identifiers are lowercased.

storesUpperCaseIdentifiersback to summary
private boolean storesUpperCaseIdentifiers

Indicates whether the identifiers are uppercased.

tableColumnMetaDataUsedback to summary
private boolean tableColumnMetaDataUsed

Indicates whether column meta-data has been used.

tableParameterMetaDataback to summary
private final List<TableParameterMetaData> tableParameterMetaData

Collection of TableParameterMetaData objects.

userNameback to summary
private final String userName

The name of the user currently connected.

Annotations
@Nullable

Constructor Detail

GenericTableMetaDataProviderback to summary
protected GenericTableMetaDataProvider(DatabaseMetaData databaseMetaData) throws SQLException

Constructor used to initialize with provided database meta-data.

Parameters
databaseMetaData:DatabaseMetaData

meta-data to be used

Method Detail

catalogNameToUseback to summary
public String catalogNameToUse(String catalogName)

Implements org.springframework.jdbc.core.metadata.TableMetaDataProvider.catalogNameToUse.

Doc from org.springframework.jdbc.core.metadata.TableMetaDataProvider.catalogNameToUse.

Get the catalog name formatted based on meta-data information.

This could include altering the case.

Annotations
@Override
@Nullable
columnNameToUseback to summary
public String columnNameToUse(String columnName)

Implements org.springframework.jdbc.core.metadata.TableMetaDataProvider.columnNameToUse.

Doc from org.springframework.jdbc.core.metadata.TableMetaDataProvider.columnNameToUse.

Get the column name formatted based on meta-data information.

This could include altering the case.

Annotations
@Override
@Nullable
findTableMetaDataback to summary
private GenericTableMetaDataProvider.TableMetaData findTableMetaData(String schemaName, String tableName, Map<String, GenericTableMetaDataProvider.TableMetaData> tableMeta)
getDatabaseVersionback to summary
protected String getDatabaseVersion()

Provide access to the version info for subclasses.

Annotations
@Nullable
getDefaultSchemaback to summary
protected String getDefaultSchema()

Provide access to the default schema for subclasses.

Annotations
@Nullable
getIdentifierQuoteStringback to summary
public String getIdentifierQuoteString()

Implements org.springframework.jdbc.core.metadata.TableMetaDataProvider.getIdentifierQuoteString.

Doc from org.springframework.jdbc.core.metadata.TableMetaDataProvider.getIdentifierQuoteString.

Get the string used to quote SQL identifiers.

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

Returns:String

database identifier quote string

Annotations
@Override
getSimpleQueryForGetGeneratedKeyback to summary
public String getSimpleQueryForGetGeneratedKey(String tableName, String keyColumnName)

Implements org.springframework.jdbc.core.metadata.TableMetaDataProvider.getSimpleQueryForGetGeneratedKey.

Doc from org.springframework.jdbc.core.metadata.TableMetaDataProvider.getSimpleQueryForGetGeneratedKey.

Get the simple query to retrieve generated keys when the JDBC feature for retrieving generated keys is not supported.

Annotations
@Override
@Nullable
getTableParameterMetaDataback to summary
public List<TableParameterMetaData> getTableParameterMetaData()

Implements org.springframework.jdbc.core.metadata.TableMetaDataProvider.getTableParameterMetaData.

Doc from org.springframework.jdbc.core.metadata.TableMetaDataProvider.getTableParameterMetaData.

Get the table parameter meta-data that is currently used.

Returns:List<TableParameterMetaData>

a List of TableParameterMetaData

Annotations
@Override
identifierNameToUseback to summary
private String identifierNameToUse(String identifierName)
Annotations
@Nullable
initializeWithMetaDataback to summary
public void initializeWithMetaData(DatabaseMetaData databaseMetaData) throws SQLException

Implements org.springframework.jdbc.core.metadata.TableMetaDataProvider.initializeWithMetaData.

Doc from org.springframework.jdbc.core.metadata.TableMetaDataProvider.initializeWithMetaData.

Initialize using the database meta-data provided.

Parameters
databaseMetaData:DatabaseMetaData

used to retrieve database specific information

Annotations
@Override
Exceptions
SQLException:
in case of initialization failure
initializeWithTableColumnMetaDataback to summary
public void initializeWithTableColumnMetaData(DatabaseMetaData databaseMetaData, String catalogName, String schemaName, String tableName) throws SQLException

Implements org.springframework.jdbc.core.metadata.TableMetaDataProvider.initializeWithTableColumnMetaData.

Doc from org.springframework.jdbc.core.metadata.TableMetaDataProvider.initializeWithTableColumnMetaData.

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.

Parameters
databaseMetaData:DatabaseMetaData

used to retrieve database specific information

catalogName:String

name of catalog to use (or null if none)

schemaName:String

name of schema name to use (or null if none)

tableName:String

name of the table

Annotations
@Override
Exceptions
SQLException:
in case of initialization failure
isGeneratedKeysColumnNameArraySupportedback to summary
public boolean isGeneratedKeysColumnNameArraySupported()

Implements org.springframework.jdbc.core.metadata.TableMetaDataProvider.isGeneratedKeysColumnNameArraySupported.

Doc from org.springframework.jdbc.core.metadata.TableMetaDataProvider.isGeneratedKeysColumnNameArraySupported.

Does this database support a column name String array for retrieving generated keys?

Annotations
@Override
isGetGeneratedKeysSimulatedback to summary
public boolean isGetGeneratedKeysSimulated()

Implements org.springframework.jdbc.core.metadata.TableMetaDataProvider.isGetGeneratedKeysSimulated.

Doc from org.springframework.jdbc.core.metadata.TableMetaDataProvider.isGetGeneratedKeysSimulated.

Does this database support a simple query to retrieve generated keys when the JDBC feature for retrieving generated keys is not supported?

Annotations
@Override
isGetGeneratedKeysSupportedback to summary
public boolean isGetGeneratedKeysSupported()

Implements org.springframework.jdbc.core.metadata.TableMetaDataProvider.isGetGeneratedKeysSupported.

Doc from org.springframework.jdbc.core.metadata.TableMetaDataProvider.isGetGeneratedKeysSupported.

Does this database support the JDBC feature for retrieving generated keys?

Annotations
@Override
isStoresLowerCaseIdentifiersback to summary
public boolean isStoresLowerCaseIdentifiers()
isStoresUpperCaseIdentifiersback to summary
public boolean isStoresUpperCaseIdentifiers()
isTableColumnMetaDataUsedback to summary
public boolean isTableColumnMetaDataUsed()

Implements org.springframework.jdbc.core.metadata.TableMetaDataProvider.isTableColumnMetaDataUsed.

Doc from org.springframework.jdbc.core.metadata.TableMetaDataProvider.isTableColumnMetaDataUsed.

Are we using the meta-data for the table columns?

Annotations
@Override
locateTableAndProcessMetaDataback to summary
private void locateTableAndProcessMetaData(DatabaseMetaData databaseMetaData, String catalogName, String schemaName, String tableName)

Method supporting the meta-data processing for a table.

metaDataCatalogNameToUseback to summary
public String metaDataCatalogNameToUse(String catalogName)

Implements org.springframework.jdbc.core.metadata.TableMetaDataProvider.metaDataCatalogNameToUse.

Doc from org.springframework.jdbc.core.metadata.TableMetaDataProvider.metaDataCatalogNameToUse.

Provide any modification of the catalog name passed in to match the meta-data currently used.

The returned value will be used for meta-data lookups.

This could include altering the case used or providing a base catalog if none is provided.

Annotations
@Override
@Nullable
metaDataSchemaNameToUseback to summary
public String metaDataSchemaNameToUse(String schemaName)

Implements org.springframework.jdbc.core.metadata.TableMetaDataProvider.metaDataSchemaNameToUse.

Doc from org.springframework.jdbc.core.metadata.TableMetaDataProvider.metaDataSchemaNameToUse.

Provide any modification of the schema name passed in to match the meta-data currently used.

The returned value will be used for meta-data lookups.

This could include altering the case used or providing a base schema if none is provided.

Annotations
@Override
@Nullable
processTableColumnsback to summary
private void processTableColumns(DatabaseMetaData databaseMetaData, GenericTableMetaDataProvider.TableMetaData tmd)

Method supporting the meta-data processing for a table's columns.

schemaNameToUseback to summary
public String schemaNameToUse(String schemaName)

Implements org.springframework.jdbc.core.metadata.TableMetaDataProvider.schemaNameToUse.

Doc from org.springframework.jdbc.core.metadata.TableMetaDataProvider.schemaNameToUse.

Get the schema name formatted based on meta-data information.

This could include altering the case.

Annotations
@Override
@Nullable
setGeneratedKeysColumnNameArraySupportedback to summary
public void setGeneratedKeysColumnNameArraySupported(boolean generatedKeysColumnNameArraySupported)
setGetGeneratedKeysSupportedback to summary
public void setGetGeneratedKeysSupported(boolean getGeneratedKeysSupported)
setStoresLowerCaseIdentifiersback to summary
public void setStoresLowerCaseIdentifiers(boolean storesLowerCaseIdentifiers)
setStoresUpperCaseIdentifiersback to summary
public void setStoresUpperCaseIdentifiers(boolean storesUpperCaseIdentifiers)
tableNameToUseback to summary
public String tableNameToUse(String tableName)

Implements org.springframework.jdbc.core.metadata.TableMetaDataProvider.tableNameToUse.

Doc from org.springframework.jdbc.core.metadata.TableMetaDataProvider.tableNameToUse.

Get the table name formatted based on meta-data information.

This could include altering the case.

Annotations
@Override
@Nullable
org.springframework.jdbc.core.metadata back to summary

private final Record GenericTableMetaDataProvider.TableMetaData

extends Record
Class Inheritance
Record Components
catalogName:String 
schemaName:String 
tableName:String 

Record representing table meta-data.

Field Summary

Modifier and TypeField and Description
private final String
catalogName

Record Component accessed by catalogName().

private final String
schemaName

Record Component accessed by schemaName().

private final String
tableName

Record Component accessed by tableName().

Constructor Summary

AccessConstructor and Description
private
TableMetaData(String catalogName, String schemaName, String tableName)

Method Summary

Modifier and TypeMethod and Description
public String
catalogName()

Record Component getter of catalogName.

public final boolean
equals(Object
the reference object with which to compare.
o
)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public String
schemaName()

Record Component getter of schemaName.

public String
tableName()

Record Component getter of tableName.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

catalogNameback to summary
private final String catalogName

Record Component accessed by catalogName().

Annotations
@Nullable
schemaNameback to summary
private final String schemaName

Record Component accessed by schemaName().

Annotations
@Nullable
tableNameback to summary
private final String tableName

Record Component accessed by tableName().

Annotations
@Nullable

Constructor Detail

TableMetaDataback to summary
private TableMetaData(String catalogName, String schemaName, String tableName)

Method Detail

catalogNameback to summary
public String catalogName()

Record Component getter of catalogName.

Annotations
@Nullable
equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this record is equal to the argument; false otherwise.

hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

Returns:int

a hash code value for this record.

schemaNameback to summary
public String schemaName()

Record Component getter of schemaName.

Annotations
@Nullable
tableNameback to summary
public String tableName()

Record Component getter of tableName.

Annotations
@Nullable
toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

Returns:String

a string representation of the object.