public class GenericTableMetaDataProvider extends java.lang.Object implements TableMetaDataProvider
TableMetaDataProvider
that should provide
enough features for all supported databases.Modifier and Type | Class and Description |
---|---|
private static class |
GenericTableMetaDataProvider.TableMetaData
Inner class representing table meta data.
|
Modifier and Type | Field and Description |
---|---|
private java.lang.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
|
protected static Log |
logger
Logger available to subclasses
|
private NativeJdbcExtractor |
nativeJdbcExtractor
NativeJdbcExtractor that can be used to retrieve the native connection
|
private java.util.List<java.lang.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
indicator whether column metadata should be used
|
private java.util.List<TableParameterMetaData> |
tableParameterMetaData
Collection of TableParameterMetaData objects
|
private java.lang.String |
userName
the name of the user currently connected
|
Modifier | Constructor and Description |
---|---|
protected |
GenericTableMetaDataProvider(java.sql.DatabaseMetaData databaseMetaData)
Constructor used to initialize with provided database meta data.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
catalogNameToUse(java.lang.String catalogName)
Get the catalog name formatted based on metadata information.
|
protected java.lang.String |
getDatabaseVersion()
Provide access to version info for subclasses.
|
protected java.lang.String |
getDefaultSchema()
Provide access to default schema for subclasses.
|
protected NativeJdbcExtractor |
getNativeJdbcExtractor() |
java.lang.String |
getSimpleQueryForGetGeneratedKey(java.lang.String tableName,
java.lang.String keyColumnName)
Get the simple query to retrieve a generated key
|
java.util.List<TableParameterMetaData> |
getTableParameterMetaData()
Get the table parameter metadata that is currently used.
|
void |
initializeWithMetaData(java.sql.DatabaseMetaData databaseMetaData)
Initialize using the database metedata provided
|
void |
initializeWithTableColumnMetaData(java.sql.DatabaseMetaData databaseMetaData,
java.lang.String catalogName,
java.lang.String schemaName,
java.lang.String tableName)
Initialize using provided database metadata, table and column information.
|
boolean |
isGeneratedKeysColumnNameArraySupported()
Does this database support a column name String array for retreiving generated keys
Connection.createStruct(String, Object[]) |
boolean |
isGetGeneratedKeysSimulated()
Does this database support a simple quey to retrieve the generated key whe the JDBC 3.0 feature
of retreiving generated keys is not supported
DatabaseMetaData.supportsGetGeneratedKeys() |
boolean |
isGetGeneratedKeysSupported()
Does this database support the JDBC 3.0 feature of retreiving generated keys
DatabaseMetaData.supportsGetGeneratedKeys() |
boolean |
isStoresLowerCaseIdentifiers() |
boolean |
isStoresUpperCaseIdentifiers() |
boolean |
isTableColumnMetaDataUsed()
Are we using the meta data for the table columns?
|
private void |
locateTableAndProcessMetaData(java.sql.DatabaseMetaData databaseMetaData,
java.lang.String catalogName,
java.lang.String schemaName,
java.lang.String tableName)
Method supporting the metedata processing for a table.
|
java.lang.String |
metaDataCatalogNameToUse(java.lang.String catalogName)
Provide any modification of the catalog name passed in to match the meta data currently used.
|
java.lang.String |
metaDataSchemaNameToUse(java.lang.String schemaName)
Provide any modification of the schema name passed in to match the meta data currently used.
|
private void |
processTableColumns(java.sql.DatabaseMetaData databaseMetaData,
GenericTableMetaDataProvider.TableMetaData tmd)
Method supporting the metadata processing for a table's columns
|
java.lang.String |
schemaNameToUse(java.lang.String schemaName)
Get the schema name formatted based on metadata information.
|
void |
setGeneratedKeysColumnNameArraySupported(boolean generatedKeysColumnNameArraySupported) |
void |
setGetGeneratedKeysSupported(boolean getGeneratedKeysSupported) |
void |
setNativeJdbcExtractor(NativeJdbcExtractor nativeJdbcExtractor)
Set the
NativeJdbcExtractor to use to retrieve the native connection if necessary |
void |
setStoresLowerCaseIdentifiers(boolean storesLowerCaseIdentifiers) |
void |
setStoresUpperCaseIdentifiers(boolean storesUpperCaseIdentifiers) |
java.lang.String |
tableNameToUse(java.lang.String tableName)
Get the table name formatted based on metadata information.
|
protected static final Log logger
private boolean tableColumnMetaDataUsed
private java.lang.String databaseVersion
private java.lang.String userName
private boolean storesUpperCaseIdentifiers
private boolean storesLowerCaseIdentifiers
private boolean getGeneratedKeysSupported
private boolean generatedKeysColumnNameArraySupported
private java.util.List<java.lang.String> productsNotSupportingGeneratedKeysColumnNameArray
private java.util.List<TableParameterMetaData> tableParameterMetaData
private NativeJdbcExtractor nativeJdbcExtractor
protected GenericTableMetaDataProvider(java.sql.DatabaseMetaData databaseMetaData) throws java.sql.SQLException
databaseMetaData
- meta data to be usedjava.sql.SQLException
public void setStoresUpperCaseIdentifiers(boolean storesUpperCaseIdentifiers)
public boolean isStoresUpperCaseIdentifiers()
public void setStoresLowerCaseIdentifiers(boolean storesLowerCaseIdentifiers)
public boolean isStoresLowerCaseIdentifiers()
public boolean isTableColumnMetaDataUsed()
TableMetaDataProvider
isTableColumnMetaDataUsed
in interface TableMetaDataProvider
public java.util.List<TableParameterMetaData> getTableParameterMetaData()
TableMetaDataProvider
getTableParameterMetaData
in interface TableMetaDataProvider
TableParameterMetaData
public boolean isGetGeneratedKeysSupported()
TableMetaDataProvider
DatabaseMetaData.supportsGetGeneratedKeys()
isGetGeneratedKeysSupported
in interface TableMetaDataProvider
public boolean isGetGeneratedKeysSimulated()
TableMetaDataProvider
DatabaseMetaData.supportsGetGeneratedKeys()
isGetGeneratedKeysSimulated
in interface TableMetaDataProvider
public java.lang.String getSimpleQueryForGetGeneratedKey(java.lang.String tableName, java.lang.String keyColumnName)
TableMetaDataProvider
getSimpleQueryForGetGeneratedKey
in interface TableMetaDataProvider
public void setGetGeneratedKeysSupported(boolean getGeneratedKeysSupported)
public void setGeneratedKeysColumnNameArraySupported(boolean generatedKeysColumnNameArraySupported)
public boolean isGeneratedKeysColumnNameArraySupported()
TableMetaDataProvider
Connection.createStruct(String, Object[])
isGeneratedKeysColumnNameArraySupported
in interface TableMetaDataProvider
public void setNativeJdbcExtractor(NativeJdbcExtractor nativeJdbcExtractor)
TableMetaDataProvider
NativeJdbcExtractor
to use to retrieve the native connection if necessarysetNativeJdbcExtractor
in interface TableMetaDataProvider
protected NativeJdbcExtractor getNativeJdbcExtractor()
public void initializeWithMetaData(java.sql.DatabaseMetaData databaseMetaData) throws java.sql.SQLException
TableMetaDataProvider
initializeWithMetaData
in interface TableMetaDataProvider
java.sql.SQLException
public void initializeWithTableColumnMetaData(java.sql.DatabaseMetaData databaseMetaData, java.lang.String catalogName, java.lang.String schemaName, java.lang.String tableName) throws java.sql.SQLException
TableMetaDataProvider
initializeWithTableColumnMetaData
in interface TableMetaDataProvider
databaseMetaData
- used to retrieve database specific informationcatalogName
- name of catalog to use or nullschemaName
- name of schema name to use or nulltableName
- name of the tablejava.sql.SQLException
public java.lang.String tableNameToUse(java.lang.String tableName)
TableMetaDataProvider
tableNameToUse
in interface TableMetaDataProvider
public java.lang.String catalogNameToUse(java.lang.String catalogName)
TableMetaDataProvider
catalogNameToUse
in interface TableMetaDataProvider
public java.lang.String schemaNameToUse(java.lang.String schemaName)
TableMetaDataProvider
schemaNameToUse
in interface TableMetaDataProvider
public java.lang.String metaDataCatalogNameToUse(java.lang.String catalogName)
TableMetaDataProvider
metaDataCatalogNameToUse
in interface TableMetaDataProvider
public java.lang.String metaDataSchemaNameToUse(java.lang.String schemaName)
TableMetaDataProvider
metaDataSchemaNameToUse
in interface TableMetaDataProvider
protected java.lang.String getDefaultSchema()
protected java.lang.String getDatabaseVersion()
private void locateTableAndProcessMetaData(java.sql.DatabaseMetaData databaseMetaData, java.lang.String catalogName, java.lang.String schemaName, java.lang.String tableName)
private void processTableColumns(java.sql.DatabaseMetaData databaseMetaData, GenericTableMetaDataProvider.TableMetaData tmd)