diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java index fb4e68d05a5b..3acfab1d8215 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -80,9 +80,8 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto new Converter() { @Override public Annotation convert(Method method) { - AspectJAnnotation annotation = - AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(method); - return (annotation != null ? annotation.getAnnotation() : null); + AspectJAnnotation ann = AbstractAspectJAdvisorFactory.findAspectJAnnotationOnMethod(method); + return (ann != null ? ann.getAnnotation() : null); } })); comparator.addComparator(new ConvertingComparator( diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/autoproxy/AspectJPrecedenceComparator.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/autoproxy/AspectJPrecedenceComparator.java index 419d00dfe24d..8e12e83c0b20 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/autoproxy/AspectJPrecedenceComparator.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/autoproxy/AspectJPrecedenceComparator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2020 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. @@ -136,14 +136,8 @@ private String getAspectName(Advisor anAdvisor) { } private int getAspectDeclarationOrder(Advisor anAdvisor) { - AspectJPrecedenceInformation precedenceInfo = - AspectJAopUtils.getAspectJPrecedenceInformationFor(anAdvisor); - if (precedenceInfo != null) { - return precedenceInfo.getDeclarationOrder(); - } - else { - return 0; - } + AspectJPrecedenceInformation precedenceInfo = AspectJAopUtils.getAspectJPrecedenceInformationFor(anAdvisor); + return (precedenceInfo != null ? precedenceInfo.getDeclarationOrder() : 0); } } diff --git a/spring-aop/src/main/java/org/springframework/aop/config/AopNamespaceHandler.java b/spring-aop/src/main/java/org/springframework/aop/config/AopNamespaceHandler.java index 99eb2fa6f594..fa6cc80a1f3c 100644 --- a/spring-aop/src/main/java/org/springframework/aop/config/AopNamespaceHandler.java +++ b/spring-aop/src/main/java/org/springframework/aop/config/AopNamespaceHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2020 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. @@ -61,12 +61,12 @@ public class AopNamespaceHandler extends NamespaceHandlerSupport { */ @Override public void init() { - // In 2.0 XSD as well as in 2.1 XSD. + // In 2.0 XSD as well as in 2.5+ XSDs registerBeanDefinitionParser("config", new ConfigBeanDefinitionParser()); registerBeanDefinitionParser("aspectj-autoproxy", new AspectJAutoProxyBeanDefinitionParser()); registerBeanDefinitionDecorator("scoped-proxy", new ScopedProxyBeanDefinitionDecorator()); - // Only in 2.0 XSD: moved to context namespace as of 2.1 + // Only in 2.0 XSD: moved to context namespace in 2.5+ registerBeanDefinitionParser("spring-configured", new SpringConfiguredBeanDefinitionParser()); } diff --git a/spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java b/spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java index a4410e505a34..092111f44922 100644 --- a/spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java +++ b/spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2020 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. @@ -43,9 +43,9 @@ * Internal class that caches JavaBeans {@link java.beans.PropertyDescriptor} * information for a Java class. Not intended for direct use by application code. * - *

Necessary for own caching of descriptors within the application's - * ClassLoader, rather than rely on the JDK's system-wide BeanInfo cache - * (in order to avoid leaks on ClassLoader shutdown). + *

Necessary for Spring's own caching of bean descriptors within the application + * {@link ClassLoader}, rather than relying on the JDK's system-wide {@link BeanInfo} + * cache (in order to avoid leaks on individual application shutdown in a shared JVM). * *

Information is cached statically, so we don't need to create new * objects of this class for every JavaBean we manipulate. Hence, this class @@ -97,7 +97,7 @@ public class CachedIntrospectionResults { SpringProperties.getFlag(IGNORE_BEANINFO_PROPERTY_NAME); /** Stores the BeanInfoFactory instances */ - private static List beanInfoFactories = SpringFactoriesLoader.loadFactories( + private static final List beanInfoFactories = SpringFactoriesLoader.loadFactories( BeanInfoFactory.class, CachedIntrospectionResults.class.getClassLoader()); private static final Log logger = LogFactory.getLog(CachedIntrospectionResults.class); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Lookup.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Lookup.java index b453b063f246..0fca4f3316a0 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Lookup.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Lookup.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2020 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. @@ -41,12 +41,11 @@ * regular constructors: i.e. lookup methods cannot get replaced on beans returned * from factory methods where we cannot dynamically provide a subclass for them. * - *

Concrete limitations in typical Spring configuration scenarios: - * When used with component scanning or any other mechanism that filters out abstract - * beans, provide stub implementations of your lookup methods to be able to declare - * them as concrete classes. And please remember that lookup methods won't work on - * beans returned from {@code @Bean} methods in configuration classes; you'll have - * to resort to {@code @Inject Provider<TargetBean>} or the like instead. + *

Recommendations for typical Spring configuration scenarios: + * When a concrete class may be needed in certain scenarios, consider providing stub + * implementations of your lookup methods. And please remember that lookup methods + * won't work on beans returned from {@code @Bean} methods in configuration classes; + * you'll have to resort to {@code @Inject Provider} or the like instead. * * @author Juergen Hoeller * @since 4.1 diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java index 040e3c9f773f..da4f75d9d971 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java @@ -879,7 +879,7 @@ public List getBeanPostProcessors() { /** * Return whether this factory holds a InstantiationAwareBeanPostProcessor - * that will get applied to singleton beans on shutdown. + * that will get applied to singleton beans on creation. * @see #addBeanPostProcessor * @see org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor */ @@ -1508,7 +1508,7 @@ protected boolean isFactoryBean(String beanName, RootBeanDefinition mbd) { * should be used as fallback. * @param beanName the name of the bean * @param mbd the merged bean definition for the bean - * @return the type for the bean if determinable, or {@code null} else + * @return the type for the bean if determinable, or {@code null} otherwise * @see org.springframework.beans.factory.FactoryBean#getObjectType() * @see #getBean(String) */ diff --git a/spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCache.java b/spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCache.java index 9dfeef4a5bbb..fea574005b6f 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCache.java +++ b/spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCache.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2020 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. @@ -35,6 +35,7 @@ * @author Juergen Hoeller * @author Stephane Nicoll * @since 4.3 + * @see CaffeineCacheManager */ @UsesJava8 public class CaffeineCache extends AbstractValueAdaptingCache { diff --git a/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCache.java b/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCache.java index 5baa8f8a0b08..2715a3d484a4 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCache.java +++ b/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCache.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -92,7 +92,6 @@ public T get(Object key, Callable valueLoader) { this.cache.releaseWriteLockOnKey(key); } } - } private T loadValue(Object key, Callable valueLoader) { diff --git a/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCacheManager.java b/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCacheManager.java index 9cafb16725f8..f08be497cf60 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCacheManager.java +++ b/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCacheManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2020 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. @@ -32,6 +32,7 @@ * @author Juergen Hoeller * @author Stephane Nicoll * @since 3.1 + * @see EhCacheCache */ public class EhCacheCacheManager extends AbstractTransactionSupportingCacheManager { diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCache.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCache.java index 79a7b3a8aa55..a14f7373e73a 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCache.java +++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCache.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -27,13 +27,14 @@ /** * {@link org.springframework.cache.Cache} implementation on top of a - * {@link javax.cache.Cache} instance. + * {@link Cache javax.cache.Cache} instance. * *

Note: This class has been updated for JCache 1.0, as of Spring 4.0. * * @author Juergen Hoeller * @author Stephane Nicoll * @since 3.2 + * @see JCacheCacheManager */ public class JCacheCache extends AbstractValueAdaptingCache { @@ -41,7 +42,7 @@ public class JCacheCache extends AbstractValueAdaptingCache { /** - * Create an {@link org.springframework.cache.jcache.JCacheCache} instance. + * Create a {@code JCacheCache} instance. * @param jcache backing JCache Cache instance */ public JCacheCache(Cache jcache) { @@ -49,7 +50,7 @@ public JCacheCache(Cache jcache) { } /** - * Create an {@link org.springframework.cache.jcache.JCacheCache} instance. + * Create a {@code JCacheCache} instance. * @param jcache backing JCache Cache instance * @param allowNullValues whether to accept and convert null values for this cache */ @@ -123,7 +124,7 @@ public T process(MutableEntry entry, Object... arguments) throws } catch (Exception ex) { throw new EntryProcessorException("Value loader '" + valueLoader + "' failed " + - "to compute value for key '" + entry.getKey() + "'", ex); + "to compute value for key '" + entry.getKey() + "'", ex); } entry.setValue(toStoreValue(value)); return value; diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCacheManager.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCacheManager.java index 16e75582fb1c..e164d95bb1ad 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCacheManager.java +++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCacheManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2020 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. @@ -26,7 +26,7 @@ /** * {@link org.springframework.cache.CacheManager} implementation - * backed by a JCache {@link javax.cache.CacheManager}. + * backed by a JCache {@link CacheManager javax.cache.CacheManager}. * *

Note: This class has been updated for JCache 1.0, as of Spring 4.0. * @@ -42,15 +42,18 @@ public class JCacheCacheManager extends AbstractTransactionSupportingCacheManage /** - * Create a new JCacheCacheManager, setting the target JCache CacheManager - * through the {@link #setCacheManager} bean property. + * Create a new {@code JCacheCacheManager} without a backing JCache + * {@link CacheManager javax.cache.CacheManager}. + *

The backing JCache {@code javax.cache.CacheManager} can be set via the + * {@link #setCacheManager} bean property. */ public JCacheCacheManager() { } /** - * Create a new JCacheCacheManager for the given backing JCache. - * @param cacheManager the backing JCache {@link javax.cache.CacheManager} + * Create a new {@code JCacheCacheManager} for the given backing JCache + * {@link CacheManager javax.cache.CacheManager}. + * @param cacheManager the backing JCache {@code javax.cache.CacheManager} */ public JCacheCacheManager(CacheManager cacheManager) { this.cacheManager = cacheManager; @@ -58,14 +61,14 @@ public JCacheCacheManager(CacheManager cacheManager) { /** - * Set the backing JCache {@link javax.cache.CacheManager}. + * Set the backing JCache {@link CacheManager javax.cache.CacheManager}. */ public void setCacheManager(CacheManager cacheManager) { this.cacheManager = cacheManager; } /** - * Return the backing JCache {@link javax.cache.CacheManager}. + * Return the backing JCache {@link CacheManager javax.cache.CacheManager}. */ public CacheManager getCacheManager() { return this.cacheManager; diff --git a/spring-context/src/main/java/org/springframework/cache/support/NoOpCache.java b/spring-context/src/main/java/org/springframework/cache/support/NoOpCache.java index aa3751a2f4f2..5ab036174cc9 100644 --- a/spring-context/src/main/java/org/springframework/cache/support/NoOpCache.java +++ b/spring-context/src/main/java/org/springframework/cache/support/NoOpCache.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2020 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. @@ -29,6 +29,7 @@ * @author Costin Leau * @author Stephane Nicoll * @since 4.3.4 + * @see NoOpCacheManager */ public class NoOpCache implements Cache { @@ -36,7 +37,7 @@ public class NoOpCache implements Cache { /** - * Create a {@link NoOpCache} instance with the specified name + * Create a {@link NoOpCache} instance with the specified name. * @param name the name of the cache */ public NoOpCache(String name) { diff --git a/spring-context/src/main/java/org/springframework/cache/support/NoOpCacheManager.java b/spring-context/src/main/java/org/springframework/cache/support/NoOpCacheManager.java index 288dbc8f7c31..6794b39f4c87 100644 --- a/spring-context/src/main/java/org/springframework/cache/support/NoOpCacheManager.java +++ b/spring-context/src/main/java/org/springframework/cache/support/NoOpCacheManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2020 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. @@ -36,7 +36,7 @@ * @author Costin Leau * @author Stephane Nicoll * @since 3.1 - * @see CompositeCacheManager + * @see NoOpCache */ public class NoOpCacheManager implements CacheManager { diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcOperations.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcOperations.java index 33bf907a0aea..0e68af37f14b 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcOperations.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcOperations.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -97,7 +97,7 @@ public interface JdbcOperations { * @param rse a callback that will extract all rows of results * @return an arbitrary result object, as returned by the ResultSetExtractor * @throws DataAccessException if there is any problem executing the query - * @see #query(String, Object[], ResultSetExtractor) + * @see #query(String, ResultSetExtractor, Object...) */ T query(String sql, ResultSetExtractor rse) throws DataAccessException; @@ -110,7 +110,7 @@ public interface JdbcOperations { * @param sql the SQL query to execute * @param rch a callback that will extract results, one row at a time * @throws DataAccessException if there is any problem executing the query - * @see #query(String, Object[], RowCallbackHandler) + * @see #query(String, RowCallbackHandler, Object...) */ void query(String sql, RowCallbackHandler rch) throws DataAccessException; @@ -124,7 +124,7 @@ public interface JdbcOperations { * @param rowMapper a callback that will map one object per row * @return the result List, containing mapped objects * @throws DataAccessException if there is any problem executing the query - * @see #query(String, Object[], RowMapper) + * @see #query(String, RowMapper, Object...) */ List query(String sql, RowMapper rowMapper) throws DataAccessException; @@ -142,7 +142,7 @@ public interface JdbcOperations { * @throws IncorrectResultSizeDataAccessException if the query does not * return exactly one row * @throws DataAccessException if there is any problem executing the query - * @see #queryForObject(String, Object[], RowMapper) + * @see #queryForObject(String, RowMapper, Object...) */ T queryForObject(String sql, RowMapper rowMapper) throws DataAccessException; @@ -161,7 +161,7 @@ public interface JdbcOperations { * @throws IncorrectResultSizeDataAccessException if the query does not return * exactly one row, or does not return exactly one column in that row * @throws DataAccessException if there is any problem executing the query - * @see #queryForObject(String, Object[], Class) + * @see #queryForObject(String, Class, Object...) */ T queryForObject(String sql, Class requiredType) throws DataAccessException; @@ -178,7 +178,7 @@ public interface JdbcOperations { * @throws IncorrectResultSizeDataAccessException if the query does not * return exactly one row * @throws DataAccessException if there is any problem executing the query - * @see #queryForMap(String, Object[]) + * @see #queryForMap(String, Object...) * @see ColumnMapRowMapper */ Map queryForMap(String sql) throws DataAccessException; @@ -195,7 +195,7 @@ public interface JdbcOperations { * (for example, {@code Integer.class}) * @return a List of objects that match the specified element type * @throws DataAccessException if there is any problem executing the query - * @see #queryForList(String, Object[], Class) + * @see #queryForList(String, Class, Object...) * @see SingleColumnRowMapper */ List queryForList(String sql, Class elementType) throws DataAccessException; @@ -212,7 +212,7 @@ public interface JdbcOperations { * @param sql the SQL query to execute * @return an List that contains a Map per row * @throws DataAccessException if there is any problem executing the query - * @see #queryForList(String, Object[]) + * @see #queryForList(String, Object...) */ List> queryForList(String sql) throws DataAccessException; @@ -231,7 +231,7 @@ public interface JdbcOperations { * @return a SqlRowSet representation (possibly a wrapper around a * {@code javax.sql.rowset.CachedRowSet}) * @throws DataAccessException if there is any problem executing the query - * @see #queryForRowSet(String, Object[]) + * @see #queryForRowSet(String, Object...) * @see SqlRowSetResultSetExtractor * @see javax.sql.rowset.CachedRowSet */ @@ -884,6 +884,7 @@ List queryForList(String sql, Object[] args, int[] argTypes, Class ele * @param sql the SQL statement to execute * @param batchArgs the List of Object arrays containing the batch of arguments for the query * @return an array containing the numbers of rows affected by each update in the batch + * @throws DataAccessException if there is any problem issuing the update */ int[] batchUpdate(String sql, List batchArgs) throws DataAccessException; @@ -894,6 +895,7 @@ List queryForList(String sql, Object[] args, int[] argTypes, Class ele * @param argTypes the SQL types of the arguments * (constants from {@code java.sql.Types}) * @return an array containing the numbers of rows affected by each update in the batch + * @throws DataAccessException if there is any problem issuing the update */ int[] batchUpdate(String sql, List batchArgs, int[] argTypes) throws DataAccessException; @@ -907,6 +909,7 @@ List queryForList(String sql, Object[] args, int[] argTypes, Class ele * @param pss the ParameterizedPreparedStatementSetter to use * @return an array containing for each batch another array containing the numbers of rows affected * by each update in the batch + * @throws DataAccessException if there is any problem issuing the update * @since 3.1 */ int[][] batchUpdate(String sql, Collection batchArgs, int batchSize, diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcOperations.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcOperations.java index 508292a15732..e9f0fa9c0824 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcOperations.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcOperations.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2020 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. @@ -61,7 +61,7 @@ public interface NamedParameterJdbcOperations { * and converting JDBC SQLExceptions into Spring's DataAccessException hierarchy. *

The callback action can return a result object, for example a * domain object or a collection of domain objects. - * @param sql SQL to execute + * @param sql the SQL to execute * @param paramSource container of arguments to bind to the query * @param action callback object that specifies the action * @return a result object returned by the action, or {@code null} @@ -78,7 +78,7 @@ T execute(String sql, SqlParameterSource paramSource, PreparedStatementCallb * and converting JDBC SQLExceptions into Spring's DataAccessException hierarchy. *

The callback action can return a result object, for example a * domain object or a collection of domain objects. - * @param sql SQL to execute + * @param sql the SQL to execute * @param paramMap map of parameters to bind to the query * (leaving it to the PreparedStatement to guess the corresponding SQL type) * @param action callback object that specifies the action @@ -96,7 +96,7 @@ T execute(String sql, Map paramMap, PreparedStatementCallback * and converting JDBC SQLExceptions into Spring's DataAccessException hierarchy. *

The callback action can return a result object, for example a * domain object or a collection of domain objects. - * @param sql SQL to execute + * @param sql the SQL to execute * @param action callback object that specifies the action * @return a result object returned by the action, or {@code null} * @throws DataAccessException if there is any problem @@ -107,7 +107,7 @@ T execute(String sql, Map paramMap, PreparedStatementCallback * Query given SQL to create a prepared statement from SQL and a list * of arguments to bind to the query, reading the ResultSet with a * ResultSetExtractor. - * @param sql SQL query to execute + * @param sql the SQL query to execute * @param paramSource container of arguments to bind to the query * @param rse object that will extract results * @return an arbitrary result object, as returned by the ResultSetExtractor @@ -120,12 +120,12 @@ T query(String sql, SqlParameterSource paramSource, ResultSetExtractor rs * Query given SQL to create a prepared statement from SQL and a list * of arguments to bind to the query, reading the ResultSet with a * ResultSetExtractor. - * @param sql SQL query to execute + * @param sql the SQL query to execute * @param paramMap map of parameters to bind to the query * (leaving it to the PreparedStatement to guess the corresponding SQL type) * @param rse object that will extract results * @return an arbitrary result object, as returned by the ResultSetExtractor - * @throws org.springframework.dao.DataAccessException if the query fails + * @throws DataAccessException if the query fails */ T query(String sql, Map paramMap, ResultSetExtractor rse) throws DataAccessException; @@ -136,10 +136,10 @@ T query(String sql, Map paramMap, ResultSetExtractor rse) *

Note: In contrast to the JdbcOperations method with the same signature, * this query variant always uses a PreparedStatement. It is effectively * equivalent to a query call with an empty parameter Map. - * @param sql SQL query to execute + * @param sql the SQL query to execute * @param rse object that will extract results * @return an arbitrary result object, as returned by the ResultSetExtractor - * @throws org.springframework.dao.DataAccessException if the query fails + * @throws DataAccessException if the query fails */ T query(String sql, ResultSetExtractor rse) throws DataAccessException; @@ -147,7 +147,7 @@ T query(String sql, Map paramMap, ResultSetExtractor rse) * Query given SQL to create a prepared statement from SQL and a list of * arguments to bind to the query, reading the ResultSet on a per-row basis * with a RowCallbackHandler. - * @param sql SQL query to execute + * @param sql the SQL query to execute * @param paramSource container of arguments to bind to the query * @param rch object that will extract results, one row at a time * @throws DataAccessException if the query fails @@ -159,11 +159,11 @@ void query(String sql, SqlParameterSource paramSource, RowCallbackHandler rch) * Query given SQL to create a prepared statement from SQL and a list of * arguments to bind to the query, reading the ResultSet on a per-row basis * with a RowCallbackHandler. - * @param sql SQL query to execute + * @param sql the SQL query to execute * @param paramMap map of parameters to bind to the query * (leaving it to the PreparedStatement to guess the corresponding SQL type) * @param rch object that will extract results, one row at a time - * @throws org.springframework.dao.DataAccessException if the query fails + * @throws DataAccessException if the query fails */ void query(String sql, Map paramMap, RowCallbackHandler rch) throws DataAccessException; @@ -173,9 +173,9 @@ void query(String sql, SqlParameterSource paramSource, RowCallbackHandler rch) *

Note: In contrast to the JdbcOperations method with the same signature, * this query variant always uses a PreparedStatement. It is effectively * equivalent to a query call with an empty parameter Map. - * @param sql SQL query to execute + * @param sql the SQL query to execute * @param rch object that will extract results, one row at a time - * @throws org.springframework.dao.DataAccessException if the query fails + * @throws DataAccessException if the query fails */ void query(String sql, RowCallbackHandler rch) throws DataAccessException; @@ -183,11 +183,11 @@ void query(String sql, SqlParameterSource paramSource, RowCallbackHandler rch) * Query given SQL to create a prepared statement from SQL and a list * of arguments to bind to the query, mapping each row to a Java object * via a RowMapper. - * @param sql SQL query to execute + * @param sql the SQL query to execute * @param paramSource container of arguments to bind to the query * @param rowMapper object that will map one object per row * @return the result List, containing mapped objects - * @throws org.springframework.dao.DataAccessException if the query fails + * @throws DataAccessException if the query fails */ List query(String sql, SqlParameterSource paramSource, RowMapper rowMapper) throws DataAccessException; @@ -196,12 +196,12 @@ List query(String sql, SqlParameterSource paramSource, RowMapper rowMa * Query given SQL to create a prepared statement from SQL and a list * of arguments to bind to the query, mapping each row to a Java object * via a RowMapper. - * @param sql SQL query to execute + * @param sql the SQL query to execute * @param paramMap map of parameters to bind to the query * (leaving it to the PreparedStatement to guess the corresponding SQL type) * @param rowMapper object that will map one object per row * @return the result List, containing mapped objects - * @throws org.springframework.dao.DataAccessException if the query fails + * @throws DataAccessException if the query fails */ List query(String sql, Map paramMap, RowMapper rowMapper) throws DataAccessException; @@ -212,10 +212,10 @@ List query(String sql, Map paramMap, RowMapper rowMapper) *

Note: In contrast to the JdbcOperations method with the same signature, * this query variant always uses a PreparedStatement. It is effectively * equivalent to a query call with an empty parameter Map. - * @param sql SQL query to execute + * @param sql the SQL query to execute * @param rowMapper object that will map one object per row * @return the result List, containing mapped objects - * @throws org.springframework.dao.DataAccessException if the query fails + * @throws DataAccessException if the query fails */ List query(String sql, RowMapper rowMapper) throws DataAccessException; @@ -223,7 +223,7 @@ List query(String sql, Map paramMap, RowMapper rowMapper) * Query given SQL to create a prepared statement from SQL and a list * of arguments to bind to the query, mapping a single result row to a * Java object via a RowMapper. - * @param sql SQL query to execute + * @param sql the SQL query to execute * @param paramSource container of arguments to bind to the query * @param rowMapper object that will map one object per row * @return the single mapped object (may be {@code null} if the given @@ -231,7 +231,7 @@ List query(String sql, Map paramMap, RowMapper rowMapper) * @throws org.springframework.dao.IncorrectResultSizeDataAccessException * if the query does not return exactly one row, or does not return exactly * one column in that row - * @throws org.springframework.dao.DataAccessException if the query fails + * @throws DataAccessException if the query fails */ T queryForObject(String sql, SqlParameterSource paramSource, RowMapper rowMapper) throws DataAccessException; @@ -240,7 +240,7 @@ T queryForObject(String sql, SqlParameterSource paramSource, RowMapper ro * Query given SQL to create a prepared statement from SQL and a list * of arguments to bind to the query, mapping a single result row to a * Java object via a RowMapper. - * @param sql SQL query to execute + * @param sql the SQL query to execute * @param paramMap map of parameters to bind to the query * (leaving it to the PreparedStatement to guess the corresponding SQL type) * @param rowMapper object that will map one object per row @@ -249,7 +249,7 @@ T queryForObject(String sql, SqlParameterSource paramSource, RowMapper ro * @throws org.springframework.dao.IncorrectResultSizeDataAccessException * if the query does not return exactly one row, or does not return exactly * one column in that row - * @throws org.springframework.dao.DataAccessException if the query fails + * @throws DataAccessException if the query fails */ T queryForObject(String sql, Map paramMap, RowMapper rowMapper) throws DataAccessException; @@ -259,14 +259,14 @@ T queryForObject(String sql, Map paramMap, RowMapper rowMapper * list of arguments to bind to the query, expecting a result object. *

The query is expected to be a single row/single column query; the returned * result will be directly mapped to the corresponding object type. - * @param sql SQL query to execute + * @param sql the SQL query to execute * @param paramSource container of arguments to bind to the query * @param requiredType the type that the result object is expected to match * @return the result object of the required type, or {@code null} in case of SQL NULL * @throws org.springframework.dao.IncorrectResultSizeDataAccessException * if the query does not return exactly one row, or does not return exactly * one column in that row - * @throws org.springframework.dao.DataAccessException if the query fails + * @throws DataAccessException if the query fails * @see org.springframework.jdbc.core.JdbcTemplate#queryForObject(String, Class) */ T queryForObject(String sql, SqlParameterSource paramSource, Class requiredType) @@ -277,7 +277,7 @@ T queryForObject(String sql, SqlParameterSource paramSource, Class requir * list of arguments to bind to the query, expecting a result object. *

The query is expected to be a single row/single column query; the returned * result will be directly mapped to the corresponding object type. - * @param sql SQL query to execute + * @param sql the SQL query to execute * @param paramMap map of parameters to bind to the query * (leaving it to the PreparedStatement to guess the corresponding SQL type) * @param requiredType the type that the result object is expected to match @@ -285,7 +285,7 @@ T queryForObject(String sql, SqlParameterSource paramSource, Class requir * @throws org.springframework.dao.IncorrectResultSizeDataAccessException * if the query does not return exactly one row, or does not return exactly * one column in that row - * @throws org.springframework.dao.DataAccessException if the query fails + * @throws DataAccessException if the query fails * @see org.springframework.jdbc.core.JdbcTemplate#queryForObject(String, Class) */ T queryForObject(String sql, Map paramMap, Class requiredType) @@ -296,12 +296,12 @@ T queryForObject(String sql, Map paramMap, Class requiredType) * list of arguments to bind to the query, expecting a result Map. *

The query is expected to be a single row query; the result row will be * mapped to a Map (one entry for each column, using the column name as the key). - * @param sql SQL query to execute + * @param sql the SQL query to execute * @param paramSource container of arguments to bind to the query * @return the result Map (one entry for each column, using the column name as the key) * @throws org.springframework.dao.IncorrectResultSizeDataAccessException * if the query does not return exactly one row - * @throws org.springframework.dao.DataAccessException if the query fails + * @throws DataAccessException if the query fails * @see org.springframework.jdbc.core.JdbcTemplate#queryForMap(String) * @see org.springframework.jdbc.core.ColumnMapRowMapper */ @@ -315,13 +315,13 @@ T queryForObject(String sql, Map paramMap, Class requiredType) * one of the queryForObject() methods. *

The query is expected to be a single row query; the result row will be * mapped to a Map (one entry for each column, using the column name as the key). - * @param sql SQL query to execute + * @param sql the SQL query to execute * @param paramMap map of parameters to bind to the query * (leaving it to the PreparedStatement to guess the corresponding SQL type) * @return the result Map (one entry for each column, using the column name as the key) * @throws org.springframework.dao.IncorrectResultSizeDataAccessException * if the query does not return exactly one row - * @throws org.springframework.dao.DataAccessException if the query fails + * @throws DataAccessException if the query fails * @see org.springframework.jdbc.core.JdbcTemplate#queryForMap(String) * @see org.springframework.jdbc.core.ColumnMapRowMapper */ @@ -332,12 +332,12 @@ T queryForObject(String sql, Map paramMap, Class requiredType) * list of arguments to bind to the query, expecting a result list. *

The results will be mapped to a List (one entry for each row) of * result objects, each of them matching the specified element type. - * @param sql SQL query to execute + * @param sql the SQL query to execute * @param paramSource container of arguments to bind to the query * @param elementType the required type of element in the result list * (for example, {@code Integer.class}) * @return a List of objects that match the specified element type - * @throws org.springframework.dao.DataAccessException if the query fails + * @throws DataAccessException if the query fails * @see org.springframework.jdbc.core.JdbcTemplate#queryForList(String, Class) * @see org.springframework.jdbc.core.SingleColumnRowMapper */ @@ -349,13 +349,13 @@ List queryForList(String sql, SqlParameterSource paramSource, Class el * list of arguments to bind to the query, expecting a result list. *

The results will be mapped to a List (one entry for each row) of * result objects, each of them matching the specified element type. - * @param sql SQL query to execute + * @param sql the SQL query to execute * @param paramMap map of parameters to bind to the query * (leaving it to the PreparedStatement to guess the corresponding SQL type) * @param elementType the required type of element in the result list * (for example, {@code Integer.class}) * @return a List of objects that match the specified element type - * @throws org.springframework.dao.DataAccessException if the query fails + * @throws DataAccessException if the query fails * @see org.springframework.jdbc.core.JdbcTemplate#queryForList(String, Class) * @see org.springframework.jdbc.core.SingleColumnRowMapper */ @@ -369,10 +369,10 @@ List queryForList(String sql, Map paramMap, Class elementTy * Maps (one entry for each column, using the column name as the key). * Each element in the list will be of the form returned by this interface's * {@code queryForMap} methods. - * @param sql SQL query to execute + * @param sql the SQL query to execute * @param paramSource container of arguments to bind to the query * @return a List that contains a Map per row - * @throws org.springframework.dao.DataAccessException if the query fails + * @throws DataAccessException if the query fails * @see org.springframework.jdbc.core.JdbcTemplate#queryForList(String) */ List> queryForList(String sql, SqlParameterSource paramSource) throws DataAccessException; @@ -384,11 +384,11 @@ List queryForList(String sql, Map paramMap, Class elementTy * Maps (one entry for each column, using the column name as the key). * Each element in the list will be of the form returned by this interface's * {@code queryForMap} methods. - * @param sql SQL query to execute + * @param sql the SQL query to execute * @param paramMap map of parameters to bind to the query * (leaving it to the PreparedStatement to guess the corresponding SQL type) * @return a List that contains a Map per row - * @throws org.springframework.dao.DataAccessException if the query fails + * @throws DataAccessException if the query fails * @see org.springframework.jdbc.core.JdbcTemplate#queryForList(String) */ List> queryForList(String sql, Map paramMap) throws DataAccessException; @@ -402,11 +402,11 @@ List queryForList(String sql, Map paramMap, Class elementTy * be available at runtime: by default, Sun's {@code com.sun.rowset.CachedRowSetImpl} * class is used, which is part of JDK 1.5+ and also available separately as part of * Sun's JDBC RowSet Implementations download (rowset.jar). - * @param sql SQL query to execute + * @param sql the SQL query to execute * @param paramSource container of arguments to bind to the query * @return a SqlRowSet representation (possibly a wrapper around a * {@code javax.sql.rowset.CachedRowSet}) - * @throws org.springframework.dao.DataAccessException if there is any problem executing the query + * @throws DataAccessException if there is any problem executing the query * @see org.springframework.jdbc.core.JdbcTemplate#queryForRowSet(String) * @see org.springframework.jdbc.core.SqlRowSetResultSetExtractor * @see javax.sql.rowset.CachedRowSet @@ -422,12 +422,12 @@ List queryForList(String sql, Map paramMap, Class elementTy * be available at runtime: by default, Sun's {@code com.sun.rowset.CachedRowSetImpl} * class is used, which is part of JDK 1.5+ and also available separately as part of * Sun's JDBC RowSet Implementations download (rowset.jar). - * @param sql SQL query to execute + * @param sql the SQL query to execute * @param paramMap map of parameters to bind to the query * (leaving it to the PreparedStatement to guess the corresponding SQL type) * @return a SqlRowSet representation (possibly a wrapper around a * {@code javax.sql.rowset.CachedRowSet}) - * @throws org.springframework.dao.DataAccessException if there is any problem executing the query + * @throws DataAccessException if there is any problem executing the query * @see org.springframework.jdbc.core.JdbcTemplate#queryForRowSet(String) * @see org.springframework.jdbc.core.SqlRowSetResultSetExtractor * @see javax.sql.rowset.CachedRowSet @@ -436,31 +436,31 @@ List queryForList(String sql, Map paramMap, Class elementTy /** * Issue an update via a prepared statement, binding the given arguments. - * @param sql SQL containing named parameters + * @param sql the SQL containing named parameters * @param paramSource container of arguments and SQL types to bind to the query * @return the number of rows affected - * @throws org.springframework.dao.DataAccessException if there is any problem issuing the update + * @throws DataAccessException if there is any problem issuing the update */ int update(String sql, SqlParameterSource paramSource) throws DataAccessException; /** * Issue an update via a prepared statement, binding the given arguments. - * @param sql SQL containing named parameters + * @param sql the SQL containing named parameters * @param paramMap map of parameters to bind to the query * (leaving it to the PreparedStatement to guess the corresponding SQL type) * @return the number of rows affected - * @throws org.springframework.dao.DataAccessException if there is any problem issuing the update + * @throws DataAccessException if there is any problem issuing the update */ int update(String sql, Map paramMap) throws DataAccessException; /** * Issue an update via a prepared statement, binding the given arguments, * returning generated keys. - * @param sql SQL containing named parameters + * @param sql the SQL containing named parameters * @param paramSource container of arguments and SQL types to bind to the query - * @param generatedKeyHolder KeyHolder that will hold the generated keys + * @param generatedKeyHolder a {@link KeyHolder} that will hold the generated keys * @return the number of rows affected - * @throws org.springframework.dao.DataAccessException if there is any problem issuing the update + * @throws DataAccessException if there is any problem issuing the update * @see MapSqlParameterSource * @see org.springframework.jdbc.support.GeneratedKeyHolder */ @@ -470,12 +470,12 @@ int update(String sql, SqlParameterSource paramSource, KeyHolder generatedKeyHol /** * Issue an update via a prepared statement, binding the given arguments, * returning generated keys. - * @param sql SQL containing named parameters + * @param sql the SQL containing named parameters * @param paramSource container of arguments and SQL types to bind to the query - * @param generatedKeyHolder KeyHolder that will hold the generated keys + * @param generatedKeyHolder a {@link KeyHolder} that will hold the generated keys * @param keyColumnNames names of the columns that will have keys generated for them * @return the number of rows affected - * @throws org.springframework.dao.DataAccessException if there is any problem issuing the update + * @throws DataAccessException if there is any problem issuing the update * @see MapSqlParameterSource * @see org.springframework.jdbc.support.GeneratedKeyHolder */ @@ -487,6 +487,7 @@ int update(String sql, SqlParameterSource paramSource, KeyHolder generatedKeyHol * @param sql the SQL statement to execute * @param batchValues the array of Maps containing the batch of arguments for the query * @return an array containing the numbers of rows affected by each update in the batch + * @throws DataAccessException if there is any problem issuing the update */ int[] batchUpdate(String sql, Map[] batchValues); @@ -495,6 +496,7 @@ int update(String sql, SqlParameterSource paramSource, KeyHolder generatedKeyHol * @param sql the SQL statement to execute * @param batchArgs the array of {@link SqlParameterSource} containing the batch of arguments for the query * @return an array containing the numbers of rows affected by each update in the batch + * @throws DataAccessException if there is any problem issuing the update */ int[] batchUpdate(String sql, SqlParameterSource[] batchArgs); diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DataSourceTransactionManager.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DataSourceTransactionManager.java index 6991a9e87da1..e0ba2cb7d170 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DataSourceTransactionManager.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DataSourceTransactionManager.java @@ -178,7 +178,7 @@ public DataSource getDataSource() { * through an explicit statement on the transactional connection: * "SET TRANSACTION READ ONLY" as understood by Oracle, MySQL and Postgres. *

The exact treatment, including any SQL statement executed on the connection, - * can be customized through through {@link #prepareTransactionalConnection}. + * can be customized through {@link #prepareTransactionalConnection}. *

This mode of read-only handling goes beyond the {@link Connection#setReadOnly} * hint that Spring applies by default. In contrast to that standard JDBC hint, * "SET TRANSACTION READ ONLY" enforces an isolation-level-like connection mode @@ -233,9 +233,6 @@ protected boolean isExistingTransaction(Object transaction) { return (txObject.hasConnectionHolder() && txObject.getConnectionHolder().isTransactionActive()); } - /** - * This implementation sets the isolation level but ignores the timeout. - */ @Override protected void doBegin(Object transaction, TransactionDefinition definition) { DataSourceTransactionObject txObject = (DataSourceTransactionObject) transaction; diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java b/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java index fe585785f687..6cf0e94c5a42 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2020 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. @@ -133,7 +133,7 @@ public JpaTransactionManager() { /** * Create a new JpaTransactionManager instance. - * @param emf EntityManagerFactory to manage transactions for + * @param emf the EntityManagerFactory to manage transactions for */ public JpaTransactionManager(EntityManagerFactory emf) { this(); @@ -400,8 +400,7 @@ public int getTimeout() { conHolder.setTimeoutInSeconds(timeoutToUse); } if (logger.isDebugEnabled()) { - logger.debug("Exposing JPA transaction as JDBC transaction [" + - conHolder.getConnectionHandle() + "]"); + logger.debug("Exposing JPA transaction as JDBC [" + conHolder.getConnectionHandle() + "]"); } TransactionSynchronizationManager.bindResource(getDataSource(), conHolder); txObject.setConnectionHolder(conHolder); @@ -581,13 +580,16 @@ protected void doCleanupAfterCompletion(Object transaction) { // Remove the JDBC connection holder from the thread, if exposed. if (txObject.hasConnectionHolder()) { TransactionSynchronizationManager.unbindResource(getDataSource()); - try { - getJpaDialect().releaseJdbcConnection(txObject.getConnectionHolder().getConnectionHandle(), - txObject.getEntityManagerHolder().getEntityManager()); - } - catch (Exception ex) { - // Just log it, to keep a transaction-related exception. - logger.error("Could not close JDBC connection after transaction", ex); + ConnectionHandle conHandle = txObject.getConnectionHolder().getConnectionHandle(); + if (conHandle != null) { + try { + getJpaDialect().releaseJdbcConnection(conHandle, + txObject.getEntityManagerHolder().getEntityManager()); + } + catch (Throwable ex) { + // Just log it, to keep a transaction-related exception. + logger.error("Failed to release JDBC connection after transaction", ex); + } } }