001: /*
002: * Copyright 2002-2007 the original author or authors.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.springframework.jdbc.core.metadata;
018:
019: import java.sql.DatabaseMetaData;
020: import java.sql.SQLException;
021: import java.util.List;
022:
023: /**
024: * Interface specifying the API to be implemented by a class providing table metedata. This is intended for internal use
025: * by the Simple JDBC classes.
026: *
027: * @author Thomas Risberg
028: * @since 2.5
029: */
030: public interface TableMetaDataProvider {
031:
032: /**
033: * Initialize using the database metedata provided
034: * @param databaseMetaData
035: * @throws SQLException
036: */
037: void initializeWithMetaData(DatabaseMetaData databaseMetaData)
038: throws SQLException;
039:
040: /**
041: * Initialize using provided database metadata, table and column information. This initalization can be
042: * turned off by specifying that column meta data should not be used.
043: * @param databaseMetaData used to retreive database specific information
044: * @param catalogName name of catalog to use or null
045: * @param schemaName name of schema name to use or null
046: * @param tableName name of the table
047: * @throws SQLException
048: */
049: void initializeWithTableColumnMetaData(
050: DatabaseMetaData databaseMetaData, String catalogName,
051: String schemaName, String tableName) throws SQLException;
052:
053: /**
054: * Get the table name formatted based on metadata information. This could include altering the case.
055: *
056: * @param tableName
057: * @return table name formatted
058: */
059: String tableNameToUse(String tableName);
060:
061: /**
062: * Get the catalog name formatted based on metadata information. This could include altering the case.
063: *
064: * @param catalogName
065: * @return catalog name formatted
066: */
067: String catalogNameToUse(String catalogName);
068:
069: /**
070: * Get the schema name formatted based on metadata information. This could include altering the case.
071: *
072: * @param schemaName
073: * @return schema name formatted
074: */
075: String schemaNameToUse(String schemaName);
076:
077: /**
078: * Provide any modification of the catalog name passed in to match the meta data currently used.
079: * The reyurned value will be used for meta data lookups. This could include alterig the case used or
080: * providing a base catalog if mone provided.
081: *
082: * @param catalogName
083: * @return catalog name to use
084: */
085: String metaDataCatalogNameToUse(String catalogName);
086:
087: /**
088: * Provide any modification of the schema name passed in to match the meta data currently used.
089: * The reyurned value will be used for meta data lookups. This could include alterig the case used or
090: * providing a base schema if mone provided.
091: *
092: * @param schemaName
093: * @return schema name to use
094: */
095: String metaDataSchemaNameToUse(String schemaName);
096:
097: /**
098: * Are we using the meta data for the table columns?
099: */
100: boolean isTableColumnMetaDataUsed();
101:
102: /**
103: * Does this database support the JDBC 3.0 feature of retreiving generated keys
104: * {@link java.sql.DatabaseMetaData#supportsGetGeneratedKeys()}
105: */
106: boolean isGetGeneratedKeysSupported();
107:
108: /**
109: * Does this database support a simple quey to retreive the generated key whe the JDBC 3.0 feature
110: * of retreiving generated keys is not supported
111: * {@link java.sql.DatabaseMetaData#supportsGetGeneratedKeys()}
112: */
113: boolean isGetGeneratedKeysSimulated();
114:
115: /**
116: * Get the simple query to retreive a generated key
117: */
118: String getSimpleQueryForGetGeneratedKey(String tableName,
119: String keyColumnName);
120:
121: /**
122: * Does this database support a column name String array for retreiving generated keys
123: * {@link java.sql.Connection#createStruct(String, Object[])}
124: */
125: boolean isGeneratedKeysColumnNameArraySupported();
126:
127: /**
128: * Get the table parameter metadata that is currently used.
129: * @return List of {@link TableParameterMetaData}
130: */
131: List<TableParameterMetaData> getTableParameterMetaData();
132:
133: }
|