Fix and improve Javadoc in spring-jdbc
Closes gh-28796
This commit is contained in:
@@ -54,7 +54,7 @@ public class ArgumentPreparedStatementSetter implements PreparedStatementSetter,
|
||||
|
||||
/**
|
||||
* Set the value for prepared statements specified parameter index using the passed in value.
|
||||
* This method can be overridden by sub-classes if needed.
|
||||
* This method can be overridden by subclasses if needed.
|
||||
* @param ps the PreparedStatement
|
||||
* @param parameterPosition index of the parameter position
|
||||
* @param argValue the value to set
|
||||
|
||||
@@ -87,7 +87,7 @@ public class ArgumentTypePreparedStatementSetter implements PreparedStatementSet
|
||||
|
||||
/**
|
||||
* Set the value for the prepared statement's specified parameter position using the passed in
|
||||
* value and type. This method can be overridden by sub-classes if needed.
|
||||
* value and type. This method can be overridden by subclasses if needed.
|
||||
* @param ps the PreparedStatement
|
||||
* @param parameterPosition index of the parameter position
|
||||
* @param argType the argument type
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -109,7 +109,7 @@ public class CallableStatementCreatorFactory {
|
||||
|
||||
|
||||
/**
|
||||
* Return a new CallableStatementCreator instance given this parameters.
|
||||
* Return a new CallableStatementCreator instance given these parameters.
|
||||
* @param params list of parameters (may be {@code null})
|
||||
*/
|
||||
public CallableStatementCreator newCallableStatementCreator(@Nullable Map<String, ?> params) {
|
||||
|
||||
@@ -84,7 +84,7 @@ public class ColumnMapRowMapper implements RowMapper<Map<String, Object>> {
|
||||
* Retrieve a JDBC object value for the specified column.
|
||||
* <p>The default implementation uses the {@code getObject} method.
|
||||
* Additionally, this implementation includes a "hack" to get around Oracle
|
||||
* returning a non standard object for their TIMESTAMP data type.
|
||||
* returning a non-standard object for their TIMESTAMP data type.
|
||||
* @param rs the ResultSet holding the data
|
||||
* @param index the column index
|
||||
* @return the Object returned
|
||||
|
||||
@@ -234,7 +234,7 @@ public interface JdbcOperations {
|
||||
* Each element in the list will be of the form returned by this interface's
|
||||
* {@code queryForMap} methods.
|
||||
* @param sql the SQL query to execute
|
||||
* @return an List that contains a Map per row
|
||||
* @return a List that contains a Map per row
|
||||
* @throws DataAccessException if there is any problem executing the query
|
||||
* @see #queryForList(String, Object...)
|
||||
*/
|
||||
|
||||
@@ -111,7 +111,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
private static final String RETURN_UPDATE_COUNT_PREFIX = "#update-count-";
|
||||
|
||||
|
||||
/** If this variable is false, we will throw exceptions on SQL warnings. */
|
||||
/** If this variable is {@code false}, we will throw exceptions on SQL warnings. */
|
||||
private boolean ignoreWarnings = true;
|
||||
|
||||
/**
|
||||
@@ -149,7 +149,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
|
||||
/**
|
||||
* If this variable is set to true then execution of a CallableStatement will return
|
||||
* the results in a Map that uses case insensitive names for the parameters.
|
||||
* the results in a Map that uses case-insensitive names for the parameters.
|
||||
*/
|
||||
private boolean resultsMapCaseInsensitive = false;
|
||||
|
||||
@@ -187,7 +187,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
|
||||
|
||||
/**
|
||||
* Set whether or not we want to ignore SQLWarnings.
|
||||
* Set whether we want to ignore SQLWarnings.
|
||||
* <p>Default is "true", swallowing and logging all warnings. Switch this flag
|
||||
* to "false" to make the JdbcTemplate throw an SQLWarningException instead.
|
||||
* @see java.sql.SQLWarning
|
||||
@@ -199,7 +199,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether or not we ignore SQLWarnings.
|
||||
* Return whether we ignore SQLWarnings.
|
||||
*/
|
||||
public boolean isIgnoreWarnings() {
|
||||
return this.ignoreWarnings;
|
||||
@@ -303,7 +303,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
|
||||
/**
|
||||
* Set whether execution of a CallableStatement will return the results in a Map
|
||||
* that uses case insensitive names for the parameters.
|
||||
* that uses case-insensitive names for the parameters.
|
||||
*/
|
||||
public void setResultsMapCaseInsensitive(boolean resultsMapCaseInsensitive) {
|
||||
this.resultsMapCaseInsensitive = resultsMapCaseInsensitive;
|
||||
@@ -311,7 +311,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
|
||||
/**
|
||||
* Return whether execution of a CallableStatement will return the results in a Map
|
||||
* that uses case insensitive names for the parameters.
|
||||
* that uses case-insensitive names for the parameters.
|
||||
*/
|
||||
public boolean isResultsMapCaseInsensitive() {
|
||||
return this.resultsMapCaseInsensitive;
|
||||
|
||||
@@ -478,7 +478,7 @@ public class CallMetaDataContext {
|
||||
*/
|
||||
public Map<String, Object> matchInParameterValuesWithCallParameters(SqlParameterSource parameterSource) {
|
||||
// For parameter source lookups we need to provide case-insensitive lookup support
|
||||
// since the database meta-data is not necessarily providing case sensitive parameter names.
|
||||
// since the database meta-data is not necessarily providing case-sensitive parameter names.
|
||||
Map<String, String> caseInsensitiveParameterNames =
|
||||
SqlParameterSourceUtils.extractCaseInsensitiveParameterNames(parameterSource);
|
||||
|
||||
|
||||
@@ -406,7 +406,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
|
||||
* @param sql the SQL statement to execute
|
||||
* @param paramSource container of arguments to bind
|
||||
* @param customizer callback for setting further properties on the
|
||||
* {@link PreparedStatementCreatorFactory} in use), applied before the
|
||||
* {@link PreparedStatementCreatorFactory} in use, applied before the
|
||||
* actual {@code newPreparedStatementCreator} call
|
||||
* @return the corresponding {@link PreparedStatementCreator}
|
||||
* @since 5.0.5
|
||||
|
||||
@@ -69,7 +69,7 @@ public class ParsedSql {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all of the parameters (bind variables) in the parsed SQL statement.
|
||||
* Return all the parameters (bind variables) in the parsed SQL statement.
|
||||
* Repeated occurrences of the same parameter name are included here.
|
||||
*/
|
||||
List<String> getParameterNames() {
|
||||
@@ -81,7 +81,7 @@ public class ParsedSql {
|
||||
* @param parameterPosition the position of the parameter
|
||||
* (as index in the parameter names List)
|
||||
* @return the start index and end index, combined into
|
||||
* a int array of length 2
|
||||
* an int array of length 2
|
||||
*/
|
||||
int[] getParameterIndexes(int parameterPosition) {
|
||||
return this.parameterIndexes.get(parameterPosition);
|
||||
@@ -104,21 +104,21 @@ public class ParsedSql {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the count of all of the unnamed parameters in the SQL statement.
|
||||
* Set the count of all the unnamed parameters in the SQL statement.
|
||||
*/
|
||||
void setUnnamedParameterCount(int unnamedParameterCount) {
|
||||
this.unnamedParameterCount = unnamedParameterCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the count of all of the unnamed parameters in the SQL statement.
|
||||
* Return the count of all the unnamed parameters in the SQL statement.
|
||||
*/
|
||||
int getUnnamedParameterCount() {
|
||||
return this.unnamedParameterCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the total count of all of the parameters in the SQL statement.
|
||||
* Set the total count of all the parameters in the SQL statement.
|
||||
* Repeated occurrences of the same parameter name do count here.
|
||||
*/
|
||||
void setTotalParameterCount(int totalParameterCount) {
|
||||
@@ -126,7 +126,7 @@ public class ParsedSql {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the total count of all of the parameters in the SQL statement.
|
||||
* Return the total count of all the parameters in the SQL statement.
|
||||
* Repeated occurrences of the same parameter name do count here.
|
||||
*/
|
||||
int getTotalParameterCount() {
|
||||
|
||||
@@ -106,9 +106,9 @@ public abstract class SqlParameterSourceUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Map of case insensitive parameter names together with the original name.
|
||||
* Create a Map of case-insensitive parameter names together with the original name.
|
||||
* @param parameterSource the source of parameter names
|
||||
* @return the Map that can be used for case insensitive matching of parameter names
|
||||
* @return the Map that can be used for case-insensitive matching of parameter names
|
||||
*/
|
||||
public static Map<String, String> extractCaseInsensitiveParameterNames(SqlParameterSource parameterSource) {
|
||||
Map<String, String> caseInsensitiveParameterNames = new HashMap<>();
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.springframework.jdbc.core.SqlParameter;
|
||||
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
||||
|
||||
/**
|
||||
* A SimpleJdbcCall is a multi-threaded, reusable object representing a call
|
||||
* A SimpleJdbcCall is a multithreaded, reusable object representing a call
|
||||
* to a stored procedure or a stored function. It provides meta-data processing
|
||||
* to simplify the code needed to access basic stored procedures/functions.
|
||||
* All you need to provide is the name of the procedure/function and a Map
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
||||
import org.springframework.jdbc.support.KeyHolder;
|
||||
|
||||
/**
|
||||
* A SimpleJdbcInsert is a multi-threaded, reusable object providing easy insert
|
||||
* A SimpleJdbcInsert is a multithreaded, reusable object providing easy insert
|
||||
* capabilities for a table. It provides meta-data processing to simplify the code
|
||||
* needed to construct a basic insert statement. All you need to provide is the
|
||||
* name of the table and a Map containing the column names and the column values.
|
||||
|
||||
@@ -195,7 +195,7 @@ public class DataSourceTransactionManager extends AbstractPlatformTransactionMan
|
||||
|
||||
/**
|
||||
* Specify whether to enforce the read-only nature of a transaction
|
||||
* (as indicated by {@link TransactionDefinition#isReadOnly()}
|
||||
* (as indicated by {@link TransactionDefinition#isReadOnly()})
|
||||
* through an explicit statement on the transactional connection:
|
||||
* "SET TRANSACTION READ ONLY" as understood by Oracle, MySQL and Postgres.
|
||||
* <p>The exact treatment, including any SQL statement executed on the connection,
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.springframework.util.ClassUtils;
|
||||
* connection pool, implementing the same standard interface, but creating new
|
||||
* Connections on every call.
|
||||
*
|
||||
* <p>Useful for test or standalone environments outside of a Java EE container, either
|
||||
* <p>Useful for test or standalone environments outside a Java EE container, either
|
||||
* as a DataSource bean in a corresponding ApplicationContext or in conjunction with
|
||||
* a simple JNDI environment. Pool-assuming {@code Connection.close()} calls will
|
||||
* simply close the Connection, so any DataSource-aware persistence code should work.
|
||||
|
||||
@@ -25,7 +25,7 @@ import javax.sql.DataSource;
|
||||
* implemented by special DataSources that return JDBC Connections
|
||||
* in an unwrapped fashion.
|
||||
*
|
||||
* <p>Classes using this interface can query whether or not the Connection
|
||||
* <p>Classes using this interface can query whether the Connection
|
||||
* should be closed after an operation. Spring's DataSourceUtils and
|
||||
* JdbcTemplate classes automatically perform such a check.
|
||||
*
|
||||
|
||||
@@ -122,7 +122,7 @@ public class UserCredentialsDataSourceAdapter extends DelegatingDataSource {
|
||||
|
||||
|
||||
/**
|
||||
* Set user credententials for this proxy and the current thread.
|
||||
* Set user credentials for this proxy and the current thread.
|
||||
* The given username and password will be applied to all subsequent
|
||||
* {@code getConnection()} calls on this DataSource proxy.
|
||||
* <p>This will override any statically specified user credentials,
|
||||
|
||||
@@ -209,7 +209,7 @@ public class EmbeddedDatabaseFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook to shutdown the embedded database. Subclasses may call this method
|
||||
* Hook to shut down the embedded database. Subclasses may call this method
|
||||
* to force shutdown.
|
||||
* <p>After calling, {@link #getDataSource()} returns {@code null}.
|
||||
* <p>Does nothing if no embedded database has been initialized.
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.springframework.lang.Nullable;
|
||||
* proxy since the {@link FactoryBean} will manage the initialization and destruction
|
||||
* lifecycle of the embedded database instance.
|
||||
*
|
||||
* <p>Implements {@link DisposableBean} to shutdown the embedded database when the
|
||||
* <p>Implements {@link DisposableBean} to shut down the embedded database when the
|
||||
* managing Spring container is being closed.
|
||||
*
|
||||
* @author Keith Donald
|
||||
|
||||
@@ -161,9 +161,9 @@ public abstract class ScriptUtils {
|
||||
* configured and ready to use
|
||||
* @param resource the resource (potentially associated with a specific encoding)
|
||||
* to load the SQL script from
|
||||
* @param continueOnError whether or not to continue without throwing an exception
|
||||
* @param continueOnError whether to continue without throwing an exception
|
||||
* in the event of an error
|
||||
* @param ignoreFailedDrops whether or not to continue in the event of specifically
|
||||
* @param ignoreFailedDrops whether to continue in the event of specifically
|
||||
* an error on a {@code DROP} statement
|
||||
* @param commentPrefix the prefix that identifies single-line comments in the
|
||||
* SQL script (typically "--")
|
||||
@@ -200,9 +200,9 @@ public abstract class ScriptUtils {
|
||||
* configured and ready to use
|
||||
* @param resource the resource (potentially associated with a specific encoding)
|
||||
* to load the SQL script from
|
||||
* @param continueOnError whether or not to continue without throwing an exception
|
||||
* @param continueOnError whether to continue without throwing an exception
|
||||
* in the event of an error
|
||||
* @param ignoreFailedDrops whether or not to continue in the event of specifically
|
||||
* @param ignoreFailedDrops whether to continue in the event of specifically
|
||||
* an error on a {@code DROP} statement
|
||||
* @param commentPrefixes the prefixes that identify single-line comments in the
|
||||
* SQL script (typically "--")
|
||||
|
||||
@@ -39,7 +39,7 @@ public class DataSourceLookupFailureException extends NonTransientDataAccessExce
|
||||
/**
|
||||
* Constructor for DataSourceLookupFailureException.
|
||||
* @param msg the detail message
|
||||
* @param cause the root cause (usually from using a underlying
|
||||
* @param cause the root cause (usually from using an underlying
|
||||
* lookup API such as JNDI)
|
||||
*/
|
||||
public DataSourceLookupFailureException(String msg, Throwable cause) {
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* An "RDBMS operation" is a multi-threaded, reusable object representing a query,
|
||||
* An "RDBMS operation" is a multithreaded, reusable object representing a query,
|
||||
* update, or stored procedure call. An RDBMS operation is <b>not</b> a command,
|
||||
* as a command is not reusable. However, execute methods may take commands as
|
||||
* arguments. Subclasses should be JavaBeans, allowing easy configuration.
|
||||
|
||||
@@ -49,7 +49,7 @@ public abstract class SqlCall extends RdbmsOperation {
|
||||
|
||||
/**
|
||||
* Flag used to indicate that the sql for this call should be used exactly as
|
||||
* it is defined. No need to add the escape syntax and parameter place holders.
|
||||
* it is defined. No need to add the escape syntax and parameter placeholders.
|
||||
*/
|
||||
private boolean sqlReadyForUse = false;
|
||||
|
||||
@@ -184,7 +184,7 @@ public abstract class SqlCall extends RdbmsOperation {
|
||||
|
||||
/**
|
||||
* Return a CallableStatementCreator to perform an operation
|
||||
* with this parameters.
|
||||
* with these parameters.
|
||||
* @param inParams parameters. May be {@code null}.
|
||||
*/
|
||||
protected CallableStatementCreator newCallableStatementCreator(@Nullable Map<String, ?> inParams) {
|
||||
|
||||
@@ -71,13 +71,13 @@ public abstract class UpdatableSqlQuery<T> extends SqlQuery<T> {
|
||||
* ResultSet and optionally create object of the result type.
|
||||
* @param rs the ResultSet we're working through
|
||||
* @param rowNum row number (from 0) we're up to
|
||||
* @param context passed to the execute() method.
|
||||
* @param context passed to the {@code execute()} method.
|
||||
* It can be {@code null} if no contextual information is need. If you
|
||||
* need to pass in data for each row, you can pass in a HashMap with
|
||||
* the primary key of the row being the key for the HashMap. That way
|
||||
* it is easy to locate the updates for each row
|
||||
* @return an object of the result type
|
||||
* @throws SQLException if there's an error updateing data.
|
||||
* @throws SQLException if there's an error updating data.
|
||||
* Subclasses can simply not catch SQLExceptions, relying on the
|
||||
* framework to clean up.
|
||||
*/
|
||||
|
||||
@@ -501,7 +501,7 @@ public abstract class JdbcUtils {
|
||||
* <p><i>columnLabel - the label for the column specified with the SQL AS clause.
|
||||
* If the SQL AS clause was not specified, then the label is the name of the column</i>.
|
||||
* @param resultSetMetaData the current meta-data to use
|
||||
* @param columnIndex the index of the column for the look up
|
||||
* @param columnIndex the index of the column for the lookup
|
||||
* @return the column name to use
|
||||
* @throws SQLException in case of lookup failure
|
||||
*/
|
||||
|
||||
@@ -73,7 +73,7 @@ public class MySQLMaxValueIncrementer extends AbstractColumnMaxValueIncrementer
|
||||
/** The max id to serve. */
|
||||
private long maxId = 0;
|
||||
|
||||
/** Whether or not to use a new connection for the incrementer. */
|
||||
/** Whether to use a new connection for the incrementer. */
|
||||
private boolean useNewConnection = true;
|
||||
|
||||
|
||||
|
||||
@@ -246,7 +246,7 @@ public interface SqlRowSet extends Serializable {
|
||||
/**
|
||||
* Retrieve the value of the indicated column in the current row as an Object.
|
||||
* @param columnIndex the column index
|
||||
* @return a Object representing the column value
|
||||
* @return an Object representing the column value
|
||||
* @see java.sql.ResultSet#getObject(int)
|
||||
*/
|
||||
@Nullable
|
||||
@@ -255,7 +255,7 @@ public interface SqlRowSet extends Serializable {
|
||||
/**
|
||||
* Retrieve the value of the indicated column in the current row as an Object.
|
||||
* @param columnLabel the column label
|
||||
* @return a Object representing the column value
|
||||
* @return an Object representing the column value
|
||||
* @see java.sql.ResultSet#getObject(String)
|
||||
*/
|
||||
@Nullable
|
||||
@@ -265,7 +265,7 @@ public interface SqlRowSet extends Serializable {
|
||||
* Retrieve the value of the indicated column in the current row as an Object.
|
||||
* @param columnIndex the column index
|
||||
* @param map a Map object containing the mapping from SQL types to Java types
|
||||
* @return a Object representing the column value
|
||||
* @return an Object representing the column value
|
||||
* @see java.sql.ResultSet#getObject(int, Map)
|
||||
*/
|
||||
@Nullable
|
||||
@@ -275,7 +275,7 @@ public interface SqlRowSet extends Serializable {
|
||||
* Retrieve the value of the indicated column in the current row as an Object.
|
||||
* @param columnLabel the column label
|
||||
* @param map a Map object containing the mapping from SQL types to Java types
|
||||
* @return a Object representing the column value
|
||||
* @return an Object representing the column value
|
||||
* @see java.sql.ResultSet#getObject(String, Map)
|
||||
*/
|
||||
@Nullable
|
||||
@@ -285,7 +285,7 @@ public interface SqlRowSet extends Serializable {
|
||||
* Retrieve the value of the indicated column in the current row as an Object.
|
||||
* @param columnIndex the column index
|
||||
* @param type the Java type to convert the designated column to
|
||||
* @return a Object representing the column value
|
||||
* @return an Object representing the column value
|
||||
* @since 4.1.3
|
||||
* @see java.sql.ResultSet#getObject(int, Class)
|
||||
*/
|
||||
@@ -296,7 +296,7 @@ public interface SqlRowSet extends Serializable {
|
||||
* Retrieve the value of the indicated column in the current row as an Object.
|
||||
* @param columnLabel the column label
|
||||
* @param type the Java type to convert the designated column to
|
||||
* @return a Object representing the column value
|
||||
* @return an Object representing the column value
|
||||
* @since 4.1.3
|
||||
* @see java.sql.ResultSet#getObject(String, Class)
|
||||
*/
|
||||
|
||||
@@ -145,7 +145,7 @@ public interface SqlRowSetMetaData {
|
||||
/**
|
||||
* Indicate whether the case of the designated column is significant.
|
||||
* @param columnIndex the index of the column
|
||||
* @return true if the case sensitive, false otherwise
|
||||
* @return true if the column is case-sensitive, false otherwise
|
||||
* @see java.sql.ResultSetMetaData#isCaseSensitive(int)
|
||||
*/
|
||||
boolean isCaseSensitive(int columnIndex) throws InvalidResultSetAccessException;
|
||||
|
||||
@@ -90,7 +90,7 @@ public class SQLExceptionSubclassTranslatorTests {
|
||||
assertThat(rdaex2.getCause()).isEqualTo(recoverableEx);
|
||||
|
||||
// Test classic error code translation. We should move there next if the exception we pass in is not one
|
||||
// of the new sub-classes.
|
||||
// of the new subclasses.
|
||||
SQLException sexEct = new SQLException("", "", 1);
|
||||
BadSqlGrammarException bsgEct = (BadSqlGrammarException) sext.translate("task", "SQL-ECT", sexEct);
|
||||
assertThat(bsgEct.getSql()).isEqualTo("SQL-ECT");
|
||||
|
||||
Reference in New Issue
Block a user