org.springframework.jdbc.core.metadata
Class TableMetaDataContext

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

public class TableMetaDataContext
extends java.lang.Object

Class to manage context metadata used for the configuration and execution of operations on a database table.

Since:
2.5
Author:
Thomas Risberg

Field Summary
private  boolean accessTableColumnMetaData
          should we access insert parameter meta data info or not
private  java.lang.String catalogName
          name of catalog for call
private  boolean generatedKeyColumnsUsed
          are we using generated key columns
protected  Log logger
          Logger available to subclasses
private  TableMetaDataProvider metaDataProvider
          the provider of table meta data
(package private)  NativeJdbcExtractor nativeJdbcExtractor
          NativeJdbcExtractor to be used to retrieve the native connection
private  boolean overrideIncludeSynonymsDefault
          should we override default for including synonyms for meta data lookups
private  java.lang.String schemaName
          name of schema for call
private  java.util.List<java.lang.String> tableColumns
          List of columns objects to be used in this context
private  java.lang.String tableName
          name of procedure to call
 
Constructor Summary
TableMetaDataContext()
           
 
Method Summary
 java.lang.String createInsertString(java.lang.String[] generatedKeyNames)
          Build the insert string based on configuration and metadata information
 int[] createInsertTypes()
          Build the array of Types based on configuration and metadata information
 java.lang.String getCatalogName()
          Get the name of the catalog for this context.
 java.lang.String getSchemaName()
          Get the name of the schema for this context.
 java.lang.String getSimulationQueryForGetGeneratedKey(java.lang.String tableName, java.lang.String keyColumnName)
          Does this database support simple query to retrieve generated keys when the JDBC 3.0 feature is not supported.
 java.util.List<java.lang.String> getTableColumns()
          Get a List of the table column names.
 java.lang.String getTableName()
          Get the name of the table for this context.
 boolean isAccessTableColumnMetaData()
          Are we accessing table meta data?
 boolean isGeneratedKeysColumnNameArraySupported()
          Is a column name String array for retrieving generated keys supported? Connection.createStruct(String, Object[])?
 boolean isGetGeneratedKeysSimulated()
          Does this database support simple query to retrieve generated keys when the JDBC 3.0 feature is not supported.
 boolean isGetGeneratedKeysSupported()
          Does this database support the JDBC 3.0 feature of retrieving generated keys DatabaseMetaData.supportsGetGeneratedKeys()?
 boolean isOverrideIncludeSynonymsDefault()
          Are we overriding include synonyms default?
 java.util.List<java.lang.Object> matchInParameterValuesWithInsertColumns(java.util.Map<java.lang.String,java.lang.Object> inParameters)
          Match the provided column names and values with the list of columns used.
 java.util.List<java.lang.Object> matchInParameterValuesWithInsertColumns(SqlParameterSource parameterSource)
          Match the provided column names and values with the list of columns used.
 void processMetaData(javax.sql.DataSource dataSource, java.util.List<java.lang.String> declaredColumns, java.lang.String[] generatedKeyNames)
          Process the current meta data with the provided configuration options.
protected  java.util.List<java.lang.String> reconcileColumnsToUse(java.util.List<java.lang.String> declaredColumns, java.lang.String[] generatedKeyNames)
          Compare columns created from metadata with declared columns and return a reconciled list.
 void setAccessTableColumnMetaData(boolean accessTableColumnMetaData)
          Specify whether we should access table column meta data.
 void setCatalogName(java.lang.String catalogName)
          Set the name of the catalog for this context.
 void setNativeJdbcExtractor(NativeJdbcExtractor nativeJdbcExtractor)
          Set NativeJdbcExtractor to be used to retrieve the native connection.
 void setOverrideIncludeSynonymsDefault(boolean override)
          Specify whether we should override default for accessing synonyms.
 void setSchemaName(java.lang.String schemaName)
          Set the name of the schema for this context.
 void setTableName(java.lang.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 Detail

logger

protected final Log logger
Logger available to subclasses


tableName

private java.lang.String tableName
name of procedure to call


catalogName

private java.lang.String catalogName
name of catalog for call


schemaName

private java.lang.String schemaName
name of schema for call


tableColumns

private java.util.List<java.lang.String> tableColumns
List of columns objects to be used in this context


accessTableColumnMetaData

private boolean accessTableColumnMetaData
should we access insert parameter meta data info or not


overrideIncludeSynonymsDefault

private boolean overrideIncludeSynonymsDefault
should we override default for including synonyms for meta data lookups


metaDataProvider

private TableMetaDataProvider metaDataProvider
the provider of table meta data


generatedKeyColumnsUsed

private boolean generatedKeyColumnsUsed
are we using generated key columns


nativeJdbcExtractor

NativeJdbcExtractor nativeJdbcExtractor
NativeJdbcExtractor to be used to retrieve the native connection

Constructor Detail

TableMetaDataContext

public TableMetaDataContext()
Method Detail

setTableName

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


getTableName

public java.lang.String getTableName()
Get the name of the table for this context.


setCatalogName

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


getCatalogName

public java.lang.String getCatalogName()
Get the name of the catalog for this context.


setSchemaName

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


getSchemaName

public java.lang.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?


getTableColumns

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


isGetGeneratedKeysSupported

public boolean isGetGeneratedKeysSupported()
Does this database support the JDBC 3.0 feature of retrieving generated keys DatabaseMetaData.supportsGetGeneratedKeys()?


isGetGeneratedKeysSimulated

public boolean isGetGeneratedKeysSimulated()
Does this database support simple query to retrieve generated keys when the JDBC 3.0 feature is not supported. DatabaseMetaData.supportsGetGeneratedKeys()?


getSimulationQueryForGetGeneratedKey

public java.lang.String getSimulationQueryForGetGeneratedKey(java.lang.String tableName,
                                                             java.lang.String keyColumnName)
Does this database support simple query to retrieve generated keys when the JDBC 3.0 feature is not supported. DatabaseMetaData.supportsGetGeneratedKeys()?


isGeneratedKeysColumnNameArraySupported

public boolean isGeneratedKeysColumnNameArraySupported()
Is a column name String array for retrieving generated keys supported? Connection.createStruct(String, Object[])?


setNativeJdbcExtractor

public void setNativeJdbcExtractor(NativeJdbcExtractor nativeJdbcExtractor)
Set NativeJdbcExtractor to be used to retrieve the native connection.


processMetaData

public void processMetaData(javax.sql.DataSource dataSource,
                            java.util.List<java.lang.String> declaredColumns,
                            java.lang.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 java.util.List<java.lang.String> reconcileColumnsToUse(java.util.List<java.lang.String> declaredColumns,
                                                                 java.lang.String[] generatedKeyNames)
Compare columns created from metadata with declared columns and return a reconciled list.

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

matchInParameterValuesWithInsertColumns

public java.util.List<java.lang.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 java.util.List<java.lang.Object> matchInParameterValuesWithInsertColumns(java.util.Map<java.lang.String,java.lang.Object> inParameters)
Match the provided column names and values with the list of columns used.

Parameters:
inParameters - the parameter names and values

createInsertString

public java.lang.String createInsertString(java.lang.String[] generatedKeyNames)
Build the insert string based on configuration and metadata information

Returns:
the insert string to be used

createInsertTypes

public int[] createInsertTypes()
Build the array of Types based on configuration and metadata information

Returns:
the array of types to be used