diff --git a/settings.gradle b/settings.gradle index 79a1490dc5..53a8c6da19 100644 --- a/settings.gradle +++ b/settings.gradle @@ -59,6 +59,7 @@ include "spring-boot-project:spring-boot-jackson" include "spring-boot-project:spring-boot-jdbc" include "spring-boot-project:spring-boot-jetty" include "spring-boot-project:spring-boot-jms" +include "spring-boot-project:spring-boot-jpa" include "spring-boot-project:spring-boot-jsonb" include "spring-boot-project:spring-boot-kafka" include "spring-boot-project:spring-boot-liquibase" diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle b/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle index 9f904ae02c..9f640bd954 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle @@ -25,6 +25,7 @@ dependencies { optional(project(":spring-boot-project:spring-boot-jackson")) optional(project(":spring-boot-project:spring-boot-jdbc")) optional(project(":spring-boot-project:spring-boot-jetty")) + optional(project(":spring-boot-project:spring-boot-jpa")) optional(project(":spring-boot-project:spring-boot-jsonb")) optional(project(":spring-boot-project:spring-boot-kafka")) optional(project(":spring-boot-project:spring-boot-liquibase")) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/orm/jpa/HibernateMetricsAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/orm/jpa/HibernateMetricsAutoConfiguration.java index b973390e72..0d7ce59714 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/orm/jpa/HibernateMetricsAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/orm/jpa/HibernateMetricsAutoConfiguration.java @@ -34,7 +34,6 @@ import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.util.StringUtils; /** @@ -45,8 +44,8 @@ import org.springframework.util.StringUtils; * @author Stephane Nicoll * @since 2.1.0 */ -@AutoConfiguration(after = { MetricsAutoConfiguration.class, HibernateJpaAutoConfiguration.class, - SimpleMetricsExportAutoConfiguration.class }) +@AutoConfiguration(after = { MetricsAutoConfiguration.class, SimpleMetricsExportAutoConfiguration.class }, + afterName = "org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration") @ConditionalOnClass({ EntityManagerFactory.class, SessionFactory.class, HibernateMetrics.class, MeterRegistry.class }) @ConditionalOnBean({ EntityManagerFactory.class, MeterRegistry.class }) public class HibernateMetricsAutoConfiguration implements SmartInitializingSingleton { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/data/RepositoryMetricsAutoConfigurationIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/data/RepositoryMetricsAutoConfigurationIntegrationTests.java index 29c2938c28..35df19c8ff 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/data/RepositoryMetricsAutoConfigurationIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/data/RepositoryMetricsAutoConfigurationIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2025 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,8 +27,8 @@ import org.springframework.boot.autoconfigure.AutoConfigurationPackage; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration; -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.EmbeddedDataSourceConfiguration; +import org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/orm/jpa/HibernateMetricsAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/orm/jpa/HibernateMetricsAutoConfigurationTests.java index a50bdba041..c4378acce8 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/orm/jpa/HibernateMetricsAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/orm/jpa/HibernateMetricsAutoConfigurationTests.java @@ -34,11 +34,11 @@ import org.mockito.ArgumentMatchers; import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun; import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.autoconfigure.orm.jpa.EntityManagerFactoryBuilderCustomizer; -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.DataSourceInitializationAutoConfiguration; -import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; +import org.springframework.boot.jpa.EntityManagerFactoryBuilder; +import org.springframework.boot.jpa.autoconfigure.EntityManagerFactoryBuilderCustomizer; +import org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration; import org.springframework.boot.test.context.FilteredClassLoader; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.testsupport.classpath.resources.WithResource; diff --git a/spring-boot-project/spring-boot-all/src/main/resources/META-INF/spring.factories b/spring-boot-project/spring-boot-all/src/main/resources/META-INF/spring.factories index f2ead15079..22c48e78b4 100644 --- a/spring-boot-project/spring-boot-all/src/main/resources/META-INF/spring.factories +++ b/spring-boot-project/spring-boot-all/src/main/resources/META-INF/spring.factories @@ -6,11 +6,6 @@ org.springframework.boot.rsocket.context.RSocketPortInfoApplicationContextInitia org.springframework.boot.env.EnvironmentPostProcessor=\ org.springframework.boot.reactor.ReactorEnvironmentPostProcessor -# Database Initializer Detectors -org.springframework.boot.sql.init.dependency.DatabaseInitializerDetector=\ -org.springframework.boot.orm.jpa.JpaDatabaseInitializerDetector - # Depends On Database Initialization Detectors org.springframework.boot.sql.init.dependency.DependsOnDatabaseInitializationDetector=\ -org.springframework.boot.jooq.JooqDependsOnDatabaseInitializationDetector,\ -org.springframework.boot.orm.jpa.JpaDependsOnDatabaseInitializationDetector +org.springframework.boot.jooq.JooqDependsOnDatabaseInitializationDetector diff --git a/spring-boot-project/spring-boot-autoconfigure-all/build.gradle b/spring-boot-project/spring-boot-autoconfigure-all/build.gradle index a4e7e7d21a..e516c0031a 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/build.gradle +++ b/spring-boot-project/spring-boot-autoconfigure-all/build.gradle @@ -47,6 +47,7 @@ dependencies { optional(project(":spring-boot-project:spring-boot-flyway")) optional(project(":spring-boot-project:spring-boot-jackson")) optional(project(":spring-boot-project:spring-boot-jdbc")) + optional(project(":spring-boot-project:spring-boot-jpa")) optional(project(":spring-boot-project:spring-boot-jsonb")) optional(project(":spring-boot-project:spring-boot-liquibase")) optional(project(":spring-boot-project:spring-boot-r2dbc")) diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java index da5c5f333d..e04d268219 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java @@ -35,7 +35,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.autoconfigure.sql.init.OnDatabaseInitializationCondition; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.sql.init.dependency.DatabaseInitializationDependencyConfigurer; @@ -70,7 +69,8 @@ import org.springframework.util.StringUtils; * @author Yanming Zhou * @since 1.0.0 */ -@AutoConfiguration(after = { HibernateJpaAutoConfiguration.class, TransactionAutoConfiguration.class }) +@AutoConfiguration(after = TransactionAutoConfiguration.class, + afterName = "org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration") @ConditionalOnClass({ JobLauncher.class, DataSource.class, DatabasePopulator.class }) @ConditionalOnBean({ DataSource.class, PlatformTransactionManager.class }) @ConditionalOnMissingBean(value = DefaultBatchConfiguration.class, annotation = EnableBatchProcessing.class) diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfiguration.java index 49d331a58f..948b9ff428 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfiguration.java @@ -21,20 +21,20 @@ import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration.CacheConfigurationImportSelector; -import org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration.CacheManagerEntityManagerFactoryDependsOnPostProcessor; +import org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration.CacheManagerEntityManagerFactoryDependsOnConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.data.couchbase.CouchbaseDataAutoConfiguration; import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; import org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration; -import org.springframework.boot.autoconfigure.orm.jpa.EntityManagerFactoryDependsOnPostProcessor; -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.boot.jpa.autoconfigure.EntityManagerFactoryDependsOnPostProcessor; import org.springframework.cache.CacheManager; import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.interceptor.CacheAspectSupport; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.context.annotation.ImportSelector; import org.springframework.core.type.AnnotationMetadata; @@ -53,13 +53,15 @@ import org.springframework.util.Assert; * @since 1.3.0 * @see EnableCaching */ -@AutoConfiguration(after = { CouchbaseDataAutoConfiguration.class, HazelcastAutoConfiguration.class, - HibernateJpaAutoConfiguration.class, RedisAutoConfiguration.class }) +@AutoConfiguration( + after = { CouchbaseDataAutoConfiguration.class, HazelcastAutoConfiguration.class, + RedisAutoConfiguration.class }, + afterName = "org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration") @ConditionalOnClass(CacheManager.class) @ConditionalOnBean(CacheAspectSupport.class) @ConditionalOnMissingBean(value = CacheManager.class, name = "cacheResolver") @EnableConfigurationProperties(CacheProperties.class) -@Import({ CacheConfigurationImportSelector.class, CacheManagerEntityManagerFactoryDependsOnPostProcessor.class }) +@Import({ CacheConfigurationImportSelector.class, CacheManagerEntityManagerFactoryDependsOnConfiguration.class }) public class CacheAutoConfiguration { @Bean @@ -74,8 +76,15 @@ public class CacheAutoConfiguration { return new CacheManagerValidator(cacheProperties, cacheManager); } - @ConditionalOnClass(LocalContainerEntityManagerFactoryBean.class) + @Configuration(proxyBeanMethods = false) + @ConditionalOnClass({ EntityManagerFactoryDependsOnPostProcessor.class, + LocalContainerEntityManagerFactoryBean.class }) @ConditionalOnBean(AbstractEntityManagerFactoryBean.class) + @Import(CacheManagerEntityManagerFactoryDependsOnPostProcessor.class) + static class CacheManagerEntityManagerFactoryDependsOnConfiguration { + + } + static class CacheManagerEntityManagerFactoryDependsOnPostProcessor extends EntityManagerFactoryDependsOnPostProcessor { diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/data/jpa/JpaRepositoriesAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/data/jpa/JpaRepositoriesAutoConfiguration.java index 08cf97b59d..65a3a06f36 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/data/jpa/JpaRepositoriesAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/data/jpa/JpaRepositoriesAutoConfiguration.java @@ -29,9 +29,9 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration.JpaRepositoriesImportSelector; -import org.springframework.boot.autoconfigure.orm.jpa.EntityManagerFactoryBuilderCustomizer; -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration; +import org.springframework.boot.jpa.autoconfigure.EntityManagerFactoryBuilderCustomizer; +import org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Import; diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastJpaDependencyAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastJpaDependencyAutoConfiguration.java index 2b00af66f1..ff37ec7243 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastJpaDependencyAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastJpaDependencyAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * Copyright 2012-2025 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. @@ -23,10 +23,10 @@ import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.AllNestedConditions; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.hazelcast.HazelcastJpaDependencyAutoConfiguration.HazelcastInstanceEntityManagerFactoryDependsOnPostProcessor; -import org.springframework.boot.autoconfigure.orm.jpa.EntityManagerFactoryDependsOnPostProcessor; -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; +import org.springframework.boot.autoconfigure.hazelcast.HazelcastJpaDependencyAutoConfiguration.HazelcastInstanceEntityManagerFactoryDependsOnConfiguration; +import org.springframework.boot.jpa.autoconfigure.EntityManagerFactoryDependsOnPostProcessor; import org.springframework.context.annotation.Conditional; +import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.orm.jpa.AbstractEntityManagerFactoryBean; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; @@ -38,12 +38,20 @@ import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; * @author Stephane Nicoll * @since 1.3.2 */ -@AutoConfiguration(after = { HazelcastAutoConfiguration.class, HibernateJpaAutoConfiguration.class }) +@AutoConfiguration(after = HazelcastAutoConfiguration.class, + afterName = "org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration") @ConditionalOnClass({ HazelcastInstance.class, LocalContainerEntityManagerFactoryBean.class }) -@Import(HazelcastInstanceEntityManagerFactoryDependsOnPostProcessor.class) +@Import(HazelcastInstanceEntityManagerFactoryDependsOnConfiguration.class) public class HazelcastJpaDependencyAutoConfiguration { + @Configuration(proxyBeanMethods = false) + @ConditionalOnClass(EntityManagerFactoryDependsOnPostProcessor.class) @Conditional(OnHazelcastAndJpaCondition.class) + @Import(HazelcastInstanceEntityManagerFactoryDependsOnPostProcessor.class) + static class HazelcastInstanceEntityManagerFactoryDependsOnConfiguration { + + } + static class HazelcastInstanceEntityManagerFactoryDependsOnPostProcessor extends EntityManagerFactoryDependsOnPostProcessor { diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfiguration.java index 19d6e07537..bdc83494f5 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfiguration.java @@ -33,7 +33,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate; -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.autoconfigure.sql.init.OnDatabaseInitializationCondition; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; @@ -55,7 +54,8 @@ import org.springframework.transaction.PlatformTransactionManager; * @author Stephane Nicoll * @since 2.0.0 */ -@AutoConfiguration(after = { DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class }) +@AutoConfiguration(after = DataSourceAutoConfiguration.class, + afterName = "org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration") @ConditionalOnClass({ Scheduler.class, SchedulerFactoryBean.class, PlatformTransactionManager.class }) @EnableConfigurationProperties(QuartzProperties.class) public class QuartzAutoConfiguration { diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot-autoconfigure-all/src/main/resources/META-INF/additional-spring-configuration-metadata.json index ed8a9310d9..239140f439 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot-autoconfigure-all/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -783,19 +783,6 @@ "reason": "The new InfluxDb Java client provides Spring Boot integration." } }, - { - "name": "spring.jpa.hibernate.use-new-id-generator-mappings", - "type": "java.lang.Boolean", - "description": "Whether to use Hibernate's newer IdentifierGenerator for AUTO, TABLE and SEQUENCE. This is actually a shortcut for the \"hibernate.id.new_generator_mappings\" property. When not specified will default to \"true\".", - "deprecation": { - "level": "error", - "reason": "Hibernate no longer supports disabling the use of new ID generator mappings." - } - }, - { - "name": "spring.jpa.open-in-view", - "defaultValue": true - }, { "name": "spring.jta.enabled", "type": "java.lang.Boolean", @@ -1809,65 +1796,6 @@ } ] }, - { - "name": "spring.jpa.hibernate.ddl-auto", - "values": [ - { - "value": "create", - "description": "Create the schema and destroy previous data." - }, - { - "value": "create-drop", - "description": "Create and then destroy the schema at the end of the session." - }, - { - "value": "create-only", - "description": "Create the schema." - }, - { - "value": "drop", - "description": "Drop the schema." - }, - { - "value": "none", - "description": "Disable DDL handling." - }, - { - "value": "truncate", - "description": "Truncate the tables in the schema." - }, - { - "value": "update", - "description": "Update the schema if necessary." - }, - { - "value": "validate", - "description": "Validate the schema, make no changes to the database." - } - ] - }, - { - "name": "spring.jpa.hibernate.naming.implicit-strategy", - "providers": [ - { - "name": "class-reference", - "parameters": { - "target": "org.hibernate.boot.model.naming.ImplicitNamingStrategy" - } - } - ] - }, - { - "name": "spring.jpa.hibernate.naming.physical-strategy", - "providers": [ - { - "name": "class-reference", - "parameters": { - "target": "org.hibernate.boot.model.naming.PhysicalNamingStrategy" - } - } - ] - }, { "name": "spring.kafka.consumer.auto-offset-reset", "values": [ diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/spring-boot-project/spring-boot-autoconfigure-all/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 4f45cfa521..68731fce96 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/spring-boot-project/spring-boot-autoconfigure-all/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -65,7 +65,6 @@ org.springframework.boot.autoconfigure.mongo.MongoReactiveAutoConfiguration org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration org.springframework.boot.autoconfigure.neo4j.Neo4jAutoConfiguration org.springframework.boot.autoconfigure.netty.NettyAutoConfiguration -org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration org.springframework.boot.autoconfigure.reactor.ReactorAutoConfiguration org.springframework.boot.autoconfigure.rsocket.RSocketMessagingAutoConfiguration diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java index 3e3c0aa908..18607863ed 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java @@ -60,13 +60,13 @@ import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage; import org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration.SpringBootBatchConfiguration; import org.springframework.boot.autoconfigure.batch.domain.City; -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.flyway.autoconfigure.FlywayAutoConfiguration; import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.DataSourceTransactionManagerAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.EmbeddedDataSourceConfiguration; import org.springframework.boot.jdbc.init.DataSourceScriptDatabaseInitializer; +import org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration; import org.springframework.boot.liquibase.autoconfigure.LiquibaseAutoConfiguration; import org.springframework.boot.sql.init.DatabaseInitializationMode; import org.springframework.boot.sql.init.DatabaseInitializationSettings; diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfigurationTests.java index 25359d2a04..3ecd152469 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2025 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. @@ -23,8 +23,8 @@ import jakarta.persistence.EntityManagerFactory; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.EmbeddedDataSourceConfiguration; +import org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration; import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/data/jpa/AbstractJpaRepositoriesAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/data/jpa/AbstractJpaRepositoriesAutoConfigurationTests.java index 97607cb767..cdbfe68b01 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/data/jpa/AbstractJpaRepositoriesAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/data/jpa/AbstractJpaRepositoriesAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2025 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,10 +28,10 @@ import org.springframework.boot.autoconfigure.data.alt.mongo.CityMongoDbReposito import org.springframework.boot.autoconfigure.data.jpa.city.City; import org.springframework.boot.autoconfigure.data.jpa.city.CityRepository; import org.springframework.boot.autoconfigure.data.jpa.country.Country; -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration; import org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.EmbeddedDataSourceConfiguration; +import org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan.Filter; diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MixedMongoRepositoriesAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MixedMongoRepositoriesAutoConfigurationTests.java index 80ab4fbac6..8ea8409944 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MixedMongoRepositoriesAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MixedMongoRepositoriesAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2025 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. @@ -30,8 +30,8 @@ import org.springframework.boot.autoconfigure.data.mongo.country.Country; import org.springframework.boot.autoconfigure.data.mongo.country.CountryRepository; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration; -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; +import org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration; import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Configuration; diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/MixedNeo4jRepositoriesAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/MixedNeo4jRepositoriesAutoConfigurationTests.java index 2020cc0480..24cb9b5151 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/MixedNeo4jRepositoriesAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/MixedNeo4jRepositoriesAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2025 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,8 +32,8 @@ import org.springframework.boot.autoconfigure.data.neo4j.country.Country; import org.springframework.boot.autoconfigure.data.neo4j.country.CountryRepository; import org.springframework.boot.autoconfigure.data.neo4j.empty.EmptyMarker; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; +import org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration; import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestMvcAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestMvcAutoConfigurationTests.java index b81bfa1766..5ad129c3b7 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestMvcAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestMvcAutoConfigurationTests.java @@ -26,9 +26,9 @@ import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration; import org.springframework.boot.autoconfigure.data.jpa.city.City; -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.EmbeddedDataSourceConfiguration; +import org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration; import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext; import org.springframework.context.annotation.Bean; diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/data/web/SpringDataWebAutoConfigurationJpaTests.java b/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/data/web/SpringDataWebAutoConfigurationJpaTests.java index 7bdae3ec77..211c5c0b0b 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/data/web/SpringDataWebAutoConfigurationJpaTests.java +++ b/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/data/web/SpringDataWebAutoConfigurationJpaTests.java @@ -23,8 +23,8 @@ import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage; import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration; import org.springframework.boot.autoconfigure.data.jpa.city.City; import org.springframework.boot.autoconfigure.data.jpa.city.CityRepository; -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; +import org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration; import org.springframework.boot.test.context.runner.WebApplicationContextRunner; import org.springframework.context.annotation.Configuration; import org.springframework.data.geo.Distance; diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastJpaDependencyAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastJpaDependencyAutoConfigurationTests.java index f3b71853b3..b5c86bb315 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastJpaDependencyAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastJpaDependencyAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2025 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,9 +27,9 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.hazelcast.HazelcastJpaDependencyAutoConfiguration.HazelcastInstanceEntityManagerFactoryDependsOnPostProcessor; -import org.springframework.boot.autoconfigure.orm.jpa.EntityManagerFactoryDependsOnPostProcessor; -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; +import org.springframework.boot.jpa.autoconfigure.EntityManagerFactoryDependsOnPostProcessor; +import org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration; import org.springframework.boot.test.context.assertj.AssertableApplicationContext; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.annotation.Bean; diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/security/jpa/JpaUserDetailsTests.java b/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/security/jpa/JpaUserDetailsTests.java index 99937fc3ca..4b92051de9 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/security/jpa/JpaUserDetailsTests.java +++ b/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/security/jpa/JpaUserDetailsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2025 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. @@ -19,10 +19,10 @@ package org.springframework.boot.autoconfigure.security.jpa; import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.EmbeddedDataSourceConfiguration; +import org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration; import org.springframework.boot.test.context.SpringBootContextLoader; import org.springframework.context.annotation.Import; import org.springframework.test.annotation.DirtiesContext; diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/security/servlet/SecurityAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/security/servlet/SecurityAutoConfigurationTests.java index 0232fadb27..b8736e0fb7 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/security/servlet/SecurityAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/security/servlet/SecurityAutoConfigurationTests.java @@ -30,7 +30,6 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.autoconfigure.security.jpa.City; import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -38,6 +37,7 @@ import org.springframework.boot.context.properties.ConfigurationPropertiesBindin import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.convert.ApplicationConversionService; import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; +import org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration; import org.springframework.boot.test.context.FilteredClassLoader; import org.springframework.boot.test.context.runner.WebApplicationContextRunner; import org.springframework.boot.testsupport.classpath.resources.WithResource; diff --git a/spring-boot-project/spring-boot-autoconfigure/build.gradle b/spring-boot-project/spring-boot-autoconfigure/build.gradle index 29c725eba9..849ed332ea 100644 --- a/spring-boot-project/spring-boot-autoconfigure/build.gradle +++ b/spring-boot-project/spring-boot-autoconfigure/build.gradle @@ -13,6 +13,7 @@ dependencies { api(project(":spring-boot-project:spring-boot")) optional("com.github.ben-manes.caffeine:caffeine") + optional("jakarta.persistence:jakarta.persistence-api") optional("jakarta.servlet:jakarta.servlet-api") optional("org.springframework:spring-web") diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/domain/EntityScan.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/domain/EntityScan.java similarity index 74% rename from spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/domain/EntityScan.java rename to spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/domain/EntityScan.java index 078cea2e79..551c8caa26 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/domain/EntityScan.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/domain/EntityScan.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * Copyright 2012-2025 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,23 +27,8 @@ import org.springframework.core.annotation.AliasFor; /** * Configures the base packages used by auto-configuration when scanning for entity - * classes. - *

- * Using {@code @EntityScan} will cause auto-configuration to: - *

+ * classes. Refer to the documentation of the data technology you are using for more + * details. *

* One of {@link #basePackageClasses()}, {@link #basePackages()} or its alias * {@link #value()} may be specified to define specific packages to scan. If specific @@ -51,7 +36,7 @@ import org.springframework.core.annotation.AliasFor; * annotation. * * @author Phillip Webb - * @since 1.4.0 + * @since 4.0.0 * @see EntityScanPackages */ @Target(ElementType.TYPE) diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/domain/EntityScanPackages.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/domain/EntityScanPackages.java similarity index 99% rename from spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/domain/EntityScanPackages.java rename to spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/domain/EntityScanPackages.java index 0da1e32298..696dc56283 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/domain/EntityScanPackages.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/domain/EntityScanPackages.java @@ -43,7 +43,7 @@ import org.springframework.util.StringUtils; * (e.g. by JPA auto-configuration). * * @author Phillip Webb - * @since 1.4.0 + * @since 4.0.0 * @see EntityScan * @see EntityScanner */ diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/domain/EntityScanner.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/domain/EntityScanner.java similarity index 99% rename from spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/domain/EntityScanner.java rename to spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/domain/EntityScanner.java index 8b291eb82f..0c7c5de8b0 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/domain/EntityScanner.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/domain/EntityScanner.java @@ -36,7 +36,7 @@ import org.springframework.util.StringUtils; * specified packages. * * @author Phillip Webb - * @since 1.4.0 + * @since 4.0.0 */ public class EntityScanner { diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/domain/package-info.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/domain/package-info.java similarity index 92% rename from spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/domain/package-info.java rename to spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/domain/package-info.java index 7383994921..1910a0fe63 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/domain/package-info.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/domain/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2025 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. diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/domain/EntityScanPackagesTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/EntityScanPackagesTests.java similarity index 100% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/domain/EntityScanPackagesTests.java rename to spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/EntityScanPackagesTests.java diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/domain/EntityScannerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/EntityScannerTests.java similarity index 100% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/domain/EntityScannerTests.java rename to spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/EntityScannerTests.java diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/domain/scan/a/EmbeddableA.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/scan/a/EmbeddableA.java similarity index 92% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/domain/scan/a/EmbeddableA.java rename to spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/scan/a/EmbeddableA.java index f55a53436b..a3e78a4ff1 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/domain/scan/a/EmbeddableA.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/scan/a/EmbeddableA.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2025 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. diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/domain/scan/a/EntityA.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/scan/a/EntityA.java similarity index 92% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/domain/scan/a/EntityA.java rename to spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/scan/a/EntityA.java index c4763f95fc..c79b25c3a4 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/domain/scan/a/EntityA.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/scan/a/EntityA.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2025 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. diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/domain/scan/b/EmbeddableB.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/scan/b/EmbeddableB.java similarity index 92% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/domain/scan/b/EmbeddableB.java rename to spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/scan/b/EmbeddableB.java index 0ca02e0aca..47e05e5db9 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/domain/scan/b/EmbeddableB.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/scan/b/EmbeddableB.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2025 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. diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/domain/scan/b/EntityB.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/scan/b/EntityB.java similarity index 92% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/domain/scan/b/EntityB.java rename to spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/scan/b/EntityB.java index c38cce72f1..4b67a45492 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/domain/scan/b/EntityB.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/scan/b/EntityB.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2025 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. diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/domain/scan/c/EmbeddableC.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/scan/c/EmbeddableC.java similarity index 92% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/domain/scan/c/EmbeddableC.java rename to spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/scan/c/EmbeddableC.java index 5a72780f1d..fa025eb8d9 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/domain/scan/c/EmbeddableC.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/scan/c/EmbeddableC.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2025 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. diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/domain/scan/c/EntityC.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/scan/c/EntityC.java similarity index 92% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/domain/scan/c/EntityC.java rename to spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/scan/c/EntityC.java index 2b494cff15..78ad547b29 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/domain/scan/c/EntityC.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/domain/scan/c/EntityC.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2025 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. diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 5cd8339a73..9ba19867ac 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1995,6 +1995,7 @@ bom { "spring-boot-jdbc", "spring-boot-jetty", "spring-boot-jms", + "spring-boot-jpa", "spring-boot-jsonb", "spring-boot-kafka", "spring-boot-liquibase", diff --git a/spring-boot-project/spring-boot-devtools/build.gradle b/spring-boot-project/spring-boot-devtools/build.gradle index 9685a06a55..f59a4f3c5e 100644 --- a/spring-boot-project/spring-boot-devtools/build.gradle +++ b/spring-boot-project/spring-boot-devtools/build.gradle @@ -37,6 +37,7 @@ dependencies { intTestRuntimeOnly("org.springframework:spring-web") optional(project(":spring-boot-project:spring-boot-jdbc")) + optional(project(":spring-boot-project:spring-boot-jpa")) optional(project(":spring-boot-project:spring-boot-r2dbc")) optional("io.projectreactor:reactor-core") optional("io.r2dbc:r2dbc-spi") diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/DevToolsDataSourceAutoConfiguration.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/DevToolsDataSourceAutoConfiguration.java index 3f3eb3629c..4c4d175cc3 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/DevToolsDataSourceAutoConfiguration.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/DevToolsDataSourceAutoConfiguration.java @@ -36,14 +36,15 @@ import org.springframework.boot.autoconfigure.condition.ConditionOutcome; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.SpringBootCondition; -import org.springframework.boot.autoconfigure.orm.jpa.EntityManagerFactoryDependsOnPostProcessor; -import org.springframework.boot.devtools.autoconfigure.DevToolsDataSourceAutoConfiguration.DatabaseShutdownExecutorEntityManagerFactoryDependsOnPostProcessor; +import org.springframework.boot.devtools.autoconfigure.DevToolsDataSourceAutoConfiguration.DatabaseShutdownExecutorEntityManagerFactoryDependsOnConfiguration; import org.springframework.boot.devtools.autoconfigure.DevToolsDataSourceAutoConfiguration.DevToolsDataSourceCondition; import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.DataSourceProperties; +import org.springframework.boot.jpa.autoconfigure.EntityManagerFactoryDependsOnPostProcessor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ConditionContext; import org.springframework.context.annotation.Conditional; +import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ConfigurationCondition; import org.springframework.context.annotation.Import; import org.springframework.core.type.AnnotatedTypeMetadata; @@ -61,7 +62,7 @@ import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; @ConditionalOnEnabledDevTools @Conditional(DevToolsDataSourceCondition.class) @AutoConfiguration(afterName = "org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration") -@Import(DatabaseShutdownExecutorEntityManagerFactoryDependsOnPostProcessor.class) +@Import(DatabaseShutdownExecutorEntityManagerFactoryDependsOnConfiguration.class) public class DevToolsDataSourceAutoConfiguration { @Bean @@ -70,12 +71,19 @@ public class DevToolsDataSourceAutoConfiguration { return new NonEmbeddedInMemoryDatabaseShutdownExecutor(dataSource, dataSourceProperties); } + @Configuration(proxyBeanMethods = false) + @ConditionalOnClass({ EntityManagerFactoryDependsOnPostProcessor.class, + LocalContainerEntityManagerFactoryBean.class }) + @ConditionalOnBean(AbstractEntityManagerFactoryBean.class) + @Import(DatabaseShutdownExecutorEntityManagerFactoryDependsOnPostProcessor.class) + static class DatabaseShutdownExecutorEntityManagerFactoryDependsOnConfiguration { + + } + /** * Post processor to ensure that {@link jakarta.persistence.EntityManagerFactory} * beans depend on the {@code inMemoryDatabaseShutdownExecutor} bean. */ - @ConditionalOnClass(LocalContainerEntityManagerFactoryBean.class) - @ConditionalOnBean(AbstractEntityManagerFactoryBean.class) static class DatabaseShutdownExecutorEntityManagerFactoryDependsOnPostProcessor extends EntityManagerFactoryDependsOnPostProcessor { diff --git a/spring-boot-project/spring-boot-docs/build.gradle b/spring-boot-project/spring-boot-docs/build.gradle index 7f26560f57..4c37d15643 100644 --- a/spring-boot-project/spring-boot-docs/build.gradle +++ b/spring-boot-project/spring-boot-docs/build.gradle @@ -73,6 +73,7 @@ dependencies { autoConfiguration(project(path: ":spring-boot-project:spring-boot-jdbc", configuration: "autoConfigurationMetadata")) autoConfiguration(project(path: ":spring-boot-project:spring-boot-jetty", configuration: "autoConfigurationMetadata")) autoConfiguration(project(path: ":spring-boot-project:spring-boot-jms", configuration: "autoConfigurationMetadata")) + autoConfiguration(project(path: ":spring-boot-project:spring-boot-jpa", configuration: "autoConfigurationMetadata")) autoConfiguration(project(path: ":spring-boot-project:spring-boot-jsonb", configuration: "autoConfigurationMetadata")) autoConfiguration(project(path: ":spring-boot-project:spring-boot-kafka", configuration: "autoConfigurationMetadata")) autoConfiguration(project(path: ":spring-boot-project:spring-boot-liquibase", configuration: "autoConfigurationMetadata")) @@ -101,6 +102,7 @@ dependencies { configurationProperties(project(path: ":spring-boot-project:spring-boot-freemarker", configuration: "configurationPropertiesMetadata")) configurationProperties(project(path: ":spring-boot-project:spring-boot-jackson", configuration: "configurationPropertiesMetadata")) configurationProperties(project(path: ":spring-boot-project:spring-boot-jdbc", configuration: "configurationPropertiesMetadata")) + configurationProperties(project(path: ":spring-boot-project:spring-boot-jpa", configuration: "configurationPropertiesMetadata")) configurationProperties(project(path: ":spring-boot-project:spring-boot-jetty", configuration: "configurationPropertiesMetadata")) configurationProperties(project(path: ":spring-boot-project:spring-boot-jms", configuration: "configurationPropertiesMetadata")) configurationProperties(project(path: ":spring-boot-project:spring-boot-kafka", configuration: "configurationPropertiesMetadata")) @@ -126,6 +128,7 @@ dependencies { implementation(project(path: ":spring-boot-project:spring-boot-docker-compose")) implementation(project(path: ":spring-boot-project:spring-boot-jackson")) implementation(project(path: ":spring-boot-project:spring-boot-jdbc")) + implementation(project(path: ":spring-boot-project:spring-boot-jpa")) implementation(project(path: ":spring-boot-project:spring-boot-jms")) implementation(project(path: ":spring-boot-project:spring-boot-jsonb")) implementation(project(path: ":spring-boot-project:spring-boot-reactor-netty")) diff --git a/spring-boot-project/spring-boot-docs/src/docs/antora/modules/how-to/pages/data-access.adoc b/spring-boot-project/spring-boot-docs/src/docs/antora/modules/how-to/pages/data-access.adoc index c539f635f3..08fda3d877 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/antora/modules/how-to/pages/data-access.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/antora/modules/how-to/pages/data-access.adoc @@ -229,7 +229,7 @@ For example, if you want to configure Hibernate's batch size you must use `+spri If you use other forms, such as `batchSize` or `batch-size`, Hibernate will not apply the setting. ==== -TIP: If you need to apply advanced customization to Hibernate properties, consider registering a javadoc:org.springframework.boot.autoconfigure.orm.jpa.HibernatePropertiesCustomizer[] bean that will be invoked prior to creating the javadoc:jakarta.persistence.EntityManagerFactory[]. +TIP: If you need to apply advanced customization to Hibernate properties, consider registering a javadoc:org.springframework.boot.jpa.autoconfigure.hibernate.HibernatePropertiesCustomizer[] bean that will be invoked prior to creating the javadoc:jakarta.persistence.EntityManagerFactory[]. This takes precedence over anything that is applied by the auto-configuration. @@ -275,7 +275,7 @@ Hibernate {url-hibernate-userguide}#caching[second-level cache] can be configure Rather than configuring Hibernate to lookup the cache provider again, it is better to provide the one that is available in the context whenever possible. To do this with JCache, first make sure that `org.hibernate.orm:hibernate-jcache` is available on the classpath. -Then, add a javadoc:org.springframework.boot.autoconfigure.orm.jpa.HibernatePropertiesCustomizer[] bean as shown in the following example: +Then, add a javadoc:org.springframework.boot.jpa.autoconfigure.hibernate.HibernatePropertiesCustomizer[] bean as shown in the following example: include-code::MyHibernateSecondLevelCacheConfiguration[] @@ -290,7 +290,7 @@ For details, see {url-hibernate-userguide}#caching-provider-jcache[the Hibernate By default, Spring Boot registers a javadoc:org.hibernate.resource.beans.container.spi.BeanContainer[] implementation that uses the javadoc:org.springframework.beans.factory.BeanFactory[] so that converters and entity listeners can use regular dependency injection. -You can disable or tune this behavior by registering a javadoc:org.springframework.boot.autoconfigure.orm.jpa.HibernatePropertiesCustomizer[] that removes or changes the `hibernate.resource.beans.container` property. +You can disable or tune this behavior by registering a javadoc:org.springframework.boot.jpa.autoconfigure.hibernate.HibernatePropertiesCustomizer[] that removes or changes the `hibernate.resource.beans.container` property. @@ -301,7 +301,7 @@ To take full control of the configuration of the javadoc:jakarta.persistence.Ent Spring Boot auto-configuration switches off its entity manager in the presence of a bean of that type. NOTE: When you create a bean for javadoc:org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean[] yourself, any customization that was applied during the creation of the auto-configured javadoc:org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean[] is lost. -Make sure to use the auto-configured javadoc:org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder[] to retain JPA and vendor properties. +Make sure to use the auto-configured javadoc:org.springframework.boot.jpa.EntityManagerFactoryBuilder[] to retain JPA and vendor properties. This is particularly important if you were relying on `spring.jpa.*` properties for configuring things like the naming strategy or the DDL mode. @@ -311,7 +311,7 @@ This is particularly important if you were relying on `spring.jpa.*` properties If you need to use JPA against multiple datasources, you likely need one javadoc:jakarta.persistence.EntityManagerFactory[] per datasource. The javadoc:org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean[] from Spring ORM allows you to configure an javadoc:jakarta.persistence.EntityManagerFactory[] for your needs. -You can also reuse javadoc:org.springframework.boot.autoconfigure.orm.jpa.JpaProperties[] to bind settings for a second javadoc:jakarta.persistence.EntityManagerFactory[]. +You can also reuse javadoc:org.springframework.boot.jpa.autoconfigure.JpaProperties[] to bind settings for a second javadoc:jakarta.persistence.EntityManagerFactory[]. Building upon xref:how-to:data-access.adoc#howto.data-access.configure-two-datasources[the example for configuring a second javadoc:javax.sql.DataSource[]], a second javadoc:jakarta.persistence.EntityManagerFactory[] can be defined as shown in the following example: include-code::MyAdditionalEntityManagerFactoryConfiguration[] @@ -390,7 +390,7 @@ If you want to configure a component that JPA uses, then you need to ensure that When the component is auto-configured, Spring Boot takes care of this for you. For example, when Flyway is auto-configured, Hibernate is configured to depend on Flyway so that Flyway has a chance to initialize the database before Hibernate tries to use it. -If you are configuring a component yourself, you can use an javadoc:org.springframework.boot.autoconfigure.orm.jpa.EntityManagerFactoryDependsOnPostProcessor[] subclass as a convenient way of setting up the necessary dependencies. +If you are configuring a component yourself, you can use an javadoc:org.springframework.boot.jpa.autoconfigure.EntityManagerFactoryDependsOnPostProcessor[] subclass as a convenient way of setting up the necessary dependencies. For example, if you use Hibernate Search with Elasticsearch as its index manager, any javadoc:jakarta.persistence.EntityManagerFactory[] beans must be configured to depend on the `elasticsearchClient` bean, as shown in the following example: include-code::ElasticsearchEntityManagerFactoryDependsOnPostProcessor[] diff --git a/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/data/sql.adoc b/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/data/sql.adoc index 4a1615f10f..8c778e0674 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/data/sql.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/data/sql.adoc @@ -252,7 +252,7 @@ include-code::CityRepository[] Spring Data JPA repositories support three different modes of bootstrapping: default, deferred, and lazy. To enable deferred or lazy bootstrapping, set the configprop:spring.data.jpa.repositories.bootstrap-mode[] property to `deferred` or `lazy` respectively. -When using deferred or lazy bootstrapping, the auto-configured javadoc:org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder[] will use the context's javadoc:org.springframework.core.task.AsyncTaskExecutor[], if any, as the bootstrap executor. +When using deferred or lazy bootstrapping, the auto-configured javadoc:org.springframework.boot.jpa.EntityManagerFactoryBuilder[] will use the context's javadoc:org.springframework.core.task.AsyncTaskExecutor[], if any, as the bootstrap executor. If more than one exists, the one named `applicationTaskExecutor` will be used. [NOTE] diff --git a/spring-boot-project/spring-boot-docs/src/docs/antora/modules/specification/pages/configuration-metadata/format.adoc b/spring-boot-project/spring-boot-docs/src/docs/antora/modules/specification/pages/configuration-metadata/format.adoc index ae560f8990..4b7e96f898 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/antora/modules/specification/pages/configuration-metadata/format.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/antora/modules/specification/pages/configuration-metadata/format.adoc @@ -14,8 +14,8 @@ They use a JSON format with items categorized under either "`groups`" or "`prope }, { "name": "spring.jpa.hibernate", - "type": "org.springframework.boot.autoconfigure.orm.jpa.JpaProperties$Hibernate", - "sourceType": "org.springframework.boot.autoconfigure.orm.jpa.JpaProperties", + "type": "org.springframework.boot.jpa.autoconfigure.JpaProperties$Hibernate", + "sourceType": "org.springframework.boot.jpa.autoconfigure.JpaProperties", "sourceMethod": "getHibernate()" } ... @@ -34,7 +34,7 @@ They use a JSON format with items categorized under either "`groups`" or "`prope "name": "spring.jpa.hibernate.ddl-auto", "type": "java.lang.String", "description": "DDL mode. This is actually a shortcut for the \"hibernate.hbm2ddl.auto\" property.", - "sourceType": "org.springframework.boot.autoconfigure.orm.jpa.JpaProperties$Hibernate" + "sourceType": "org.springframework.boot.jpa.autoconfigure.JpaProperties$Hibernate" } ... ],"hints": [ diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/configureacomponentthatisusedbyjpa/ElasticsearchEntityManagerFactoryDependsOnPostProcessor.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/configureacomponentthatisusedbyjpa/ElasticsearchEntityManagerFactoryDependsOnPostProcessor.java index 6dcc96daab..e185ce18d5 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/configureacomponentthatisusedbyjpa/ElasticsearchEntityManagerFactoryDependsOnPostProcessor.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/configureacomponentthatisusedbyjpa/ElasticsearchEntityManagerFactoryDependsOnPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2025 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. @@ -18,7 +18,7 @@ package org.springframework.boot.docs.howto.dataaccess.configureacomponentthatis import jakarta.persistence.EntityManagerFactory; -import org.springframework.boot.autoconfigure.orm.jpa.EntityManagerFactoryDependsOnPostProcessor; +import org.springframework.boot.jpa.autoconfigure.EntityManagerFactoryDependsOnPostProcessor; import org.springframework.stereotype.Component; /** diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/configurehibernatesecondlevelcaching/MyHibernateSecondLevelCacheConfiguration.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/configurehibernatesecondlevelcaching/MyHibernateSecondLevelCacheConfiguration.java index 476d742c49..c379a2e9e2 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/configurehibernatesecondlevelcaching/MyHibernateSecondLevelCacheConfiguration.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/configurehibernatesecondlevelcaching/MyHibernateSecondLevelCacheConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2025 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. @@ -18,7 +18,7 @@ package org.springframework.boot.docs.howto.dataaccess.configurehibernatesecondl import org.hibernate.cache.jcache.ConfigSettings; -import org.springframework.boot.autoconfigure.orm.jpa.HibernatePropertiesCustomizer; +import org.springframework.boot.jpa.autoconfigure.hibernate.HibernatePropertiesCustomizer; import org.springframework.cache.jcache.JCacheCacheManager; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/MyAdditionalEntityManagerFactoryConfiguration.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/MyAdditionalEntityManagerFactoryConfiguration.java index 76a05743a0..1d1929d80f 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/MyAdditionalEntityManagerFactoryConfiguration.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/MyAdditionalEntityManagerFactoryConfiguration.java @@ -23,9 +23,9 @@ import java.util.function.Function; import javax.sql.DataSource; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; +import org.springframework.boot.jpa.EntityManagerFactoryBuilder; +import org.springframework.boot.jpa.autoconfigure.JpaProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.orm.jpa.JpaVendorAdapter; diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configureacomponentthatisusedbyjpa/ElasticsearchEntityManagerFactoryDependsOnPostProcessor.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configureacomponentthatisusedbyjpa/ElasticsearchEntityManagerFactoryDependsOnPostProcessor.kt index 8a682e2155..28a2b4ed66 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configureacomponentthatisusedbyjpa/ElasticsearchEntityManagerFactoryDependsOnPostProcessor.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configureacomponentthatisusedbyjpa/ElasticsearchEntityManagerFactoryDependsOnPostProcessor.kt @@ -16,7 +16,7 @@ package org.springframework.boot.docs.howto.dataaccess.configureacomponentthatisusedbyjpa -import org.springframework.boot.autoconfigure.orm.jpa.EntityManagerFactoryDependsOnPostProcessor +import org.springframework.boot.jpa.autoconfigure.EntityManagerFactoryDependsOnPostProcessor import org.springframework.stereotype.Component @Component diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurehibernatesecondlevelcaching/MyHibernateSecondLevelCacheConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurehibernatesecondlevelcaching/MyHibernateSecondLevelCacheConfiguration.kt index 391f620943..e27906cad8 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurehibernatesecondlevelcaching/MyHibernateSecondLevelCacheConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/configurehibernatesecondlevelcaching/MyHibernateSecondLevelCacheConfiguration.kt @@ -17,7 +17,7 @@ package org.springframework.boot.docs.howto.dataaccess.configurehibernatesecondlevelcaching import org.hibernate.cache.jcache.ConfigSettings -import org.springframework.boot.autoconfigure.orm.jpa.HibernatePropertiesCustomizer +import org.springframework.boot.jpa.autoconfigure.hibernate.HibernatePropertiesCustomizer import org.springframework.cache.jcache.JCacheCacheManager import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/MyAdditionalEntityManagerFactoryConfiguration.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/MyAdditionalEntityManagerFactoryConfiguration.kt index 196f835651..cce48b2c73 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/MyAdditionalEntityManagerFactoryConfiguration.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/howto/dataaccess/usemultipleentitymanagers/MyAdditionalEntityManagerFactoryConfiguration.kt @@ -17,9 +17,9 @@ package org.springframework.boot.docs.howto.dataaccess.usemultipleentitymanagers import org.springframework.beans.factory.annotation.Qualifier -import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties import org.springframework.boot.context.properties.ConfigurationProperties -import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder +import org.springframework.boot.jpa.EntityManagerFactoryBuilder +import org.springframework.boot.jpa.autoconfigure.JpaProperties import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.orm.jpa.JpaVendorAdapter diff --git a/spring-boot-project/spring-boot-flyway/src/test/java/org/springframework/boot/flyway/autoconfigure/FlywayAutoConfigurationTests.java b/spring-boot-project/spring-boot-flyway/src/test/java/org/springframework/boot/flyway/autoconfigure/FlywayAutoConfigurationTests.java index 82e01d1fc7..79862f0d1f 100644 --- a/spring-boot-project/spring-boot-flyway/src/test/java/org/springframework/boot/flyway/autoconfigure/FlywayAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-flyway/src/test/java/org/springframework/boot/flyway/autoconfigure/FlywayAutoConfigurationTests.java @@ -67,12 +67,10 @@ import org.springframework.boot.flyway.autoconfigure.FlywayAutoConfiguration.Ora import org.springframework.boot.flyway.autoconfigure.FlywayAutoConfiguration.PostgresqlFlywayConfigurationCustomizer; import org.springframework.boot.flyway.autoconfigure.FlywayAutoConfiguration.SqlServerFlywayConfigurationCustomizer; import org.springframework.boot.jdbc.DataSourceBuilder; -import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.boot.jdbc.SchemaManagement; import org.springframework.boot.jdbc.autoconfigure.DataSourceProperties; import org.springframework.boot.jdbc.autoconfigure.EmbeddedDataSourceConfiguration; import org.springframework.boot.jdbc.autoconfigure.JdbcConnectionDetails; -import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; import org.springframework.boot.test.context.FilteredClassLoader; import org.springframework.boot.test.context.assertj.AssertableApplicationContext; import org.springframework.boot.test.context.runner.ApplicationContextRunner; @@ -1065,10 +1063,11 @@ class FlywayAutoConfigurationTests { @Bean LocalContainerEntityManagerFactoryBean entityManagerFactoryBean(DataSource dataSource) { - return new EntityManagerFactoryBuilder(new HibernateJpaVendorAdapter(), (ds) -> configureJpaProperties(), - null) - .dataSource(dataSource) - .build(); + LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); + localContainerEntityManagerFactoryBean.setDataSource(dataSource); + localContainerEntityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); + localContainerEntityManagerFactoryBean.setJpaPropertyMap(configureJpaProperties()); + return localContainerEntityManagerFactoryBean; } } @@ -1089,50 +1088,11 @@ class FlywayAutoConfigurationTests { @Bean LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() { - return new EntityManagerFactoryBuilder(new HibernateJpaVendorAdapter(), - (datasource) -> configureJpaProperties(), null) - .dataSource(this.dataSource) - .build(); - } - - } - - @Configuration(proxyBeanMethods = false) - static class JpaWithMultipleDataSourcesConfiguration { - - @Bean - @Primary - DataSource normalDataSource() { - return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseConnection.HSQLDB.getType()) - .generateUniqueName(true) - .build(); - } - - @Bean - @Primary - LocalContainerEntityManagerFactoryBean normalEntityManagerFactory(EntityManagerFactoryBuilder builder, - DataSource normalDataSource) { - Map properties = new HashMap<>(); - properties.put("configured", "normal"); - properties.put("hibernate.transaction.jta.platform", NoJtaPlatform.INSTANCE); - return builder.dataSource(normalDataSource).properties(properties).build(); - } - - @Bean - @FlywayDataSource - DataSource flywayDataSource() { - return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseConnection.HSQLDB.getType()) - .generateUniqueName(true) - .build(); - } - - @Bean - LocalContainerEntityManagerFactoryBean flywayEntityManagerFactory(EntityManagerFactoryBuilder builder, - @FlywayDataSource DataSource flywayDataSource) { - Map properties = new HashMap<>(); - properties.put("configured", "flyway"); - properties.put("hibernate.transaction.jta.platform", NoJtaPlatform.INSTANCE); - return builder.dataSource(flywayDataSource).properties(properties).build(); + LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); + localContainerEntityManagerFactoryBean.setDataSource(this.dataSource); + localContainerEntityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); + localContainerEntityManagerFactoryBean.setJpaPropertyMap(configureJpaProperties()); + return localContainerEntityManagerFactoryBean; } } diff --git a/spring-boot-project/spring-boot-jpa/build.gradle b/spring-boot-project/spring-boot-jpa/build.gradle new file mode 100644 index 0000000000..01d8ad2f36 --- /dev/null +++ b/spring-boot-project/spring-boot-jpa/build.gradle @@ -0,0 +1,41 @@ +plugins { + id "java-library" + id "org.springframework.boot.auto-configuration" + id "org.springframework.boot.configuration-properties" + id "org.springframework.boot.deployed" + id "org.springframework.boot.optional-dependencies" +} + +description = "Spring Boot JPA" + +dependencies { + api(project(":spring-boot-project:spring-boot-jdbc")) + api(project(":spring-boot-project:spring-boot-tx")) + api("jakarta.persistence:jakarta.persistence-api") + api("org.hibernate.orm:hibernate-core") + api("org.springframework:spring-orm") + + optional(project(":spring-boot-project:spring-boot-autoconfigure")) + optional(project(":spring-boot-project:spring-boot-jdbc")) + optional("jakarta.servlet:jakarta.servlet-api") + optional("org.springframework:spring-webmvc") + + testImplementation(project(":spring-boot-project:spring-boot-flyway")) + testImplementation(project(":spring-boot-project:spring-boot-liquibase")) + testImplementation(project(":spring-boot-project:spring-boot-test")) + testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support")) + testImplementation(testFixtures(project(":spring-boot-project:spring-boot-autoconfigure"))) + testImplementation("com.zaxxer:HikariCP") + testImplementation("javax.cache:cache-api") + testImplementation("org.ehcache:ehcache") { + artifact { + classifier = 'jakarta' + } + } + testImplementation("org.hibernate.orm:hibernate-envers") + testImplementation("org.hibernate.orm:hibernate-jcache") + testImplementation("org.springframework:spring-context-support") + + testRuntimeOnly("ch.qos.logback:logback-classic") + testRuntimeOnly("com.h2database:h2") +} diff --git a/spring-boot-project/spring-boot-all/src/main/java/org/springframework/boot/orm/jpa/EntityManagerFactoryBuilder.java b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/EntityManagerFactoryBuilder.java similarity index 99% rename from spring-boot-project/spring-boot-all/src/main/java/org/springframework/boot/orm/jpa/EntityManagerFactoryBuilder.java rename to spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/EntityManagerFactoryBuilder.java index cf375805b5..103eac4cb6 100644 --- a/spring-boot-project/spring-boot-all/src/main/java/org/springframework/boot/orm/jpa/EntityManagerFactoryBuilder.java +++ b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/EntityManagerFactoryBuilder.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.orm.jpa; +package org.springframework.boot.jpa; import java.net.URL; import java.util.HashMap; @@ -47,7 +47,7 @@ import org.springframework.util.StringUtils; * @author Dave Syer * @author Phillip Webb * @author Stephane Nicoll - * @since 1.3.0 + * @since 4.0.0 */ public class EntityManagerFactoryBuilder { diff --git a/spring-boot-project/spring-boot-all/src/main/java/org/springframework/boot/orm/jpa/JpaDatabaseInitializerDetector.java b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/JpaDatabaseInitializerDetector.java similarity index 96% rename from spring-boot-project/spring-boot-all/src/main/java/org/springframework/boot/orm/jpa/JpaDatabaseInitializerDetector.java rename to spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/JpaDatabaseInitializerDetector.java index 13deb8ef0e..cda31387c6 100644 --- a/spring-boot-project/spring-boot-all/src/main/java/org/springframework/boot/orm/jpa/JpaDatabaseInitializerDetector.java +++ b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/JpaDatabaseInitializerDetector.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2025 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.orm.jpa; +package org.springframework.boot.jpa; import java.util.Collections; import java.util.HashSet; diff --git a/spring-boot-project/spring-boot-all/src/main/java/org/springframework/boot/orm/jpa/JpaDependsOnDatabaseInitializationDetector.java b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/JpaDependsOnDatabaseInitializationDetector.java similarity index 94% rename from spring-boot-project/spring-boot-all/src/main/java/org/springframework/boot/orm/jpa/JpaDependsOnDatabaseInitializationDetector.java rename to spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/JpaDependsOnDatabaseInitializationDetector.java index 27dc8c9c09..91051017eb 100644 --- a/spring-boot-project/spring-boot-all/src/main/java/org/springframework/boot/orm/jpa/JpaDependsOnDatabaseInitializationDetector.java +++ b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/JpaDependsOnDatabaseInitializationDetector.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2025 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.orm.jpa; +package org.springframework.boot.jpa; import java.util.Arrays; import java.util.Collections; diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/EntityManagerFactoryBuilderCustomizer.java b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/EntityManagerFactoryBuilderCustomizer.java similarity index 82% rename from spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/EntityManagerFactoryBuilderCustomizer.java rename to spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/EntityManagerFactoryBuilderCustomizer.java index d4a819f270..572df064e1 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/EntityManagerFactoryBuilderCustomizer.java +++ b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/EntityManagerFactoryBuilderCustomizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2025 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. @@ -14,16 +14,16 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.orm.jpa; +package org.springframework.boot.jpa.autoconfigure; -import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; +import org.springframework.boot.jpa.EntityManagerFactoryBuilder; /** * Callback interface that can be used to customize the auto-configured * {@link EntityManagerFactoryBuilder}. * * @author Andy Wilkinson - * @since 2.1.0 + * @since 4.0.0 */ @FunctionalInterface public interface EntityManagerFactoryBuilderCustomizer { diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/EntityManagerFactoryDependsOnPostProcessor.java b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/EntityManagerFactoryDependsOnPostProcessor.java similarity index 94% rename from spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/EntityManagerFactoryDependsOnPostProcessor.java rename to spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/EntityManagerFactoryDependsOnPostProcessor.java index 971fd6d95d..432dd2bfdd 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/EntityManagerFactoryDependsOnPostProcessor.java +++ b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/EntityManagerFactoryDependsOnPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2025 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.orm.jpa; +package org.springframework.boot.jpa.autoconfigure; import jakarta.persistence.EntityManagerFactory; @@ -32,7 +32,7 @@ import org.springframework.orm.jpa.AbstractEntityManagerFactoryBean; * @author Phillip Webb * @author Andy Wilkinson * @author Andrii Hrytsiuk - * @since 2.5.0 + * @since 4.0.0 * @see BeanDefinition#setDependsOn(String[]) */ public class EntityManagerFactoryDependsOnPostProcessor extends AbstractDependsOnBeanFactoryPostProcessor { diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaBaseConfiguration.java b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/JpaBaseConfiguration.java similarity index 98% rename from spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaBaseConfiguration.java rename to spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/JpaBaseConfiguration.java index 98f2aefeff..8e4ac4ed2e 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaBaseConfiguration.java +++ b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/JpaBaseConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.orm.jpa; +package org.springframework.boot.jpa.autoconfigure; import java.util.HashMap; import java.util.List; @@ -38,7 +38,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplicat import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; import org.springframework.boot.autoconfigure.domain.EntityScanPackages; import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; +import org.springframework.boot.jpa.EntityManagerFactoryBuilder; import org.springframework.boot.transaction.autoconfigure.TransactionManagerCustomizers; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -72,7 +72,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; * @author Kazuki Shimizu * @author Eddú Meléndez * @author Yanming Zhou - * @since 1.0.0 + * @since 4.0.0 */ @Configuration(proxyBeanMethods = false) @EnableConfigurationProperties(JpaProperties.class) diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/JpaProperties.java similarity index 97% rename from spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java rename to spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/JpaProperties.java index 0e8baac795..4373a854aa 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java +++ b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/JpaProperties.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.orm.jpa; +package org.springframework.boot.jpa.autoconfigure; import java.util.ArrayList; import java.util.HashMap; @@ -32,7 +32,7 @@ import org.springframework.orm.jpa.vendor.Database; * @author Stephane Nicoll * @author Eddú Meléndez * @author Madhura Bhave - * @since 1.1.0 + * @since 4.0.0 */ @ConfigurationProperties("spring.jpa") public class JpaProperties { diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateDefaultDdlAutoProvider.java b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/hibernate/HibernateDefaultDdlAutoProvider.java similarity index 94% rename from spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateDefaultDdlAutoProvider.java rename to spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/hibernate/HibernateDefaultDdlAutoProvider.java index aaef06de21..4e85dd7b6e 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateDefaultDdlAutoProvider.java +++ b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/hibernate/HibernateDefaultDdlAutoProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2025 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.orm.jpa; +package org.springframework.boot.jpa.autoconfigure.hibernate; import java.util.stream.StreamSupport; diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.java b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/hibernate/HibernateJpaAutoConfiguration.java similarity index 82% rename from spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.java rename to spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/hibernate/HibernateJpaAutoConfiguration.java index 9841d7dc78..52d80ac3e5 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.java +++ b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/hibernate/HibernateJpaAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2025 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.orm.jpa; +package org.springframework.boot.jpa.autoconfigure.hibernate; import jakarta.persistence.EntityManager; import org.hibernate.engine.spi.SessionImplementor; @@ -25,8 +25,10 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.DataSourceTransactionManagerAutoConfiguration; +import org.springframework.boot.jpa.autoconfigure.JpaProperties; import org.springframework.boot.transaction.autoconfigure.TransactionAutoConfiguration; import org.springframework.boot.transaction.autoconfigure.TransactionManagerCustomizationAutoConfiguration; +import org.springframework.boot.transaction.jta.autoconfigure.JtaAutoConfiguration; import org.springframework.context.annotation.Import; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; @@ -37,11 +39,11 @@ import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; * @author Josh Long * @author Manuel Doninger * @author Andy Wilkinson - * @since 1.0.0 + * @since 4.0.0 */ @AutoConfiguration( - after = { DataSourceAutoConfiguration.class, TransactionManagerCustomizationAutoConfiguration.class }, - afterName = "org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfiguration", + after = { DataSourceAutoConfiguration.class, JtaAutoConfiguration.class, + TransactionManagerCustomizationAutoConfiguration.class }, before = { TransactionAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class }) @ConditionalOnClass({ LocalContainerEntityManagerFactoryBean.class, EntityManager.class, SessionImplementor.class }) @EnableConfigurationProperties(JpaProperties.class) diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.java b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/hibernate/HibernateJpaConfiguration.java similarity index 96% rename from spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.java rename to spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/hibernate/HibernateJpaConfiguration.java index 70a333109a..2723aaee49 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.java +++ b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/hibernate/HibernateJpaConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.orm.jpa; +package org.springframework.boot.jpa.autoconfigure.hibernate; import java.util.ArrayList; import java.util.Arrays; @@ -43,14 +43,16 @@ import org.springframework.aot.hint.TypeReference; import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate; -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration.HibernateRuntimeHints; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.jdbc.SchemaManagementProvider; import org.springframework.boot.jdbc.metadata.CompositeDataSourcePoolMetadataProvider; import org.springframework.boot.jdbc.metadata.DataSourcePoolMetadata; import org.springframework.boot.jdbc.metadata.DataSourcePoolMetadataProvider; -import org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy; -import org.springframework.boot.orm.jpa.hibernate.SpringJtaPlatform; +import org.springframework.boot.jpa.autoconfigure.JpaBaseConfiguration; +import org.springframework.boot.jpa.autoconfigure.JpaProperties; +import org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaConfiguration.HibernateRuntimeHints; +import org.springframework.boot.jpa.hibernate.SpringImplicitNamingStrategy; +import org.springframework.boot.jpa.hibernate.SpringJtaPlatform; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportRuntimeHints; import org.springframework.jdbc.support.SQLExceptionTranslator; diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateProperties.java b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/hibernate/HibernateProperties.java similarity index 96% rename from spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateProperties.java rename to spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/hibernate/HibernateProperties.java index 80bcba515d..c7b02b6943 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateProperties.java +++ b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/hibernate/HibernateProperties.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.orm.jpa; +package org.springframework.boot.jpa.autoconfigure.hibernate; import java.util.Collection; import java.util.HashMap; @@ -27,7 +27,8 @@ import org.hibernate.cfg.PersistenceSettings; import org.hibernate.cfg.SchemaToolingSettings; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy; +import org.springframework.boot.jpa.autoconfigure.JpaProperties; +import org.springframework.boot.jpa.hibernate.SpringImplicitNamingStrategy; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.util.ObjectUtils; @@ -38,7 +39,7 @@ import org.springframework.util.StringUtils; * * @author Stephane Nicoll * @author Chris Bono - * @since 2.1.0 + * @since 4.0.0 * @see JpaProperties */ @ConfigurationProperties("spring.jpa.hibernate") diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernatePropertiesCustomizer.java b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/hibernate/HibernatePropertiesCustomizer.java similarity index 88% rename from spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernatePropertiesCustomizer.java rename to spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/hibernate/HibernatePropertiesCustomizer.java index c350aaf9d0..3441898d99 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernatePropertiesCustomizer.java +++ b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/hibernate/HibernatePropertiesCustomizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2025 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.orm.jpa; +package org.springframework.boot.jpa.autoconfigure.hibernate; import java.util.Map; @@ -23,7 +23,7 @@ import java.util.Map; * properties before it is used by an auto-configured {@code EntityManagerFactory}. * * @author Stephane Nicoll - * @since 2.0.0 + * @since 4.0.0 */ @FunctionalInterface public interface HibernatePropertiesCustomizer { diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateSettings.java b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/hibernate/HibernateSettings.java similarity index 91% rename from spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateSettings.java rename to spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/hibernate/HibernateSettings.java index d4e37e8822..85d85d7073 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateSettings.java +++ b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/hibernate/HibernateSettings.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2025 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.orm.jpa; +package org.springframework.boot.jpa.autoconfigure.hibernate; import java.util.ArrayList; import java.util.Collection; @@ -24,7 +24,7 @@ import java.util.function.Supplier; * Settings to apply when configuring Hibernate. * * @author Andy Wilkinson - * @since 2.0.0 + * @since 4.0.0 */ public class HibernateSettings { diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/package-info.java b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/hibernate/package-info.java similarity index 91% rename from spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/package-info.java rename to spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/hibernate/package-info.java index 3c589cfac2..7842715795 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/package-info.java +++ b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/hibernate/package-info.java @@ -17,4 +17,4 @@ /** * Auto-configuration for JPA and Spring ORM. */ -package org.springframework.boot.autoconfigure.orm.jpa; +package org.springframework.boot.jpa.autoconfigure.hibernate; diff --git a/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/package-info.java b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/package-info.java new file mode 100644 index 0000000000..1442ab3729 --- /dev/null +++ b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/autoconfigure/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2025 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Base Auto-configuration for JPA and Spring ORM. + */ +package org.springframework.boot.jpa.autoconfigure; diff --git a/spring-boot-project/spring-boot-all/src/main/java/org/springframework/boot/orm/jpa/hibernate/SpringImplicitNamingStrategy.java b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/hibernate/SpringImplicitNamingStrategy.java similarity index 92% rename from spring-boot-project/spring-boot-all/src/main/java/org/springframework/boot/orm/jpa/hibernate/SpringImplicitNamingStrategy.java rename to spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/hibernate/SpringImplicitNamingStrategy.java index 0279393824..39970bcc93 100644 --- a/spring-boot-project/spring-boot-all/src/main/java/org/springframework/boot/orm/jpa/hibernate/SpringImplicitNamingStrategy.java +++ b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/hibernate/SpringImplicitNamingStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2025 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.orm.jpa.hibernate; +package org.springframework.boot.jpa.hibernate; import org.hibernate.boot.model.naming.Identifier; import org.hibernate.boot.model.naming.ImplicitJoinTableNameSource; @@ -29,7 +29,7 @@ import org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl; * {owning_physical_table_name}_{association_owning_property_name}. * * @author Andy Wilkinson - * @since 1.4.0 + * @since 4.0.0 */ public class SpringImplicitNamingStrategy extends ImplicitNamingStrategyJpaCompliantImpl { diff --git a/spring-boot-project/spring-boot-all/src/main/java/org/springframework/boot/orm/jpa/hibernate/SpringJtaPlatform.java b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/hibernate/SpringJtaPlatform.java similarity index 96% rename from spring-boot-project/spring-boot-all/src/main/java/org/springframework/boot/orm/jpa/hibernate/SpringJtaPlatform.java rename to spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/hibernate/SpringJtaPlatform.java index 408ff160cd..e2d2a12d9e 100644 --- a/spring-boot-project/spring-boot-all/src/main/java/org/springframework/boot/orm/jpa/hibernate/SpringJtaPlatform.java +++ b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/hibernate/SpringJtaPlatform.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.orm.jpa.hibernate; +package org.springframework.boot.jpa.hibernate; import jakarta.transaction.TransactionManager; import jakarta.transaction.UserTransaction; @@ -30,7 +30,7 @@ import org.springframework.util.Assert; * * @author Josh Long * @author Phillip Webb - * @since 1.2.0 + * @since 4.0.0 */ public class SpringJtaPlatform extends AbstractJtaPlatform { diff --git a/spring-boot-project/spring-boot-all/src/main/java/org/springframework/boot/orm/jpa/hibernate/package-info.java b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/hibernate/package-info.java similarity index 92% rename from spring-boot-project/spring-boot-all/src/main/java/org/springframework/boot/orm/jpa/hibernate/package-info.java rename to spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/hibernate/package-info.java index a68d15b20e..24d2a53dd7 100644 --- a/spring-boot-project/spring-boot-all/src/main/java/org/springframework/boot/orm/jpa/hibernate/package-info.java +++ b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/hibernate/package-info.java @@ -17,4 +17,4 @@ /** * Hibernate Support classes. */ -package org.springframework.boot.orm.jpa.hibernate; +package org.springframework.boot.jpa.hibernate; diff --git a/spring-boot-project/spring-boot-all/src/main/java/org/springframework/boot/orm/jpa/package-info.java b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/package-info.java similarity index 86% rename from spring-boot-project/spring-boot-all/src/main/java/org/springframework/boot/orm/jpa/package-info.java rename to spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/package-info.java index 22a275c61f..36026d0846 100644 --- a/spring-boot-project/spring-boot-all/src/main/java/org/springframework/boot/orm/jpa/package-info.java +++ b/spring-boot-project/spring-boot-jpa/src/main/java/org/springframework/boot/jpa/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2025 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. @@ -17,4 +17,4 @@ /** * JPA Support classes. */ -package org.springframework.boot.orm.jpa; +package org.springframework.boot.jpa; diff --git a/spring-boot-project/spring-boot-jpa/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot-jpa/src/main/resources/META-INF/additional-spring-configuration-metadata.json new file mode 100644 index 0000000000..4f07557547 --- /dev/null +++ b/spring-boot-project/spring-boot-jpa/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -0,0 +1,79 @@ +{ + "groups": [], + "properties": [ + { + "name": "spring.jpa.hibernate.use-new-id-generator-mappings", + "type": "java.lang.Boolean", + "description": "Whether to use Hibernate's newer IdentifierGenerator for AUTO, TABLE and SEQUENCE. This is actually a shortcut for the \"hibernate.id.new_generator_mappings\" property. When not specified will default to \"true\".", + "deprecation": { + "level": "error", + "reason": "Hibernate no longer supports disabling the use of new ID generator mappings." + } + }, + { + "name": "spring.jpa.open-in-view", + "defaultValue": true + } + ], + "hints": [ + { + "name": "spring.jpa.hibernate.ddl-auto", + "values": [ + { + "value": "create", + "description": "Create the schema and destroy previous data." + }, + { + "value": "create-drop", + "description": "Create and then destroy the schema at the end of the session." + }, + { + "value": "create-only", + "description": "Create the schema." + }, + { + "value": "drop", + "description": "Drop the schema." + }, + { + "value": "none", + "description": "Disable DDL handling." + }, + { + "value": "truncate", + "description": "Truncate the tables in the schema." + }, + { + "value": "update", + "description": "Update the schema if necessary." + }, + { + "value": "validate", + "description": "Validate the schema, make no changes to the database." + } + ] + }, + { + "name": "spring.jpa.hibernate.naming.implicit-strategy", + "providers": [ + { + "name": "class-reference", + "parameters": { + "target": "org.hibernate.boot.model.naming.ImplicitNamingStrategy" + } + } + ] + }, + { + "name": "spring.jpa.hibernate.naming.physical-strategy", + "providers": [ + { + "name": "class-reference", + "parameters": { + "target": "org.hibernate.boot.model.naming.PhysicalNamingStrategy" + } + } + ] + } + ] +} diff --git a/spring-boot-project/spring-boot-jpa/src/main/resources/META-INF/spring.factories b/spring-boot-project/spring-boot-jpa/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000000..6437bb94c7 --- /dev/null +++ b/spring-boot-project/spring-boot-jpa/src/main/resources/META-INF/spring.factories @@ -0,0 +1,7 @@ +# Database Initializer Detectors +org.springframework.boot.sql.init.dependency.DatabaseInitializerDetector=\ +org.springframework.boot.jpa.JpaDatabaseInitializerDetector + +# Depends On Database Initialization Detectors +org.springframework.boot.sql.init.dependency.DependsOnDatabaseInitializationDetector=\ +org.springframework.boot.jpa.JpaDependsOnDatabaseInitializationDetector diff --git a/spring-boot-project/spring-boot-jpa/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/spring-boot-project/spring-boot-jpa/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000000..20bdc0cab9 --- /dev/null +++ b/spring-boot-project/spring-boot-jpa/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/AbstractJpaAutoConfigurationTests.java b/spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/AbstractJpaAutoConfigurationTests.java similarity index 97% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/AbstractJpaAutoConfigurationTests.java rename to spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/AbstractJpaAutoConfigurationTests.java index c33a012f7a..95dacc2f51 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/AbstractJpaAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/AbstractJpaAutoConfigurationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.orm.jpa; +package org.springframework.boot.jpa.autoconfigure; import java.io.File; import java.lang.annotation.ElementType; @@ -37,13 +37,13 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage; -import org.springframework.boot.autoconfigure.data.jpa.country.Country; -import org.springframework.boot.autoconfigure.orm.jpa.test.City; import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.DataSourceInitializationAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.DataSourceTransactionManagerAutoConfiguration; -import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; +import org.springframework.boot.jpa.EntityManagerFactoryBuilder; +import org.springframework.boot.jpa.autoconfigure.test.city.City; +import org.springframework.boot.jpa.autoconfigure.test.country.Country; import org.springframework.boot.test.context.assertj.AssertableApplicationContext; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.test.context.runner.ContextConsumer; @@ -78,7 +78,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Stephane Nicoll * @author Yanming Zhou */ -abstract class AbstractJpaAutoConfigurationTests { +public abstract class AbstractJpaAutoConfigurationTests { private final Class autoConfiguredClass; @@ -318,7 +318,7 @@ abstract class AbstractJpaAutoConfigurationTests { } @Configuration(proxyBeanMethods = false) - static class TestTwoDataSourcesConfiguration { + protected static class TestTwoDataSourcesConfiguration { @Bean DataSource firstDataSource() { @@ -360,7 +360,7 @@ abstract class AbstractJpaAutoConfigurationTests { @Configuration(proxyBeanMethods = false) @TestAutoConfigurationPackage(City.class) - static class TestConfiguration { + protected static class TestConfiguration { } @@ -516,12 +516,12 @@ abstract class AbstractJpaAutoConfigurationTests { - org.springframework.boot.autoconfigure.orm.jpa.test.City + org.springframework.boot.jpa.autoconfigure.test.city.City true """) - @interface WithMetaInfPersistenceXmlResource { + protected @interface WithMetaInfPersistenceXmlResource { } diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/CustomHibernateJpaAutoConfigurationTests.java b/spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/hibernate/CustomHibernateJpaAutoConfigurationTests.java similarity index 96% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/CustomHibernateJpaAutoConfigurationTests.java rename to spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/hibernate/CustomHibernateJpaAutoConfigurationTests.java index 8761d4e169..26e1bb3f26 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/CustomHibernateJpaAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/hibernate/CustomHibernateJpaAutoConfigurationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.orm.jpa; +package org.springframework.boot.jpa.autoconfigure.hibernate; import java.sql.Connection; import java.sql.DatabaseMetaData; @@ -31,8 +31,9 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage; -import org.springframework.boot.autoconfigure.orm.jpa.test.City; import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; +import org.springframework.boot.jpa.autoconfigure.JpaProperties; +import org.springframework.boot.jpa.autoconfigure.test.city.City; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/Hibernate2ndLevelCacheIntegrationTests.java b/spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/hibernate/Hibernate2ndLevelCacheIntegrationTests.java similarity index 75% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/Hibernate2ndLevelCacheIntegrationTests.java rename to spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/hibernate/Hibernate2ndLevelCacheIntegrationTests.java index aa10c26028..522410dbdd 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/Hibernate2ndLevelCacheIntegrationTests.java +++ b/spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/hibernate/Hibernate2ndLevelCacheIntegrationTests.java @@ -14,16 +14,20 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.orm.jpa; +package org.springframework.boot.jpa.autoconfigure.hibernate; + +import javax.cache.CacheManager; +import javax.cache.Caching; import org.ehcache.jsr107.EhcacheCachingProvider; import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.cache.annotation.EnableCaching; +import org.springframework.cache.jcache.JCacheCacheManager; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import static org.assertj.core.api.Assertions.assertThat; @@ -36,8 +40,8 @@ import static org.assertj.core.api.Assertions.assertThat; class Hibernate2ndLevelCacheIntegrationTests { private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(CacheAutoConfiguration.class, DataSourceAutoConfiguration.class, - HibernateJpaAutoConfiguration.class)) + .withConfiguration( + AutoConfigurations.of(DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class)) .withUserConfiguration(TestConfiguration.class); @Test @@ -54,6 +58,16 @@ class Hibernate2ndLevelCacheIntegrationTests { @EnableCaching static class TestConfiguration { + @Bean + CacheManager cacheManager() { + return Caching.getCachingProvider(EhcacheCachingProvider.class.getName()).getCacheManager(); + } + + @Bean + JCacheCacheManager jcacheCacheManager(CacheManager cacheManager) { + return new JCacheCacheManager(cacheManager); + } + } } diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateDefaultDdlAutoProviderTests.java b/spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/hibernate/HibernateDefaultDdlAutoProviderTests.java similarity index 96% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateDefaultDdlAutoProviderTests.java rename to spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/hibernate/HibernateDefaultDdlAutoProviderTests.java index 1add3d1a97..8f59764fa4 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateDefaultDdlAutoProviderTests.java +++ b/spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/hibernate/HibernateDefaultDdlAutoProviderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2025 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.orm.jpa; +package org.springframework.boot.jpa.autoconfigure.hibernate; import java.util.Collections; diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfigurationTests.java b/spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/hibernate/HibernateJpaAutoConfigurationTests.java similarity index 97% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfigurationTests.java rename to spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/hibernate/HibernateJpaAutoConfigurationTests.java index 0c23e78849..c202363f52 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/hibernate/HibernateJpaAutoConfigurationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.orm.jpa; +package org.springframework.boot.jpa.autoconfigure.hibernate; import java.io.IOException; import java.net.URL; @@ -58,16 +58,18 @@ import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage; -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfigurationTests.JpaUsingApplicationListenerConfiguration.EventCapturingApplicationListener; -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration.HibernateRuntimeHints; -import org.springframework.boot.autoconfigure.orm.jpa.mapping.NonAnnotatedEntity; -import org.springframework.boot.autoconfigure.orm.jpa.test.City; import org.springframework.boot.flyway.autoconfigure.FlywayAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.DataSourceTransactionManagerAutoConfiguration; import org.springframework.boot.jdbc.autoconfigure.XADataSourceAutoConfiguration; +import org.springframework.boot.jpa.autoconfigure.AbstractJpaAutoConfigurationTests; +import org.springframework.boot.jpa.autoconfigure.EntityManagerFactoryBuilderCustomizer; +import org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfigurationTests.JpaUsingApplicationListenerConfiguration.EventCapturingApplicationListener; +import org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaConfiguration.HibernateRuntimeHints; +import org.springframework.boot.jpa.autoconfigure.hibernate.mapping.NonAnnotatedEntity; +import org.springframework.boot.jpa.autoconfigure.test.city.City; +import org.springframework.boot.jpa.hibernate.SpringImplicitNamingStrategy; +import org.springframework.boot.jpa.hibernate.SpringJtaPlatform; import org.springframework.boot.liquibase.autoconfigure.LiquibaseAutoConfiguration; -import org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy; -import org.springframework.boot.orm.jpa.hibernate.SpringJtaPlatform; import org.springframework.boot.sql.init.dependency.DependsOnDatabaseInitialization; import org.springframework.boot.test.context.assertj.AssertableApplicationContext; import org.springframework.boot.test.context.runner.ContextConsumer; @@ -388,7 +390,7 @@ class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigurationTes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence/orm https://www.oracle.com/webfolder/technetwork/jsc/xml/ns/persistence/orm_2_1.xsd" version="2.1"> - + diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernatePropertiesTests.java b/spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/hibernate/HibernatePropertiesTests.java similarity index 97% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernatePropertiesTests.java rename to spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/hibernate/HibernatePropertiesTests.java index b2481c3c98..25f6556f09 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernatePropertiesTests.java +++ b/spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/hibernate/HibernatePropertiesTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.orm.jpa; +package org.springframework.boot.jpa.autoconfigure.hibernate; import java.util.Map; import java.util.function.Consumer; @@ -30,7 +30,8 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy; +import org.springframework.boot.jpa.autoconfigure.JpaProperties; +import org.springframework.boot.jpa.hibernate.SpringImplicitNamingStrategy; import org.springframework.boot.test.context.assertj.AssertableApplicationContext; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.test.context.runner.ContextConsumer; diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/mapping/NonAnnotatedEntity.java b/spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/hibernate/mapping/NonAnnotatedEntity.java similarity index 89% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/mapping/NonAnnotatedEntity.java rename to spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/hibernate/mapping/NonAnnotatedEntity.java index b9f41c8935..d85debbb50 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/mapping/NonAnnotatedEntity.java +++ b/spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/hibernate/mapping/NonAnnotatedEntity.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * Copyright 2012-2025 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.orm.jpa.mapping; +package org.springframework.boot.jpa.autoconfigure.hibernate.mapping; /** * A non annotated entity that is handled by a custom "mapping-file". diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/test/City.java b/spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/test/city/City.java similarity index 93% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/test/City.java rename to spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/test/city/City.java index b671c5321a..34d12d3bcb 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/test/City.java +++ b/spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/test/city/City.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2025 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.orm.jpa.test; +package org.springframework.boot.jpa.autoconfigure.test.city; import java.io.Serializable; diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/test/CityListener.java b/spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/test/city/CityListener.java similarity index 90% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/test/CityListener.java rename to spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/test/city/CityListener.java index 017bccb509..74e953a3fc 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/test/CityListener.java +++ b/spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/test/city/CityListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2025 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.orm.jpa.test; +package org.springframework.boot.jpa.autoconfigure.test.city; import jakarta.persistence.PostLoad; diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/domain/country/Country.java b/spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/test/country/Country.java similarity index 90% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/domain/country/Country.java rename to spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/test/country/Country.java index b9991b734f..1661d30553 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/domain/country/Country.java +++ b/spring-boot-project/spring-boot-jpa/src/test/java/org/springframework/boot/jpa/autoconfigure/test/country/Country.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * Copyright 2012-2025 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.orm.jpa.domain.country; +package org.springframework.boot.jpa.autoconfigure.test.country; import java.io.Serializable; diff --git a/spring-boot-project/spring-boot-starters/spring-boot-starter-data-jpa/build.gradle b/spring-boot-project/spring-boot-starters/spring-boot-starter-data-jpa/build.gradle index 0e384b7932..ce3ca6d169 100644 --- a/spring-boot-project/spring-boot-starters/spring-boot-starter-data-jpa/build.gradle +++ b/spring-boot-project/spring-boot-starters/spring-boot-starter-data-jpa/build.gradle @@ -5,9 +5,9 @@ plugins { description = "Starter for using Spring Data JPA with Hibernate" dependencies { + api(project(":spring-boot-project:spring-boot-jpa")) api(project(":spring-boot-project:spring-boot-starters:spring-boot-starter")) api(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-jdbc")) - api("org.hibernate.orm:hibernate-core") api("org.springframework.data:spring-data-jpa") api("org.springframework:spring-aspects") } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/build.gradle b/spring-boot-project/spring-boot-test-autoconfigure/build.gradle index 65a2d80212..14253f2279 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/build.gradle +++ b/spring-boot-project/spring-boot-test-autoconfigure/build.gradle @@ -41,6 +41,7 @@ dependencies { optional(project(":spring-boot-project:spring-boot-groovy-templates")) optional(project(":spring-boot-project:spring-boot-jackson")) optional(project(":spring-boot-project:spring-boot-jdbc")) + optional(project(":spring-boot-project:spring-boot-jpa")) optional(project(":spring-boot-project:spring-boot-jsonb")) optional(project(":spring-boot-project:spring-boot-liquibase")) { exclude(group: "org.liquibase") diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestEntityManagerAutoConfiguration.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestEntityManagerAutoConfiguration.java index ed0349ecc0..4041ac6dd9 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestEntityManagerAutoConfiguration.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestEntityManagerAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * Copyright 2012-2025 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. @@ -21,7 +21,6 @@ import jakarta.persistence.EntityManagerFactory; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.context.annotation.Bean; /** @@ -31,7 +30,7 @@ import org.springframework.context.annotation.Bean; * @since 1.4.0 * @see AutoConfigureTestEntityManager */ -@AutoConfiguration(after = HibernateJpaAutoConfiguration.class) +@AutoConfiguration(afterName = "org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration") @ConditionalOnClass({ EntityManagerFactory.class }) public class TestEntityManagerAutoConfiguration { diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureDataJpa.imports b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureDataJpa.imports index f8d12d54c4..2e70e2e41f 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureDataJpa.imports +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureDataJpa.imports @@ -1,6 +1,6 @@ # AutoConfigureDataJpa auto-configuration imports org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration -org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration +org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration org.springframework.boot.jdbc.autoconfigure.DataSourceInitializationAutoConfiguration org.springframework.boot.jdbc.autoconfigure.DataSourceTransactionManagerAutoConfiguration diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jpa/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jpa/build.gradle index 4b6332a3f8..e14b5aa0fe 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jpa/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jpa/build.gradle @@ -8,10 +8,8 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-freemarker")) implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-web")) implementation(project(":spring-boot-project:spring-boot-jdbc")) - implementation("jakarta.persistence:jakarta.persistence-api") + implementation(project(":spring-boot-project:spring-boot-jpa")) implementation("jakarta.xml.bind:jakarta.xml.bind-api") - implementation("org.hibernate.orm:hibernate-core") - implementation("org.springframework:spring-orm") runtimeOnly("com.h2database:h2") runtimeOnly("jakarta.transaction:jakarta.transaction-api")