Browse Source

Polishing

pull/32357/head
Juergen Hoeller 2 years ago
parent
commit
429c477f6a
  1. 4
      spring-jdbc/src/main/java/org/springframework/jdbc/IncorrectResultSetColumnCountException.java
  2. 4
      spring-jdbc/src/main/java/org/springframework/jdbc/JdbcUpdateAffectedIncorrectNumberOfRowsException.java
  3. 4
      spring-jdbc/src/main/java/org/springframework/jdbc/core/InterruptibleBatchPreparedStatementSetter.java
  4. 8
      spring-jdbc/src/main/java/org/springframework/jdbc/object/RdbmsOperation.java
  5. 4
      spring-jdbc/src/main/java/org/springframework/jdbc/object/StoredProcedure.java
  6. 10
      spring-jdbc/src/main/java/org/springframework/jdbc/support/CustomSQLExceptionTranslatorRegistry.java
  7. 14
      spring-jdbc/src/main/java/org/springframework/jdbc/support/JdbcUtils.java
  8. 4
      spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodesFactory.java
  9. 7
      spring-tx/src/main/java/org/springframework/dao/IncorrectUpdateSemanticsDataAccessException.java

4
spring-jdbc/src/main/java/org/springframework/jdbc/IncorrectResultSetColumnCountException.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 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.
@ -20,7 +20,7 @@ import org.springframework.dao.DataRetrievalFailureException;
/** /**
* Data access exception thrown when a result set did not have the correct column count, * Data access exception thrown when a result set did not have the correct column count,
* for example when expecting a single column but getting 0 or more than 1 columns. * for example when expecting a single column but getting 0 or more than 1 column.
* *
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 2.0 * @since 2.0

4
spring-jdbc/src/main/java/org/springframework/jdbc/JdbcUpdateAffectedIncorrectNumberOfRowsException.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 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.
@ -20,7 +20,7 @@ import org.springframework.dao.IncorrectUpdateSemanticsDataAccessException;
/** /**
* Exception thrown when a JDBC update affects an unexpected number of rows. * Exception thrown when a JDBC update affects an unexpected number of rows.
* Typically we expect an update to affect a single row, meaning it's an * Typically, we expect an update to affect a single row, meaning it is an
* error if it affects multiple rows. * error if it affects multiple rows.
* *
* @author Rod Johnson * @author Rod Johnson

4
spring-jdbc/src/main/java/org/springframework/jdbc/core/InterruptibleBatchPreparedStatementSetter.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 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.
@ -22,7 +22,7 @@ package org.springframework.jdbc.core;
* *
* <p>This interface allows you to signal the end of a batch rather than * <p>This interface allows you to signal the end of a batch rather than
* having to determine the exact batch size upfront. Batch size is still * having to determine the exact batch size upfront. Batch size is still
* being honored but it is now the maximum size of the batch. * being honored, but it is now the maximum size of the batch.
* *
* <p>The {@link #isBatchExhausted} method is called after each call to * <p>The {@link #isBatchExhausted} method is called after each call to
* {@link #setValues} to determine whether there were some values added, * {@link #setValues} to determine whether there were some values added,

8
spring-jdbc/src/main/java/org/springframework/jdbc/object/RdbmsOperation.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 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.
@ -128,8 +128,8 @@ public abstract class RdbmsOperation implements InitializingBean {
/** /**
* Set the maximum number of rows for this RDBMS operation. This is important * Set the maximum number of rows for this RDBMS operation. This is important
* for processing subsets of large result sets, avoiding to read and hold * for processing subsets of large result sets, in order to avoid reading and
* the entire result set in the database or in the JDBC driver. * holding the entire result set in the database or in the JDBC driver.
* <p>Default is -1, indicating to use the driver's default. * <p>Default is -1, indicating to use the driver's default.
* @see org.springframework.jdbc.core.JdbcTemplate#setMaxRows * @see org.springframework.jdbc.core.JdbcTemplate#setMaxRows
*/ */
@ -175,7 +175,7 @@ public abstract class RdbmsOperation implements InitializingBean {
public void setUpdatableResults(boolean updatableResults) { public void setUpdatableResults(boolean updatableResults) {
if (isCompiled()) { if (isCompiled()) {
throw new InvalidDataAccessApiUsageException( throw new InvalidDataAccessApiUsageException(
"The updateableResults flag must be set before the operation is compiled"); "The updatableResults flag must be set before the operation is compiled");
} }
this.updatableResults = updatableResults; this.updatableResults = updatableResults;
} }

4
spring-jdbc/src/main/java/org/springframework/jdbc/object/StoredProcedure.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2021 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.
@ -29,7 +29,7 @@ import org.springframework.jdbc.core.SqlParameter;
/** /**
* Superclass for object abstractions of RDBMS stored procedures. * Superclass for object abstractions of RDBMS stored procedures.
* This class is abstract and it is intended that subclasses will provide a typed * This class is abstract, and it is intended that subclasses will provide a typed
* method for invocation that delegates to the supplied {@link #execute} method. * method for invocation that delegates to the supplied {@link #execute} method.
* *
* <p>The inherited {@link #setSql sql} property is the name of the stored procedure * <p>The inherited {@link #setSql sql} property is the name of the stored procedure

10
spring-jdbc/src/main/java/org/springframework/jdbc/support/CustomSQLExceptionTranslatorRegistry.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 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.
@ -25,9 +25,9 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
/** /**
* Registry for custom {@link org.springframework.jdbc.support.SQLExceptionTranslator} instances associated with * Registry for custom {@link SQLExceptionTranslator} instances associated with
* specific databases allowing for overriding translation based on values contained in the configuration file * specific databases allowing for overriding translation based on values
* named "sql-error-codes.xml". * contained in the configuration file named "sql-error-codes.xml".
* *
* @author Thomas Risberg * @author Thomas Risberg
* @since 3.1.1 * @since 3.1.1
@ -38,7 +38,7 @@ public final class CustomSQLExceptionTranslatorRegistry {
private static final Log logger = LogFactory.getLog(CustomSQLExceptionTranslatorRegistry.class); private static final Log logger = LogFactory.getLog(CustomSQLExceptionTranslatorRegistry.class);
/** /**
* Keep track of a single instance so we can return it to classes that request it. * Keep track of a single instance, so we can return it to classes that request it.
*/ */
private static final CustomSQLExceptionTranslatorRegistry instance = new CustomSQLExceptionTranslatorRegistry(); private static final CustomSQLExceptionTranslatorRegistry instance = new CustomSQLExceptionTranslatorRegistry();

14
spring-jdbc/src/main/java/org/springframework/jdbc/support/JdbcUtils.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2022 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.
@ -219,7 +219,7 @@ public abstract class JdbcUtils {
return NumberUtils.convertNumberToTargetClass(number, Integer.class); return NumberUtils.convertNumberToTargetClass(number, Integer.class);
} }
else { else {
// e.g. on Postgres: getObject returns a PGObject but we need a String // e.g. on Postgres: getObject returns a PGObject, but we need a String
return rs.getString(index); return rs.getString(index);
} }
} }
@ -415,14 +415,14 @@ public abstract class JdbcUtils {
} }
/** /**
* Return whether the given JDBC driver supports JDBC 2.0 batch updates. * Return whether the given JDBC driver supports JDBC batch updates.
* <p>Typically invoked right before execution of a given set of statements: * <p>Typically invoked right before execution of a given set of statements:
* to decide whether the set of SQL statements should be executed through * to decide whether the set of SQL statements should be executed through
* the JDBC 2.0 batch mechanism or simply in a traditional one-by-one fashion. * the JDBC batch mechanism or simply in a traditional one-by-one fashion.
* <p>Logs a warning if the "supportsBatchUpdates" methods throws an exception * <p>Logs a warning if the "supportsBatchUpdates" methods throws an exception
* and simply returns {@code false} in that case. * and simply returns {@code false} in that case.
* @param con the Connection to check * @param con the Connection to check
* @return whether JDBC 2.0 batch updates are supported * @return whether JDBC batch updates are supported
* @see java.sql.DatabaseMetaData#supportsBatchUpdates() * @see java.sql.DatabaseMetaData#supportsBatchUpdates()
*/ */
public static boolean supportsBatchUpdates(Connection con) { public static boolean supportsBatchUpdates(Connection con) {
@ -492,8 +492,8 @@ public abstract class JdbcUtils {
/** /**
* Determine the column name to use. The column name is determined based on a * Determine the column name to use. The column name is determined based on a
* lookup using ResultSetMetaData. * lookup using ResultSetMetaData.
* <p>This method implementation takes into account recent clarifications * <p>This method's implementation takes into account clarifications expressed
* expressed in the JDBC 4.0 specification: * in the JDBC 4.0 specification:
* <p><i>columnLabel - the label for the column specified with the SQL AS clause. * <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>. * 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 resultSetMetaData the current meta-data to use

4
spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodesFactory.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2022 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.
@ -67,7 +67,7 @@ public class SQLErrorCodesFactory {
private static final Log logger = LogFactory.getLog(SQLErrorCodesFactory.class); private static final Log logger = LogFactory.getLog(SQLErrorCodesFactory.class);
/** /**
* Keep track of a single instance so we can return it to classes that request it. * Keep track of a single instance, so we can return it to classes that request it.
* Lazily initialized in order to avoid making {@code SQLErrorCodesFactory} constructor * Lazily initialized in order to avoid making {@code SQLErrorCodesFactory} constructor
* reachable on native images when not needed. * reachable on native images when not needed.
*/ */

7
spring-tx/src/main/java/org/springframework/dao/IncorrectUpdateSemanticsDataAccessException.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 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.
@ -44,10 +44,11 @@ public class IncorrectUpdateSemanticsDataAccessException extends InvalidDataAcce
super(msg, cause); super(msg, cause);
} }
/** /**
* Return whether data was updated. * Return whether data was updated.
* If this method returns false, there's nothing to roll back. * If this method returns {@code false}, there is nothing to roll back.
* <p>The default implementation always returns true. * <p>The default implementation always returns {@code true}.
* This can be overridden in subclasses. * This can be overridden in subclasses.
*/ */
public boolean wasDataUpdated() { public boolean wasDataUpdated() {

Loading…
Cancel
Save