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.LogFactory;
import org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy;
import org.hibernate.boot.model.naming.ImplicitNamingStrategy;
import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
import org.hibernate.boot.model.naming.PhysicalNamingStrategySnakeCaseImpl;
import org.hibernate.cfg.ManagedBeanSettings;
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(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.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.PersistenceSettings;
import org.hibernate.cfg.SchemaToolingSettings;
@ -152,7 +152,7 @@ public class HibernateProperties {
applyNamingStrategy(properties, MappingSettings.IMPLICIT_NAMING_STRATEGY, this.implicitStrategy,
SpringImplicitNamingStrategy.class::getName);
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,

View File

@ -37,9 +37,9 @@ import jakarta.transaction.Synchronization;
import jakarta.transaction.Transaction;
import jakarta.transaction.TransactionManager;
import jakarta.transaction.UserTransaction;
import org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy;
import org.hibernate.boot.model.naming.ImplicitNamingStrategy;
import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
import org.hibernate.boot.model.naming.PhysicalNamingStrategySnakeCaseImpl;
import org.hibernate.cfg.ManagedBeanSettings;
import org.hibernate.cfg.SchemaToolingSettings;
import org.hibernate.dialect.H2Dialect;
@ -617,7 +617,7 @@ class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigurationTes
RuntimeHints hints = new RuntimeHints();
new HibernateRuntimeHints().registerHints(hints, getClass().getClassLoader());
for (Class<?> noJtaPlatformClass : Arrays.asList(SpringImplicitNamingStrategy.class,
CamelCaseToUnderscoresNamingStrategy.class)) {
PhysicalNamingStrategySnakeCaseImpl.class)) {
assertThat(RuntimeHintsPredicates.reflection()
.onType(noJtaPlatformClass)
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(hints);
@ -737,7 +737,7 @@ class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigurationTes
@Bean
PhysicalNamingStrategy testPhysicalNamingStrategy() {
return new CamelCaseToUnderscoresNamingStrategy();
return new PhysicalNamingStrategySnakeCaseImpl();
}
}
@ -745,7 +745,7 @@ class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigurationTes
@Configuration(proxyBeanMethods = false)
static class TestHibernatePropertiesCustomizerConfiguration {
private final PhysicalNamingStrategy physicalNamingStrategy = new CamelCaseToUnderscoresNamingStrategy();
private final PhysicalNamingStrategy physicalNamingStrategy = new PhysicalNamingStrategySnakeCaseImpl();
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");
* 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.Supplier;
import org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy;
import org.hibernate.boot.model.naming.PhysicalNamingStrategySnakeCaseImpl;
import org.hibernate.cfg.MappingSettings;
import org.hibernate.cfg.PersistenceSettings;
import org.hibernate.cfg.SchemaToolingSettings;
@ -62,7 +62,7 @@ class HibernatePropertiesTests {
this.contextRunner.run(assertHibernateProperties((hibernateProperties) -> {
assertThat(hibernateProperties).doesNotContainKeys("hibernate.ejb.naming_strategy");
assertThat(hibernateProperties).containsEntry(MappingSettings.PHYSICAL_NAMING_STRATEGY,
CamelCaseToUnderscoresNamingStrategy.class.getName());
PhysicalNamingStrategySnakeCaseImpl.class.getName());
assertThat(hibernateProperties).containsEntry(MappingSettings.IMPLICIT_NAMING_STRATEGY,
SpringImplicitNamingStrategy.class.getName());
}));

View File

@ -534,11 +534,7 @@ bom {
releaseNotes("https://github.com/hazelcast/hazelcast/releases/tag/v{version}")
}
}
library("Hibernate", "6.6.13.Final") {
prohibit {
versionRange "[7.0.0.Alpha1,)"
because "it exceeds our Jakarta EE 10 baseline"
}
library("Hibernate", "7.0.0.Beta3") {
group("org.hibernate.orm") {
modules = [
"hibernate-agroal",
@ -794,11 +790,7 @@ bom {
]
}
}
library("Jakarta Persistence", "3.1.0") {
prohibit {
versionRange "[3.2.0-B01,)"
because "it exceeds our Jakarta EE 10 baseline"
}
library("Jakarta Persistence", "3.2.0") {
group("jakarta.persistence") {
modules = [
"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");
* 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;
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.springframework.context.annotation.Bean;
@ -26,12 +27,12 @@ import org.springframework.context.annotation.Configuration;
public class MyHibernateConfiguration {
@Bean
public CamelCaseToUnderscoresNamingStrategy caseSensitivePhysicalNamingStrategy() {
return new CamelCaseToUnderscoresNamingStrategy() {
public PhysicalNamingStrategySnakeCaseImpl caseSensitivePhysicalNamingStrategy() {
return new PhysicalNamingStrategySnakeCaseImpl() {
@Override
protected boolean isCaseInsensitive(JdbcEnvironment jdbcEnvironment) {
return false;
public Identifier toPhysicalColumnName(Identifier logicalName, JdbcEnvironment jdbcEnvironment) {
return logicalName;
}
};

View File

@ -16,7 +16,8 @@
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.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
@ -25,10 +26,10 @@ import org.springframework.context.annotation.Configuration
class MyHibernateConfiguration {
@Bean
fun caseSensitivePhysicalNamingStrategy(): CamelCaseToUnderscoresNamingStrategy {
return object : CamelCaseToUnderscoresNamingStrategy() {
override fun isCaseInsensitive(jdbcEnvironment: JdbcEnvironment): Boolean {
return false
fun caseSensitivePhysicalNamingStrategy(): PhysicalNamingStrategySnakeCaseImpl {
return object : PhysicalNamingStrategySnakeCaseImpl() {
override fun toPhysicalColumnName(logicalName: Identifier, jdbcEnvironment: JdbcEnvironment): Identifier {
return logicalName
}
}
}

View File

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