From ac5dc698e2f0f6f758983f1af3039eea627ef54d Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 28 Sep 2021 19:10:09 +0200 Subject: [PATCH] Update/remove outdated JPA and Hibernate version references Closes gh-27487 --- .../hibernate5/LocalSessionFactoryBean.java | 24 ++++++++----------- .../LocalSessionFactoryBuilder.java | 9 ++++--- .../orm/hibernate5/SpringBeanContainer.java | 12 +++++----- .../orm/jpa/DefaultJpaDialect.java | 4 +--- .../orm/jpa/EntityManagerFactoryUtils.java | 4 ++-- .../springframework/orm/jpa/JpaDialect.java | 4 ++-- ...ocalContainerEntityManagerFactoryBean.java | 6 +---- .../jpa/LocalEntityManagerFactoryBean.java | 6 +---- .../DefaultPersistenceUnitManager.java | 4 +--- .../jpa/vendor/AbstractJpaVendorAdapter.java | 4 ++-- .../orm/jpa/vendor/HibernateJpaDialect.java | 4 ++-- .../jpa/vendor/HibernateJpaVendorAdapter.java | 5 ++-- 12 files changed, 34 insertions(+), 52 deletions(-) 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 eb8fc4acfeb..7dc063b2a52 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-2020 the original author or authors. + * Copyright 2002-2021 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. @@ -51,21 +51,20 @@ import org.springframework.core.io.support.ResourcePatternUtils; import org.springframework.core.task.AsyncTaskExecutor; import org.springframework.core.type.filter.TypeFilter; import org.springframework.lang.Nullable; -import org.springframework.util.ClassUtils; /** * {@link FactoryBean} that creates a Hibernate {@link SessionFactory}. This is the usual * 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.2/5.3/5.4, as of Spring 5.3. + *

Compatible with Hibernate 5.5/5.6, as of Spring 6.0. * This Hibernate-specific {@code LocalSessionFactoryBean} can be an immediate alternative - * to {@link org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean} for common - * 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 - * mixing JPA access code with native Hibernate access code within the same transaction. + * to {@link org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean} for + * common JPA purposes: 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 mixing JPA access code + * with native Hibernate access code within the same transaction. * * @author Juergen Hoeller * @since 4.2 @@ -469,17 +468,14 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator /** * Accept the containing {@link BeanFactory}, registering corresponding Hibernate * {@link org.hibernate.resource.beans.container.spi.BeanContainer} integration for - * it if possible. This requires a Spring {@link ConfigurableListableBeanFactory} - * and Hibernate 5.3 or higher on the classpath. + * it if possible. This requires a Spring {@link ConfigurableListableBeanFactory}. * @since 5.1 * @see SpringBeanContainer * @see LocalSessionFactoryBuilder#setBeanContainer */ @Override public void setBeanFactory(BeanFactory beanFactory) { - if (beanFactory instanceof ConfigurableListableBeanFactory && - ClassUtils.isPresent("org.hibernate.resource.beans.container.spi.BeanContainer", - getClass().getClassLoader())) { + if (beanFactory instanceof ConfigurableListableBeanFactory) { this.beanFactory = (ConfigurableListableBeanFactory) beanFactory; } } 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 5fac7741cd2..0ddf08bb868 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-2020 the original author or authors. + * Copyright 2002-2021 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. @@ -77,12 +77,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.2/5.3/5.4, as of Spring 5.3. + *

Compatible with Hibernate 5.5/5.6, as of Spring 6.0. * This Hibernate-specific factory builder can also be 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/5.4 {@code BeanContainer} integration, + *

This builder supports Hibernate {@code BeanContainer} integration, * {@link MetadataSources} from custom {@link BootstrapServiceRegistryBuilder} * setup, as well as other advanced Hibernate configuration options beyond the * standard JPA bootstrap contract. @@ -221,8 +221,7 @@ public class LocalSessionFactoryBuilder extends Configuration { /** * Set a Hibernate {@link org.hibernate.resource.beans.container.spi.BeanContainer} * for the given Spring {@link ConfigurableListableBeanFactory}. - *

Note: Bean container integration requires Hibernate 5.3 or higher. - * It enables autowiring of Hibernate attribute converters and entity listeners. + *

This enables autowiring of Hibernate attribute converters and entity listeners. * @since 5.1 * @see SpringBeanContainer * @see AvailableSettings#BEAN_CONTAINER 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 92064f2a4cb..6f0d4c8b5f4 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-2020 the original author or authors. + * Copyright 2002-2021 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. @@ -34,7 +34,7 @@ import org.springframework.util.Assert; import org.springframework.util.ConcurrentReferenceHashMap; /** - * Spring's implementation of Hibernate 5.3's {@link BeanContainer} SPI, + * Spring's implementation of Hibernate's {@link BeanContainer} SPI, * delegating to a Spring {@link ConfigurableListableBeanFactory}. * *

Auto-configured by {@link LocalSessionFactoryBean#setBeanFactory}, @@ -62,10 +62,10 @@ 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/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. + * to {@link org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean} for + * common JPA purposes: 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. * * @author Juergen Hoeller * @since 5.1 diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/DefaultJpaDialect.java b/spring-orm/src/main/java/org/springframework/orm/jpa/DefaultJpaDialect.java index d78a2f79948..f562fa03e24 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/DefaultJpaDialect.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/DefaultJpaDialect.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 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,8 +36,6 @@ import org.springframework.transaction.TransactionException; *

Simply begins a standard JPA transaction in {@link #beginTransaction} and * performs standard exception translation through {@link EntityManagerFactoryUtils}. * - *

NOTE: Spring's JPA support requires JPA 2.1 or higher, as of Spring 5.0. - * * @author Juergen Hoeller * @since 2.0 * @see JpaTransactionManager#setJpaDialect diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryUtils.java b/spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryUtils.java index 2bf67927124..ceb470a9ea0 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryUtils.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 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. @@ -333,7 +333,7 @@ public abstract class EntityManagerFactoryUtils { /** * Apply the current transaction timeout, if any, to the given JPA Query object. - *

This method sets the JPA 2.0 query hint "jakarta.persistence.query.timeout" accordingly. + *

This method sets the JPA query hint "jakarta.persistence.query.timeout" accordingly. * @param query the JPA Query object * @param emf the JPA EntityManagerFactory that the Query was created for */ diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/JpaDialect.java b/spring-orm/src/main/java/org/springframework/orm/jpa/JpaDialect.java index b2c172b453f..9d519dfbfde 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/JpaDialect.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/JpaDialect.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 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. @@ -28,7 +28,7 @@ import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionException; /** - * SPI strategy that encapsulates certain functionality that standard JPA 2.1 does + * SPI strategy that encapsulates certain functionality that standard JPA 3.0 does * not offer, such as access to the underlying JDBC Connection. This strategy is * mainly intended for standalone usage of a JPA provider; most of its functionality * is not relevant when running with JTA transactions. diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBean.java b/spring-orm/src/main/java/org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBean.java index 3ec01ff8d84..a77d4f0b1a5 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBean.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2021 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. @@ -70,10 +70,6 @@ import org.springframework.util.ClassUtils; * plus the {@link EntityManagerFactoryInfo} interface which exposes additional * metadata as assembled by this FactoryBean. * - *

NOTE: Spring's JPA support requires JPA 2.1 or higher, as of Spring 5.0. - * JPA 1.0/2.0 based applications are still supported; however, a JPA 2.1 compliant - * persistence provider is needed at runtime. - * * @author Juergen Hoeller * @author Rod Johnson * @since 2.0 diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/LocalEntityManagerFactoryBean.java b/spring-orm/src/main/java/org/springframework/orm/jpa/LocalEntityManagerFactoryBean.java index 10e528cee58..68e74005785 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/LocalEntityManagerFactoryBean.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/LocalEntityManagerFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2021 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,10 +52,6 @@ import jakarta.persistence.spi.PersistenceProvider; * to the JPA provider, consider using Spring's more powerful * {@link LocalContainerEntityManagerFactoryBean} instead. * - *

NOTE: Spring's JPA support requires JPA 2.1 or higher, as of Spring 5.0. - * JPA 1.0/2.0 based applications are still supported; however, a JPA 2.1 compliant - * persistence provider is needed at runtime. - * * @author Juergen Hoeller * @author Rod Johnson * @since 2.0 diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManager.java b/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManager.java index c16527b6153..7d51f1bfa29 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManager.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 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. @@ -77,8 +77,6 @@ import org.springframework.util.ResourceUtils; * DataSource names are by default interpreted as JNDI names, and no load time weaving * is available (which requires weaving to be turned off in the persistence provider). * - *

NOTE: Spring's JPA support requires JPA 2.1 or higher, as of Spring 5.0. - * * @author Juergen Hoeller * @author Stephane Nicoll * @since 2.0 diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/AbstractJpaVendorAdapter.java b/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/AbstractJpaVendorAdapter.java index 8e6d0101f56..baa3a34b255 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/AbstractJpaVendorAdapter.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/AbstractJpaVendorAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 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. @@ -88,7 +88,7 @@ public abstract class AbstractJpaVendorAdapter implements JpaVendorAdapter { *

Note that the exact semantics of this flag depend on the underlying * persistence provider. For any more advanced needs, specify the appropriate * vendor-specific settings as "jpaProperties". - *

NOTE: Do not set this flag to 'true' while also setting JPA 2.1's + *

NOTE: Do not set this flag to 'true' while also setting JPA's * {@code jakarta.persistence.schema-generation.database.action} property. * These two schema generation mechanisms - standard JPA versus provider-native - * are mutually exclusive, e.g. with Hibernate 5. 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 327f887f08f..a87bf44b651 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-2020 the original author or authors. + * Copyright 2002-2021 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. @@ -73,7 +73,7 @@ import org.springframework.transaction.support.ResourceTransactionDefinition; /** * {@link org.springframework.orm.jpa.JpaDialect} implementation for - * Hibernate EntityManager. Developed against Hibernate 5.2/5.3/5.4. + * Hibernate EntityManager. * * @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 5807200a9c2..67d86d87e0b 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-2020 the original author or authors. + * Copyright 2002-2021 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. @@ -44,8 +44,7 @@ import org.springframework.lang.Nullable; /** * {@link org.springframework.orm.jpa.JpaVendorAdapter} implementation for Hibernate - * EntityManager. Developed and tested against Hibernate 5.3 and 5.4; - * backwards-compatible with Hibernate 5.2 at runtime on a best-effort basis. + * EntityManager. * *

Exposes Hibernate's persistence provider and Hibernate's Session as extended * EntityManager interface, and adapts {@link AbstractJpaVendorAdapter}'s common