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

public Class TableMetaDataContext

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Collections, .LinkedHashSet, .List, .Map, .Set, javax.sql.DataSource, org.apache.commons.logging.Log, .LogFactory, org.springframework.dao.InvalidDataAccessApiUsageException, org.springframework.jdbc.core.SqlTypeValue, org.springframework.jdbc.core.namedparam.SqlParameterSource, .SqlParameterSourceUtils, org.springframework.jdbc.support.JdbcUtils, org.springframework.lang.Nullable, org.springframework.util.Assert, .CollectionUtils, .StringUtils

Class to manage context meta-data used for the configuration and execution of operations on a database table.
Authors
Thomas Risberg, Juergen Hoeller, Sam Brannen
Since
2.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private boolean
private String
private boolean
protected final Log
private TableMetaDataProvider
private boolean
private boolean
private String
private List<String>
private String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the insert string to be used
createInsertString
(String... generatedKeyNames)

Build the insert string based on configuration and meta-data information.

public int[]

Returns:

the array of types to be used
createInsertTypes
()

Build the array of java.sql.Types based on configuration and meta-data information.

public String
getCatalogName()

Get the name of the catalog for this context.

public String
getSchemaName()

Get the name of the schema for this context.

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.

public List<String>
getTableColumns()

Get a List of the table column names.

public String
getTableName()

Get the name of the table for this context.

public boolean
isAccessTableColumnMetaData()

Are we accessing table meta-data?

public boolean
isGeneratedKeysColumnNameArraySupported()

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

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?

public boolean
isGetGeneratedKeysSupported()

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

public boolean
isOverrideIncludeSynonymsDefault()

Are we overriding include synonyms default?

public boolean
isQuoteIdentifiers()

Are we quoting identifiers?

public List<Object>
matchInParameterValuesWithInsertColumns(SqlParameterSource
the parameter names and values
parameterSource
)

Match the provided column names and values with the list of columns used.

public List<Object>
matchInParameterValuesWithInsertColumns(Map<String, ?>
the parameter names and values
inParameters
)

Match the provided column names and values with the list of columns used.

private TableMetaDataProvider
public void
processMetaData(DataSource
the DataSource being used
dataSource
,
List<String>
any columns that are declared
declaredColumns
,
String[]
name of generated keys
generatedKeyNames
)

Process the current meta-data with the provided configuration options.

protected List<String>
reconcileColumnsToUse(List<String>
declared column names
declaredColumns
,
String[]
names of generated key columns
generatedKeyNames
)

Compare columns created from meta-data with declared columns and return a reconciled list.

public void
setAccessTableColumnMetaData(boolean accessTableColumnMetaData)

Specify whether we should access table column meta-data.

public void
setCatalogName(String catalogName)

Set the name of the catalog for this context.

public void
setOverrideIncludeSynonymsDefault(boolean override)

Specify whether we should override default for accessing synonyms.

public void
setQuoteIdentifiers(boolean
whether identifiers should be quoted
quoteIdentifiers
)

Specify whether we are quoting SQL identifiers.

public void
setSchemaName(String schemaName)

Set the name of the schema for this context.

public void
setTableName(String tableName)

Set the name of the table for this context.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

accessTableColumnMetaDataback to summary
private boolean accessTableColumnMetaData
catalogNameback to summary
private String catalogName
Annotations
@Nullable
generatedKeyColumnsUsedback to summary
private boolean generatedKeyColumnsUsed
loggerback to summary
protected final Log logger
metaDataProviderback to summary
private TableMetaDataProvider metaDataProvider
Annotations
@Nullable
overrideIncludeSynonymsDefaultback to summary
private boolean overrideIncludeSynonymsDefault
quoteIdentifiersback to summary
private boolean quoteIdentifiers
schemaNameback to summary
private String schemaName
Annotations
@Nullable
tableColumnsback to summary
private List<String> tableColumns
tableNameback to summary
private String tableName
Annotations
@Nullable

Constructor Detail

TableMetaDataContextback to summary
public TableMetaDataContext()

Method Detail

createInsertStringback to summary
public String createInsertString(String... generatedKeyNames)

Build the insert string based on configuration and meta-data information.

Returns:String

the insert string to be used

createInsertTypesback to summary
public int[] createInsertTypes()

Build the array of java.sql.Types based on configuration and meta-data information.

