From 27d5fdc5aa10c6a95ace0a5c94c2550be980e42d Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 26 May 2020 23:35:38 +0200 Subject: [PATCH] Polishing --- .../beans/CachedIntrospectionResults.java | 4 ++-- .../main/java/org/springframework/util/ClassUtils.java | 1 - .../jdbc/datasource/DataSourceTransactionManager.java | 3 --- .../orm/hibernate5/LocalSessionFactoryBean.java | 8 ++++---- .../orm/hibernate5/LocalSessionFactoryBuilder.java | 8 ++++---- .../orm/hibernate5/SpringBeanContainer.java | 4 ++-- .../springframework/orm/jpa/JpaTransactionManager.java | 2 +- .../orm/jpa/vendor/HibernateJpaDialect.java | 4 ++-- .../orm/jpa/vendor/HibernateJpaVendorAdapter.java | 10 +++++----- 9 files changed, 20 insertions(+), 24 deletions(-) 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 5b0af83467f..7d94fe28bd2 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-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 final 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-core/src/main/java/org/springframework/util/ClassUtils.java b/spring-core/src/main/java/org/springframework/util/ClassUtils.java index f591e20d908..e570646f9e0 100644 --- a/spring-core/src/main/java/org/springframework/util/ClassUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ClassUtils.java @@ -141,7 +141,6 @@ public abstract class ClassUtils { primitiveTypes.addAll(primitiveWrapperTypeMap.values()); Collections.addAll(primitiveTypes, boolean[].class, byte[].class, char[].class, double[].class, float[].class, int[].class, long[].class, short[].class); - primitiveTypes.add(void.class); for (Class primitiveType : primitiveTypes) { primitiveTypeNameMap.put(primitiveType.getName(), primitiveType); } 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 6118e00455c..bd960e9943d 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 @@ -250,9 +250,6 @@ public class DataSourceTransactionManager extends AbstractPlatformTransactionMan 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/hibernate5/LocalSessionFactoryBean.java b/spring-orm/src/main/java/org/springframework/orm/hibernate5/LocalSessionFactoryBean.java index 8d389e64680..f17b82d5f17 100644 --- a/spring-orm/src/main/java/org/springframework/orm/hibernate5/LocalSessionFactoryBean.java +++ b/spring-orm/src/main/java/org/springframework/orm/hibernate5/LocalSessionFactoryBean.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. @@ -58,10 +58,10 @@ import org.springframework.util.ClassUtils; * way to set up a shared Hibernate SessionFactory in a Spring application context; the * SessionFactory can then be passed to data access objects via dependency injection. * - *

Compatible with Hibernate 5.0/5.1 as well as 5.2/5.3, as of Spring 5.1. - * Set up with Hibernate 5.3, {@code LocalSessionFactoryBean} is an immediate alternative + *

Compatible with Hibernate 5.0/5.1 as well as 5.2/5.3/5.4, as of Spring 5.2. + * Set up with Hibernate 5.2+, {@code LocalSessionFactoryBean} is an immediate alternative * to {@link org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean} for common - * JPA purposes: In particular with Hibernate 5.3, the Hibernate {@code SessionFactory} + * JPA purposes: In particular with Hibernate 5.3/5.4, the Hibernate {@code SessionFactory} * will natively expose the JPA {@code EntityManagerFactory} interface as well, and * Hibernate {@code BeanContainer} integration will be registered out of the box. * In combination with {@link HibernateTransactionManager}, this naturally allows for diff --git a/spring-orm/src/main/java/org/springframework/orm/hibernate5/LocalSessionFactoryBuilder.java b/spring-orm/src/main/java/org/springframework/orm/hibernate5/LocalSessionFactoryBuilder.java index 3c8f9347883..e6f50a90d62 100644 --- a/spring-orm/src/main/java/org/springframework/orm/hibernate5/LocalSessionFactoryBuilder.java +++ b/spring-orm/src/main/java/org/springframework/orm/hibernate5/LocalSessionFactoryBuilder.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. @@ -76,12 +76,12 @@ import org.springframework.util.ClassUtils; * Typically combined with {@link HibernateTransactionManager} for declarative * transactions against the {@code SessionFactory} and its JDBC {@code DataSource}. * - *

Compatible with Hibernate 5.0/5.1 as well as 5.2/5.3, as of Spring 5.1. - * Set up with Hibernate 5.2/5.3, this builder is also a convenient way to set up + *

Compatible with Hibernate 5.0/5.1 as well as 5.2/5.3/5.4, as of Spring 5.2. + * Set up with Hibernate 5.2+, this builder is also a convenient way to set up * a JPA {@code EntityManagerFactory} since the Hibernate {@code SessionFactory} * natively exposes the JPA {@code EntityManagerFactory} interface as well now. * - *

This builder supports Hibernate 5.3 {@code BeanContainer} integration, + *

This builder supports Hibernate 5.3/5.4 {@code BeanContainer} integration, * {@link MetadataSources} from custom {@link BootstrapServiceRegistryBuilder} * setup, as well as other advanced Hibernate configuration options beyond the * standard JPA bootstrap contract. diff --git a/spring-orm/src/main/java/org/springframework/orm/hibernate5/SpringBeanContainer.java b/spring-orm/src/main/java/org/springframework/orm/hibernate5/SpringBeanContainer.java index 38e606c0227..92064f2a4cb 100644 --- a/spring-orm/src/main/java/org/springframework/orm/hibernate5/SpringBeanContainer.java +++ b/spring-orm/src/main/java/org/springframework/orm/hibernate5/SpringBeanContainer.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. @@ -63,7 +63,7 @@ import org.springframework.util.ConcurrentReferenceHashMap; * * Please note that Spring's {@link LocalSessionFactoryBean} is an immediate alternative * to {@link org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean} for common - * JPA purposes: In particular with Hibernate 5.3, the Hibernate {@code SessionFactory} + * JPA purposes: In particular with Hibernate 5.3/5.4, the Hibernate {@code SessionFactory} * will natively expose the JPA {@code EntityManagerFactory} interface as well, and * Hibernate {@code BeanContainer} integration will be registered out of the box. * 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 baca6c773e7..884f56de47a 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 @@ -398,7 +398,7 @@ public class JpaTransactionManager extends AbstractPlatformTransactionManager EntityManager em = txObject.getEntityManagerHolder().getEntityManager(); // Delegate to JpaDialect for actual transaction begin. - final int timeoutToUse = determineTimeout(definition); + int timeoutToUse = determineTimeout(definition); Object transactionData = getJpaDialect().beginTransaction(em, new JpaTransactionDefinition(definition, timeoutToUse, txObject.isNewEntityManagerHolder())); txObject.setTransactionData(transactionData); diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaDialect.java b/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaDialect.java index 4ea48ce5e97..06106935b7d 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaDialect.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaDialect.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. @@ -76,7 +76,7 @@ import org.springframework.util.ReflectionUtils; /** * {@link org.springframework.orm.jpa.JpaDialect} implementation for - * Hibernate EntityManager. Developed against Hibernate 5.1/5.2/5.3. + * Hibernate EntityManager. Developed against Hibernate 5.1/5.2/5.3/5.4. * * @author Juergen Hoeller * @author Costin Leau diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaVendorAdapter.java b/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaVendorAdapter.java index 1b8515aca37..c57cb7865fd 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaVendorAdapter.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaVendorAdapter.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. @@ -42,7 +42,7 @@ import org.springframework.lang.Nullable; /** * {@link org.springframework.orm.jpa.JpaVendorAdapter} implementation for Hibernate - * EntityManager. Developed and tested against Hibernate 5.0, 5.1, 5.2 and 5.3; + * EntityManager. Developed and tested against Hibernate 5.0, 5.1, 5.2, 5.3, 5.4; * backwards-compatible with Hibernate 4.3 at runtime on a best-effort basis. * *

Exposes Hibernate's persistence provider and EntityManager extension interface, @@ -92,7 +92,7 @@ public class HibernateJpaVendorAdapter extends AbstractJpaVendorAdapter { * JDBC Connection. *

See {@link HibernateJpaDialect#setPrepareConnection(boolean)} for details. * This is just a convenience flag passed through to {@code HibernateJpaDialect}. - *

On Hibernate 5.1/5.2, this flag remains {@code true} by default like against + *

On Hibernate 5.1+, this flag remains {@code true} by default like against * previous Hibernate versions. The vendor adapter manually enforces Hibernate's * new connection handling mode {@code DELAYED_ACQUISITION_AND_HOLD} in that case * unless a user-specified connection handling mode property indicates otherwise; @@ -155,9 +155,9 @@ public class HibernateJpaVendorAdapter extends AbstractJpaVendorAdapter { } if (connectionReleaseOnClose) { - // Hibernate 5.1/5.2: manually enforce connection release mode ON_CLOSE (the former default) + // Hibernate 5.1+: manually enforce connection release mode ON_CLOSE (the former default) try { - // Try Hibernate 5.2 + // Try Hibernate 5.2+ AvailableSettings.class.getField("CONNECTION_HANDLING"); jpaProperties.put("hibernate.connection.handling_mode", "DELAYED_ACQUISITION_AND_HOLD"); }