Package org.springframework.jdbc.core.metadata

# Class TableMetaDataContext

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

public class TableMetaDataContext extends Object
Class to manage context meta-data used for the configuration and execution of operations on a database table.

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

## Field Summary

Fields
Modifier and Type
Field
Description
`protected final org.apache.commons.logging.Log`
`logger`

## Constructor Summary

Constructors
Constructor
Description
`TableMetaDataContext()`

## Method Summary

Modifier and Type
Method
Description
`String`
`createInsertString(String... generatedKeyNames)`
Build the insert string based on configuration and meta-data information.
`int[]`
`createInsertTypes()`
Build the array of `Types` based on configuration and meta-data information.
`String`
`getCatalogName()`
Get the name of the catalog for this context.
`String`
`getSchemaName()`
Get the name of the schema for this context.
`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<String>`
`getTableColumns()`
Get a List of the table column names.
`String`
`getTableName()`
Get the name of the table for this context.
`boolean`
`isAccessTableColumnMetaData()`
Are we accessing table meta-data?
`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`
`isOverrideIncludeSynonymsDefault()`
Are we overriding include synonyms default?
`boolean`
`isQuoteIdentifiers()`
Are we quoting identifiers?
`List<Object>`
`matchInParameterValuesWithInsertColumns(Map<String,?> inParameters)`
Match the provided column names and values with the list of columns used.
`List<Object>`
`matchInParameterValuesWithInsertColumns(SqlParameterSource parameterSource)`
Match the provided column names and values with the list of columns used.
`void`
`processMetaData(DataSource dataSource, List<String> declaredColumns, String[] generatedKeyNames)`
Process the current meta-data with the provided configuration options.
`protected List<String>`
`reconcileColumnsToUse(List<String> declaredColumns, String[] generatedKeyNames)`
Compare columns created from meta-data with declared columns and return a reconciled list.
`void`
`setAccessTableColumnMetaData(boolean accessTableColumnMetaData)`
Specify whether we should access table column meta-data.
`void`
`setCatalogName(String catalogName)`
Set the name of the catalog for this context.
`void`
`setOverrideIncludeSynonymsDefault(boolean override)`
Specify whether we should override default for accessing synonyms.
`void`
`setQuoteIdentifiers(boolean quoteIdentifiers)`
Specify whether we are quoting SQL identifiers.
`void`
`setSchemaName(String schemaName)`
Set the name of the schema for this context.
`void`
`setTableName(String tableName)`
Set the name of the table for this context.

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

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

## Field Details

### logger

protected final org.apache.commons.logging.Log logger

## Constructor Details

### TableMetaDataContext

public TableMetaDataContext()

## Method Details

### setTableName

public void setTableName(@Nullable String tableName)
Set the name of the table for this context.

### getTableName

@Nullable public String getTableName()
Get the name of the table for this context.

### setCatalogName

public void setCatalogName(@Nullable String catalogName)
Set the name of the catalog for this context.

### getCatalogName

@Nullable public String getCatalogName()
Get the name of the catalog for this context.

### setSchemaName

public void setSchemaName(@Nullable String schemaName)
Set the name of the schema for this context.

### getSchemaName

@Nullable public String getSchemaName()
Get the name of the schema for this context.

### setAccessTableColumnMetaData

public void setAccessTableColumnMetaData(boolean accessTableColumnMetaData)
Specify whether we should access table column meta-data.

### isAccessTableColumnMetaData

public boolean isAccessTableColumnMetaData()
Are we accessing table meta-data?

### setOverrideIncludeSynonymsDefault

public void setOverrideIncludeSynonymsDefault(boolean override)
Specify whether we should override default for accessing synonyms.

### isOverrideIncludeSynonymsDefault

public boolean isOverrideIncludeSynonymsDefault()
Are we overriding include synonyms default?

### setQuoteIdentifiers

public void setQuoteIdentifiers(boolean quoteIdentifiers)
Specify whether we are quoting SQL identifiers.

Defaults to `false`. If set to `true`, the identifier quote string for the underlying database will be used to quote SQL identifiers in generated SQL statements.

Parameters:
  `quoteIdentifiers` - whether identifiers should be quoted
Since:
  6.1
See Also:
  - `DatabaseMetaData.getIdentifierQuoteString()`

### isQuoteIdentifiers

public boolean isQuoteIdentifiers()
Are we quoting identifiers?

Since:
  6.1
See Also:
  - `setQuoteIdentifiers(boolean)`

### getTableColumns

public List<String> getTableColumns()
Get a List of the table column names.

### processMetaData

public void processMetaData(DataSource dataSource, List<String> declaredColumns, String[] generatedKeyNames)
Process the current meta-data with the provided configuration options.

Parameters:
  `dataSource` - the DataSource being used
  `declaredColumns` - any columns that are declared
  `generatedKeyNames` - name of generated keys

### reconcileColumnsToUse

protected List<String> reconcileColumnsToUse(List<String> declaredColumns, String[] generatedKeyNames)
Compare columns created from meta-data with declared columns and return a reconciled list.

Parameters:
  `declaredColumns` - declared column names
  `generatedKeyNames` - names of generated key columns

### matchInParameterValuesWithInsertColumns

public List<Object> matchInParameterValuesWithInsertColumns(SqlParameterSource parameterSource)
Match the provided column names and values with the list of columns used.

Parameters:
  `parameterSource` - the parameter names and values

### matchInParameterValuesWithInsertColumns

public List<Object> matchInParameterValuesWithInsertColumns(Map<String,?> inParameters)
Match the provided column names and values with the list of columns used.

Parameters:
  `inParameters` - the parameter names and values

### createInsertString

public String createInsertString(String... generatedKeyNames)
Build the insert string based on configuration and meta-data information.

Returns:
  the insert string to be used

### createInsertTypes

public int[] createInsertTypes()
Build the array of `Types` based on configuration and meta-data information.

Returns:
  the array of types to be used

### isGetGeneratedKeysSupported

public boolean isGetGeneratedKeysSupported()
Does this database support the JDBC feature for retrieving generated keys?

See Also:
  - `DatabaseMetaData.supportsGetGeneratedKeys()`

### isGetGeneratedKeysSimulated

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

See Also:
  - `isGetGeneratedKeysSupported()`
  - `getSimpleQueryForGetGeneratedKey(String, String)`

### getSimpleQueryForGetGeneratedKey

@Nullable public 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.

See Also:
  - `isGetGeneratedKeysSimulated()`

### isGeneratedKeysColumnNameArraySupported

public boolean isGeneratedKeysColumnNameArraySupported()
Does this database support a column name String array for retrieving generated keys?

See Also:
  - `Connection.createStruct(String, Object[])`