Returns:int[]

the array of types to be used

getCatalogNameback to summary
public String getCatalogName()

Get the name of the catalog for this context.

Annotations
@Nullable
getSchemaNameback to summary
public String getSchemaName()

Get the name of the schema for this context.

Annotations
@Nullable
getSimpleQueryForGetGeneratedKeyback to summary
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.

Annotations
@Nullable
See Also
isGetGeneratedKeysSimulated()
getTableColumnsback to summary
public List<String> getTableColumns()

Get a List of the table column names.

getTableNameback to summary
public String getTableName()

Get the name of the table for this context.

Annotations
@Nullable
isAccessTableColumnMetaDataback to summary
public boolean isAccessTableColumnMetaData()

Are we accessing table meta-data?

isGeneratedKeysColumnNameArraySupportedback to summary
public boolean isGeneratedKeysColumnNameArraySupported()

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

See Also
java.sql.Connection#createStruct(String, Object[])
isGetGeneratedKeysSimulatedback to summary
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)
isGetGeneratedKeysSupportedback to summary
public boolean isGetGeneratedKeysSupported()

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

See Also
java.sql.DatabaseMetaData#supportsGetGeneratedKeys()
isOverrideIncludeSynonymsDefaultback to summary
public boolean isOverrideIncludeSynonymsDefault()

Are we overriding include synonyms default?

isQuoteIdentifiersback to summary
public boolean isQuoteIdentifiers()

Are we quoting identifiers?

Since
6.1
See Also
setQuoteIdentifiers(boolean)
matchInParameterValuesWithInsertColumnsback to summary
public List<Object> matchInParameterValuesWithInsertColumns(SqlParameterSource parameterSource)

Match the provided column names and values with the list of columns used.

Parameters
parameterSource:SqlParameterSource

the parameter names and values

matchInParameterValuesWithInsertColumnsback to summary
public List<Object> matchInParameterValuesWithInsertColumns(Map<String, ?> inParameters)

Match the provided column names and values with the list of columns used.

Parameters
inParameters:Map<String, ?>

the parameter names and values

obtainMetaDataProviderback to summary
private TableMetaDataProvider obtainMetaDataProvider()
processMetaDataback to summary
public void processMetaData(DataSource dataSource, List<String> declaredColumns, String[] generatedKeyNames)

Process the current meta-data with the provided configuration options.

Parameters
dataSource:DataSource

the DataSource being used

declaredColumns:List<String>

any columns that are declared

generatedKeyNames:String[]

name of generated keys

reconcileColumnsToUseback to summary
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:List<String>

declared column names

generatedKeyNames:String[]

names of generated key columns

setAccessTableColumnMetaDataback to summary
public void setAccessTableColumnMetaData(boolean accessTableColumnMetaData)

Specify whether we should access table column meta-data.

setCatalogNameback to summary
public void setCatalogName(String catalogName)

Set the name of the catalog for this context.

setOverrideIncludeSynonymsDefaultback to summary
public void setOverrideIncludeSynonymsDefault(boolean override)

Specify whether we should override default for accessing synonyms.

setQuoteIdentifiersback to summary
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:boolean

whether identifiers should be quoted

Since
6.1
See Also
java.sql.DatabaseMetaData#getIdentifierQuoteString()
setSchemaNameback to summary
public void setSchemaName(String schemaName)

Set the name of the schema for this context.

setTableNameback to summary
public void setTableName(String tableName)

Set the name of the table for this context.

org.springframework.jdbc.core.metadata back to summary

private final Class TableMetaDataContext.QuoteHandler

extends Object
Class Inheritance
  • java.lang.Object
  • org.springframework.jdbc.core.metadata.TableMetaDataContext.QuoteHandler

Field Summary

Modifier and TypeField and Description
private final String
private final boolean

Constructor Summary

AccessConstructor and Description
public
QuoteHandler(String identifierQuoteString)

Method Summary

Modifier and TypeMethod and Description
public void
appendTo(StringBuilder stringBuilder, String item)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

identifierQuoteStringback to summary
private final String identifierQuoteString
Annotations
@Nullable
quotingback to summary
private final boolean quoting

Constructor Detail

QuoteHandlerback to summary
public QuoteHandler(String identifierQuoteString)

Method Detail

appendToback to summary
public void appendTo(StringBuilder stringBuilder, String item)