diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/AbstractFallbackSQLExceptionTranslator.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/AbstractFallbackSQLExceptionTranslator.java
index 4b6b11792d..87649840f2 100644
--- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/AbstractFallbackSQLExceptionTranslator.java
+++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/AbstractFallbackSQLExceptionTranslator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2017 the original author or authors.
+ * Copyright 2002-2018 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.
@@ -95,7 +95,7 @@ public abstract class AbstractFallbackSQLExceptionTranslator implements SQLExcep
* is allowed to return {@code null} to indicate that no exception match has
* been found and that fallback translation should kick in.
* @param task readable text describing the task being attempted
- * @param sql SQL query or update that caused the problem (if known)
+ * @param sql the SQL query or update that caused the problem (if known)
* @param ex the offending {@code SQLException}
* @return the DataAccessException, wrapping the {@code SQLException};
* or {@code null} if no exception match found
@@ -114,7 +114,7 @@ public abstract class AbstractFallbackSQLExceptionTranslator implements SQLExcep
* @return the message {@code String} to use
*/
protected String buildMessage(String task, @Nullable String sql, SQLException ex) {
- return task + "; " + (sql != null ? "SQL [" + sql : "]; " + "") + ex.getMessage();
+ return task + "; " + (sql != null ? ("SQL [" + sql + "]; ") : "") + ex.getMessage();
}
}
diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/GeneratedKeyHolder.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/GeneratedKeyHolder.java
index 88befa5c5f..51d720f077 100644
--- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/GeneratedKeyHolder.java
+++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/GeneratedKeyHolder.java
@@ -26,12 +26,12 @@ import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.lang.Nullable;
/**
- * Default implementation of the {@link KeyHolder} interface, to be used for
+ * The standard implementation of the {@link KeyHolder} interface, to be used for
* holding auto-generated keys (as potentially returned by JDBC insert statements).
*
- *
Create an instance of this class for each insert operation, and pass
- * it to the corresponding {@link org.springframework.jdbc.core.JdbcTemplate}
- * or {org.springframework.jdbc.object.SqlUpdate} methods.
+ *
Create an instance of this class for each insert operation, and pass it
+ * to the corresponding {@link org.springframework.jdbc.core.JdbcTemplate} or
+ * {@link org.springframework.jdbc.object.SqlUpdate} methods.
*
* @author Thomas Risberg
* @author Juergen Hoeller
@@ -92,10 +92,11 @@ public class GeneratedKeyHolder implements KeyHolder {
if (this.keyList.isEmpty()) {
return null;
}
- if (this.keyList.size() > 1)
+ if (this.keyList.size() > 1) {
throw new InvalidDataAccessApiUsageException(
"The getKeys method should only be used when keys for a single row are returned. " +
"The current key list contains keys for multiple rows: " + this.keyList);
+ }
return this.keyList.get(0);
}
diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/KeyHolder.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/KeyHolder.java
index e71725bd10..930fa0029f 100644
--- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/KeyHolder.java
+++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/KeyHolder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2018 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.
@@ -52,17 +52,17 @@ public interface KeyHolder {
* multiple entries as well. If this method encounters multiple entries in
* either the map or the list meaning that multiple keys were returned,
* then an InvalidDataAccessApiUsageException is thrown.
- * @return the generated key
- * @throws InvalidDataAccessApiUsageException if multiple keys are encountered.
+ * @return the generated key as a number
+ * @throws InvalidDataAccessApiUsageException if multiple keys are encountered
*/
@Nullable
Number getKey() throws InvalidDataAccessApiUsageException;
/**
- * Retrieve the first map of keys. If there are multiple entries in the list
- * (meaning that multiple rows had keys returned), then an
- * InvalidDataAccessApiUsageException is thrown.
- * @return the Map of generated keys
+ * Retrieve the first map of keys.
+ *
If there are multiple entries in the list (meaning that multiple rows
+ * had keys returned), then an InvalidDataAccessApiUsageException is thrown.
+ * @return the Map of generated keys for a single row
* @throws InvalidDataAccessApiUsageException if keys for multiple rows are encountered
*/
@Nullable
@@ -70,10 +70,10 @@ public interface KeyHolder {
/**
* Return a reference to the List that contains the keys.
- * Can be used for extracting keys for multiple rows (an unusual case),
+ *
Can be used for extracting keys for multiple rows (an unusual case),
* and also for adding new maps of keys.
- * @return the List for the generated keys, with each entry being a Map
- * of column names and key values
+ * @return the List for the generated keys, with each entry representing
+ * an individual row through a Map of column names and key values
*/
List