Upgrade to Hibernate 7.0.0.Beta3 and Jakarta Persistence 3.2.0

Closes gh-45476
Closes gh-45477
This commit is contained in:
Stéphane Nicoll 2025-05-07 11:16:22 -07:00 committed by Phillip Webb
parent baefbc1aff
commit 3881a79383
8 changed files with 27 additions and 32 deletions

View File

@ -29,9 +29,9 @@ import javax.sql.DataSource;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy;
import org.hibernate.boot.model.naming.ImplicitNamingStrategy; import org.hibernate.boot.model.naming.ImplicitNamingStrategy;
import org.hibernate.boot.model.naming.PhysicalNamingStrategy; import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
import org.hibernate.boot.model.naming.PhysicalNamingStrategySnakeCaseImpl;
import org.hibernate.cfg.ManagedBeanSettings; import org.hibernate.cfg.ManagedBeanSettings;
import org.springframework.aot.hint.MemberCategory; import org.springframework.aot.hint.MemberCategory;
@ -268,7 +268,7 @@ class HibernateJpaConfiguration extends JpaBaseConfiguration {
hints.reflection().registerType(TypeReference.of(noJtaPlatformClass), INVOKE_DECLARED_CONSTRUCTORS); hints.reflection().registerType(TypeReference.of(noJtaPlatformClass), INVOKE_DECLARED_CONSTRUCTORS);
} }
hints.reflection().registerType(SpringImplicitNamingStrategy.class, INVOKE_DECLARED_CONSTRUCTORS); hints.reflection().registerType(SpringImplicitNamingStrategy.class, INVOKE_DECLARED_CONSTRUCTORS);
hints.reflection().registerType(CamelCaseToUnderscoresNamingStrategy.class, INVOKE_DECLARED_CONSTRUCTORS); hints.reflection().registerType(PhysicalNamingStrategySnakeCaseImpl.class, INVOKE_DECLARED_CONSTRUCTORS);
} }
} }

View File

@ -21,7 +21,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.function.Supplier; import java.util.function.Supplier;
import org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy; import org.hibernate.boot.model.naming.PhysicalNamingStrategySnakeCaseImpl;
import org.hibernate.cfg.MappingSettings; import org.hibernate.cfg.MappingSettings;
import org.hibernate.cfg.PersistenceSettings; import org.hibernate.cfg.PersistenceSettings;
import org.hibernate.cfg.SchemaToolingSettings; import org.hibernate.cfg.SchemaToolingSettings;
@ -152,7 +152,7 @@ public class HibernateProperties {
applyNamingStrategy(properties, MappingSettings.IMPLICIT_NAMING_STRATEGY, this.implicitStrategy, applyNamingStrategy(properties, MappingSettings.IMPLICIT_NAMING_STRATEGY, this.implicitStrategy,
SpringImplicitNamingStrategy.class::getName); SpringImplicitNamingStrategy.class::getName);
applyNamingStrategy(properties, MappingSettings.PHYSICAL_NAMING_STRATEGY, this.physicalStrategy, applyNamingStrategy(properties, MappingSettings.PHYSICAL_NAMING_STRATEGY, this.physicalStrategy,
CamelCaseToUnderscoresNamingStrategy.class::getName); PhysicalNamingStrategySnakeCaseImpl.class::getName);
} }
private void applyNamingStrategy(Map<String, Object> properties, String key, Object strategy, private void applyNamingStrategy(Map<String, Object> properties, String key, Object strategy,

View File

@ -37,9 +37,9 @@ import jakarta.transaction.Synchronization;
import jakarta.transaction.Transaction; import jakarta.transaction.Transaction;
import jakarta.transaction.TransactionManager; import jakarta.transaction.TransactionManager;
import jakarta.transaction.UserTransaction; import jakarta.transaction.UserTransaction;
import org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy;
import org.hibernate.boot.model.naming.ImplicitNamingStrategy; import org.hibernate.boot.model.naming.ImplicitNamingStrategy;
import org.hibernate.boot.model.naming.PhysicalNamingStrategy; import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
import org.hibernate.boot.model.naming.PhysicalNamingStrategySnakeCaseImpl;
import org.hibernate.cfg.ManagedBeanSettings; import org.hibernate.cfg.ManagedBeanSettings;
import org.hibernate.cfg.SchemaToolingSettings; import org.hibernate.cfg.SchemaToolingSettings;
import org.hibernate.dialect.H2Dialect; import org.hibernate.dialect.H2Dialect;
@ -617,7 +617,7 @@ class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigurationTes
RuntimeHints hints = new RuntimeHints(); RuntimeHints hints = new RuntimeHints();
new HibernateRuntimeHints().registerHints(hints, getClass().getClassLoader()); new HibernateRuntimeHints().registerHints(hints, getClass().getClassLoader());
for (Class<?> noJtaPlatformClass : Arrays.asList(SpringImplicitNamingStrategy.class, for (Class<?> noJtaPlatformClass : Arrays.asList(SpringImplicitNamingStrategy.class,
CamelCaseToUnderscoresNamingStrategy.class)) { PhysicalNamingStrategySnakeCaseImpl.class)) {
assertThat(RuntimeHintsPredicates.reflection() assertThat(RuntimeHintsPredicates.reflection()
.onType(noJtaPlatformClass) .onType(noJtaPlatformClass)
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(hints); .withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(hints);
@ -737,7 +737,7 @@ class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigurationTes
@Bean @Bean
PhysicalNamingStrategy testPhysicalNamingStrategy() { PhysicalNamingStrategy testPhysicalNamingStrategy() {
return new CamelCaseToUnderscoresNamingStrategy(); return new PhysicalNamingStrategySnakeCaseImpl();
} }
} }
@ -745,7 +745,7 @@ class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigurationTes
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
static class TestHibernatePropertiesCustomizerConfiguration { static class TestHibernatePropertiesCustomizerConfiguration {
private final PhysicalNamingStrategy physicalNamingStrategy = new CamelCaseToUnderscoresNamingStrategy(); private final PhysicalNamingStrategy physicalNamingStrategy = new PhysicalNamingStrategySnakeCaseImpl();
private final ImplicitNamingStrategy implicitNamingStrategy = new SpringImplicitNamingStrategy(); private final ImplicitNamingStrategy implicitNamingStrategy = new SpringImplicitNamingStrategy();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2024 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,7 +20,7 @@ import java.util.Map;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Supplier; import java.util.function.Supplier;
import org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy; import org.hibernate.boot.model.naming.PhysicalNamingStrategySnakeCaseImpl;
import org.hibernate.cfg.MappingSettings; import org.hibernate.cfg.MappingSettings;
import org.hibernate.cfg.PersistenceSettings; import org.hibernate.cfg.PersistenceSettings;
import org.hibernate.cfg.SchemaToolingSettings; import org.hibernate.cfg.SchemaToolingSettings;
@ -62,7 +62,7 @@ class HibernatePropertiesTests {
this.contextRunner.run(assertHibernateProperties((hibernateProperties) -> { this.contextRunner.run(assertHibernateProperties((hibernateProperties) -> {
assertThat(hibernateProperties).doesNotContainKeys("hibernate.ejb.naming_strategy"); assertThat(hibernateProperties).doesNotContainKeys("hibernate.ejb.naming_strategy");
assertThat(hibernateProperties).containsEntry(MappingSettings.PHYSICAL_NAMING_STRATEGY, assertThat(hibernateProperties).containsEntry(MappingSettings.PHYSICAL_NAMING_STRATEGY,
CamelCaseToUnderscoresNamingStrategy.class.getName()); PhysicalNamingStrategySnakeCaseImpl.class.getName());
assertThat(hibernateProperties).containsEntry(MappingSettings.IMPLICIT_NAMING_STRATEGY, assertThat(hibernateProperties).containsEntry(MappingSettings.IMPLICIT_NAMING_STRATEGY,
SpringImplicitNamingStrategy.class.getName()); SpringImplicitNamingStrategy.class.getName());
})); }));

View File

@ -534,11 +534,7 @@ bom {
releaseNotes("https://github.com/hazelcast/hazelcast/releases/tag/v{version}") releaseNotes("https://github.com/hazelcast/hazelcast/releases/tag/v{version}")
} }
} }
library("Hibernate", "6.6.13.Final") { library("Hibernate", "7.0.0.Beta3") {
prohibit {
versionRange "[7.0.0.Alpha1,)"
because "it exceeds our Jakarta EE 10 baseline"
}
group("org.hibernate.orm") { group("org.hibernate.orm") {
modules = [ modules = [
"hibernate-agroal", "hibernate-agroal",
@ -794,11 +790,7 @@ bom {
] ]
} }
} }
library("Jakarta Persistence", "3.1.0") { library("Jakarta Persistence", "3.2.0") {
prohibit {
versionRange "[3.2.0-B01,)"
because "it exceeds our Jakarta EE 10 baseline"
}
group("jakarta.persistence") { group("jakarta.persistence") {
modules = [ modules = [
"jakarta.persistence-api" "jakarta.persistence-api"

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,8 @@
package org.springframework.boot.docs.howto.dataaccess.configurehibernatenamingstrategy.spring; package org.springframework.boot.docs.howto.dataaccess.configurehibernatenamingstrategy.spring;
import org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy; import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.naming.PhysicalNamingStrategySnakeCaseImpl;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment; import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -26,12 +27,12 @@ import org.springframework.context.annotation.Configuration;
public class MyHibernateConfiguration { public class MyHibernateConfiguration {
@Bean @Bean
public CamelCaseToUnderscoresNamingStrategy caseSensitivePhysicalNamingStrategy() { public PhysicalNamingStrategySnakeCaseImpl caseSensitivePhysicalNamingStrategy() {
return new CamelCaseToUnderscoresNamingStrategy() { return new PhysicalNamingStrategySnakeCaseImpl() {
@Override @Override
protected boolean isCaseInsensitive(JdbcEnvironment jdbcEnvironment) { public Identifier toPhysicalColumnName(Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
return false; return logicalName;
} }
}; };

View File

@ -16,7 +16,8 @@
package org.springframework.boot.docs.howto.dataaccess.configurehibernatenamingstrategy.spring package org.springframework.boot.docs.howto.dataaccess.configurehibernatenamingstrategy.spring
import org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy import org.hibernate.boot.model.naming.Identifier
import org.hibernate.boot.model.naming.PhysicalNamingStrategySnakeCaseImpl
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment
import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Configuration
@ -25,10 +26,10 @@ import org.springframework.context.annotation.Configuration
class MyHibernateConfiguration { class MyHibernateConfiguration {
@Bean @Bean
fun caseSensitivePhysicalNamingStrategy(): CamelCaseToUnderscoresNamingStrategy { fun caseSensitivePhysicalNamingStrategy(): PhysicalNamingStrategySnakeCaseImpl {
return object : CamelCaseToUnderscoresNamingStrategy() { return object : PhysicalNamingStrategySnakeCaseImpl() {
override fun isCaseInsensitive(jdbcEnvironment: JdbcEnvironment): Boolean { override fun toPhysicalColumnName(logicalName: Identifier, jdbcEnvironment: JdbcEnvironment): Identifier {
return false return logicalName
} }
} }
} }

View File

@ -54,6 +54,7 @@ public class Review implements Serializable {
@Column(nullable = false) @Column(nullable = false)
@Temporal(TemporalType.DATE) @Temporal(TemporalType.DATE)
@SuppressWarnings("deprecation")
private Date checkInDate; private Date checkInDate;
@Column(nullable = false) @Column(nullable = false)