Consistent method declaration order in Call/TableMetaDataProvider
This commit is contained in:
parent
969b18b0e8
commit
a44341ece3
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2023 the original author or authors.
|
* Copyright 2002-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -677,7 +677,6 @@ public class CallMetaDataContext {
|
||||||
*/
|
*/
|
||||||
protected String createParameterBinding(SqlParameter parameter) {
|
protected String createParameterBinding(SqlParameter parameter) {
|
||||||
Assert.state(this.metaDataProvider != null, "No CallMetaDataProvider available");
|
Assert.state(this.metaDataProvider != null, "No CallMetaDataProvider available");
|
||||||
|
|
||||||
return (isNamedBinding() ? this.metaDataProvider.namedParameterBindingToUse(parameter.getName()) : "?");
|
return (isNamedBinding() ? this.metaDataProvider.namedParameterBindingToUse(parameter.getName()) : "?");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2023 the original author or authors.
|
* Copyright 2002-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -150,6 +150,11 @@ public interface CallMetaDataProvider {
|
||||||
@Nullable
|
@Nullable
|
||||||
String getUserName();
|
String getUserName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Are we using the meta-data for the procedure columns?
|
||||||
|
*/
|
||||||
|
boolean isProcedureColumnMetaDataUsed();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does this database support returning ResultSets that should be retrieved with the JDBC call:
|
* Does this database support returning ResultSets that should be retrieved with the JDBC call:
|
||||||
* {@link java.sql.Statement#getResultSet()}?
|
* {@link java.sql.Statement#getResultSet()}?
|
||||||
|
|
@ -168,11 +173,6 @@ public interface CallMetaDataProvider {
|
||||||
*/
|
*/
|
||||||
int getRefCursorSqlType();
|
int getRefCursorSqlType();
|
||||||
|
|
||||||
/**
|
|
||||||
* Are we using the meta-data for the procedure columns?
|
|
||||||
*/
|
|
||||||
boolean isProcedureColumnMetaDataUsed();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should we bypass the return parameter with the specified name?
|
* Should we bypass the return parameter with the specified name?
|
||||||
* <p>This allows the database specific implementation to skip the processing
|
* <p>This allows the database specific implementation to skip the processing
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2023 the original author or authors.
|
* Copyright 2002-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -53,6 +53,8 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
|
||||||
|
|
||||||
private final String userName;
|
private final String userName;
|
||||||
|
|
||||||
|
private boolean procedureColumnMetaDataUsed = false;
|
||||||
|
|
||||||
private boolean supportsCatalogsInProcedureCalls = true;
|
private boolean supportsCatalogsInProcedureCalls = true;
|
||||||
|
|
||||||
private boolean supportsSchemasInProcedureCalls = true;
|
private boolean supportsSchemasInProcedureCalls = true;
|
||||||
|
|
@ -61,8 +63,6 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
|
||||||
|
|
||||||
private boolean storesLowerCaseIdentifiers = false;
|
private boolean storesLowerCaseIdentifiers = false;
|
||||||
|
|
||||||
private boolean procedureColumnMetaDataUsed = false;
|
|
||||||
|
|
||||||
private final List<CallParameterMetaData> callParameterMetaData = new ArrayList<>();
|
private final List<CallParameterMetaData> callParameterMetaData = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -195,6 +195,11 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
|
||||||
return this.userName;
|
return this.userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isProcedureColumnMetaDataUsed() {
|
||||||
|
return this.procedureColumnMetaDataUsed;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isReturnResultSetSupported() {
|
public boolean isReturnResultSetSupported() {
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -210,17 +215,11 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
|
||||||
return Types.OTHER;
|
return Types.OTHER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isProcedureColumnMetaDataUsed() {
|
|
||||||
return this.procedureColumnMetaDataUsed;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean byPassReturnParameter(String parameterName) {
|
public boolean byPassReturnParameter(String parameterName) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify whether the database supports the use of catalog name in procedure calls.
|
* Specify whether the database supports the use of catalog name in procedure calls.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -47,38 +47,40 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
|
||||||
/** Logger available to subclasses. */
|
/** Logger available to subclasses. */
|
||||||
protected static final Log logger = LogFactory.getLog(TableMetaDataProvider.class);
|
protected static final Log logger = LogFactory.getLog(TableMetaDataProvider.class);
|
||||||
|
|
||||||
/** indicator whether column meta-data should be used. */
|
/** Database products we know not supporting the use of a String[] for generated keys. */
|
||||||
private boolean tableColumnMetaDataUsed = false;
|
private static final List<String> productsNotSupportingGeneratedKeysColumnNameArray =
|
||||||
|
Arrays.asList("Apache Derby", "HSQL Database Engine");
|
||||||
|
|
||||||
/** the version of the database. */
|
|
||||||
@Nullable
|
|
||||||
private String databaseVersion;
|
|
||||||
|
|
||||||
/** the name of the user currently connected. */
|
/** The name of the user currently connected. */
|
||||||
@Nullable
|
@Nullable
|
||||||
private final String userName;
|
private final String userName;
|
||||||
|
|
||||||
/** indicates whether the identifiers are uppercased. */
|
/** The version of the database. */
|
||||||
private boolean storesUpperCaseIdentifiers = true;
|
@Nullable
|
||||||
|
private String databaseVersion;
|
||||||
|
|
||||||
/** indicates whether the identifiers are lowercased. */
|
/** Indicates whether column meta-data has been used. */
|
||||||
private boolean storesLowerCaseIdentifiers = false;
|
private boolean tableColumnMetaDataUsed = false;
|
||||||
|
|
||||||
/** indicates whether generated keys retrieval is supported. */
|
/** Indicates whether generated keys retrieval is supported. */
|
||||||
private boolean getGeneratedKeysSupported = true;
|
private boolean getGeneratedKeysSupported = true;
|
||||||
|
|
||||||
/** indicates whether the use of a String[] for generated keys is supported. */
|
/** Indicates whether the use of a String[] for generated keys is supported. */
|
||||||
private boolean generatedKeysColumnNameArraySupported = true;
|
private boolean generatedKeysColumnNameArraySupported = true;
|
||||||
|
|
||||||
/** database products we know not supporting the use of a String[] for generated keys. */
|
/** Indicates whether the identifiers are uppercased. */
|
||||||
private final List<String> productsNotSupportingGeneratedKeysColumnNameArray =
|
private boolean storesUpperCaseIdentifiers = true;
|
||||||
Arrays.asList("Apache Derby", "HSQL Database Engine");
|
|
||||||
|
/** Indicates whether the identifiers are lowercased. */
|
||||||
|
private boolean storesLowerCaseIdentifiers = false;
|
||||||
|
|
||||||
|
/** The string used to quote SQL identifiers. */
|
||||||
|
private String identifierQuoteString = " ";
|
||||||
|
|
||||||
/** Collection of TableParameterMetaData objects. */
|
/** Collection of TableParameterMetaData objects. */
|
||||||
private final List<TableParameterMetaData> tableParameterMetaData = new ArrayList<>();
|
private final List<TableParameterMetaData> tableParameterMetaData = new ArrayList<>();
|
||||||
|
|
||||||
/** The string used to quote SQL identifiers. */
|
|
||||||
private String identifierQuoteString = " ";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor used to initialize with provided database meta-data.
|
* Constructor used to initialize with provided database meta-data.
|
||||||
|
|
@ -89,63 +91,6 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setStoresUpperCaseIdentifiers(boolean storesUpperCaseIdentifiers) {
|
|
||||||
this.storesUpperCaseIdentifiers = storesUpperCaseIdentifiers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isStoresUpperCaseIdentifiers() {
|
|
||||||
return this.storesUpperCaseIdentifiers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStoresLowerCaseIdentifiers(boolean storesLowerCaseIdentifiers) {
|
|
||||||
this.storesLowerCaseIdentifiers = storesLowerCaseIdentifiers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isStoresLowerCaseIdentifiers() {
|
|
||||||
return this.storesLowerCaseIdentifiers;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isTableColumnMetaDataUsed() {
|
|
||||||
return this.tableColumnMetaDataUsed;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<TableParameterMetaData> getTableParameterMetaData() {
|
|
||||||
return this.tableParameterMetaData;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isGetGeneratedKeysSupported() {
|
|
||||||
return this.getGeneratedKeysSupported;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isGetGeneratedKeysSimulated(){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nullable
|
|
||||||
public String getSimpleQueryForGetGeneratedKey(String tableName, String keyColumnName) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGetGeneratedKeysSupported(boolean getGeneratedKeysSupported) {
|
|
||||||
this.getGeneratedKeysSupported = getGeneratedKeysSupported;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGeneratedKeysColumnNameArraySupported(boolean generatedKeysColumnNameArraySupported) {
|
|
||||||
this.generatedKeysColumnNameArraySupported = generatedKeysColumnNameArraySupported;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isGeneratedKeysColumnNameArraySupported() {
|
|
||||||
return this.generatedKeysColumnNameArraySupported;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initializeWithMetaData(DatabaseMetaData databaseMetaData) throws SQLException {
|
public void initializeWithMetaData(DatabaseMetaData databaseMetaData) throws SQLException {
|
||||||
try {
|
try {
|
||||||
|
|
@ -165,7 +110,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
String databaseProductName = databaseMetaData.getDatabaseProductName();
|
String databaseProductName = databaseMetaData.getDatabaseProductName();
|
||||||
if (this.productsNotSupportingGeneratedKeysColumnNameArray.contains(databaseProductName)) {
|
if (productsNotSupportingGeneratedKeysColumnNameArray.contains(databaseProductName)) {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("GeneratedKeysColumnNameArray is not supported for " + databaseProductName);
|
logger.debug("GeneratedKeysColumnNameArray is not supported for " + databaseProductName);
|
||||||
}
|
}
|
||||||
|
|
@ -234,6 +179,11 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
|
||||||
locateTableAndProcessMetaData(databaseMetaData, catalogName, schemaName, tableName);
|
locateTableAndProcessMetaData(databaseMetaData, catalogName, schemaName, tableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TableParameterMetaData> getTableParameterMetaData() {
|
||||||
|
return this.tableParameterMetaData;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public String tableNameToUse(@Nullable String tableName) {
|
public String tableNameToUse(@Nullable String tableName) {
|
||||||
|
|
@ -305,16 +255,62 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
|
||||||
return this.databaseVersion;
|
return this.databaseVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Provide access to the identifier quote string.
|
public boolean isTableColumnMetaDataUsed() {
|
||||||
* @since 6.1
|
return this.tableColumnMetaDataUsed;
|
||||||
* @see java.sql.DatabaseMetaData#getIdentifierQuoteString()
|
}
|
||||||
*/
|
|
||||||
|
public void setGetGeneratedKeysSupported(boolean getGeneratedKeysSupported) {
|
||||||
|
this.getGeneratedKeysSupported = getGeneratedKeysSupported;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isGetGeneratedKeysSupported() {
|
||||||
|
return this.getGeneratedKeysSupported;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isGetGeneratedKeysSimulated(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public String getSimpleQueryForGetGeneratedKey(String tableName, String keyColumnName) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGeneratedKeysColumnNameArraySupported(boolean generatedKeysColumnNameArraySupported) {
|
||||||
|
this.generatedKeysColumnNameArraySupported = generatedKeysColumnNameArraySupported;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isGeneratedKeysColumnNameArraySupported() {
|
||||||
|
return this.generatedKeysColumnNameArraySupported;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStoresUpperCaseIdentifiers(boolean storesUpperCaseIdentifiers) {
|
||||||
|
this.storesUpperCaseIdentifiers = storesUpperCaseIdentifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isStoresUpperCaseIdentifiers() {
|
||||||
|
return this.storesUpperCaseIdentifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStoresLowerCaseIdentifiers(boolean storesLowerCaseIdentifiers) {
|
||||||
|
this.storesLowerCaseIdentifiers = storesLowerCaseIdentifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isStoresLowerCaseIdentifiers() {
|
||||||
|
return this.storesLowerCaseIdentifiers;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getIdentifierQuoteString() {
|
public String getIdentifierQuoteString() {
|
||||||
return this.identifierQuoteString;
|
return this.identifierQuoteString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method supporting the meta-data processing for a table.
|
* Method supporting the meta-data processing for a table.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -64,18 +64,12 @@ public class TableMetaDataContext {
|
||||||
@Nullable
|
@Nullable
|
||||||
private String schemaName;
|
private String schemaName;
|
||||||
|
|
||||||
// List of columns objects to be used in this context
|
|
||||||
private List<String> tableColumns = new ArrayList<>();
|
|
||||||
|
|
||||||
// Should we access insert parameter meta-data info or not
|
// Should we access insert parameter meta-data info or not
|
||||||
private boolean accessTableColumnMetaData = true;
|
private boolean accessTableColumnMetaData = true;
|
||||||
|
|
||||||
// Should we override default for including synonyms for meta-data lookups
|
// Should we override default for including synonyms for meta-data lookups
|
||||||
private boolean overrideIncludeSynonymsDefault = false;
|
private boolean overrideIncludeSynonymsDefault = false;
|
||||||
|
|
||||||
// Are we using generated key columns?
|
|
||||||
private boolean generatedKeyColumnsUsed = false;
|
|
||||||
|
|
||||||
// Are we quoting identifiers?
|
// Are we quoting identifiers?
|
||||||
private boolean quoteIdentifiers = false;
|
private boolean quoteIdentifiers = false;
|
||||||
|
|
||||||
|
|
@ -83,6 +77,12 @@ public class TableMetaDataContext {
|
||||||
@Nullable
|
@Nullable
|
||||||
private TableMetaDataProvider metaDataProvider;
|
private TableMetaDataProvider metaDataProvider;
|
||||||
|
|
||||||
|
// List of columns objects to be used in this context
|
||||||
|
private List<String> tableColumns = new ArrayList<>();
|
||||||
|
|
||||||
|
// Are we using generated key columns
|
||||||
|
private boolean generatedKeyColumnsUsed = false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the name of the table for this context.
|
* Set the name of the table for this context.
|
||||||
|
|
@ -343,8 +343,8 @@ public class TableMetaDataContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String message = "Unable to locate columns for table '" + tableName
|
String message = "Unable to locate columns for table '" + tableName +
|
||||||
+ "' so an insert statement can't be generated.";
|
"' so an insert statement can't be generated.";
|
||||||
if (isAccessTableColumnMetaData()) {
|
if (isAccessTableColumnMetaData()) {
|
||||||
message += " Consider specifying explicit column names -- for example, via SimpleJdbcInsert#usingColumns().";
|
message += " Consider specifying explicit column names -- for example, via SimpleJdbcInsert#usingColumns().";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2023 the original author or authors.
|
* Copyright 2002-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -53,6 +53,12 @@ public interface TableMetaDataProvider {
|
||||||
void initializeWithTableColumnMetaData(DatabaseMetaData databaseMetaData, @Nullable String catalogName,
|
void initializeWithTableColumnMetaData(DatabaseMetaData databaseMetaData, @Nullable String catalogName,
|
||||||
@Nullable String schemaName, @Nullable String tableName) throws SQLException;
|
@Nullable String schemaName, @Nullable String tableName) throws SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the table parameter meta-data that is currently used.
|
||||||
|
* @return a List of {@link TableParameterMetaData}
|
||||||
|
*/
|
||||||
|
List<TableParameterMetaData> getTableParameterMetaData();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the table name formatted based on meta-data information.
|
* Get the table name formatted based on meta-data information.
|
||||||
* <p>This could include altering the case.
|
* <p>This could include altering the case.
|
||||||
|
|
@ -136,12 +142,6 @@ public interface TableMetaDataProvider {
|
||||||
*/
|
*/
|
||||||
boolean isGeneratedKeysColumnNameArraySupported();
|
boolean isGeneratedKeysColumnNameArraySupported();
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the table parameter meta-data that is currently used.
|
|
||||||
* @return a List of {@link TableParameterMetaData}
|
|
||||||
*/
|
|
||||||
List<TableParameterMetaData> getTableParameterMetaData();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the string used to quote SQL identifiers.
|
* Get the string used to quote SQL identifiers.
|
||||||
* <p>This method returns a space ({@code " "}) if identifier quoting is not
|
* <p>This method returns a space ({@code " "}) if identifier quoting is not
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue