Upgrade to Hibernate 6.1.1.Final

This commit makes the following potentially breaking changes:

- Dependency management for modules that do not exist in Hibernate
  6.1 has been removed.
- Hibernate's modules are now in the org.hibernate.orm group. Users
  not using the starter or using modules that are not in the starter
  will have to update their build configuration accordingly.
- spring.jpa.hibernate.use-new-id-generator-mappings has been removed
  as Hibernate no longer supports switching back to the old ID
  generator mappings.

Co-authored-by: Andy Wilkinson <wilkinsona@vmware.com>

Closes gh-31674
pull/31689/head
Oliver Drotbohm 2 years ago committed by Andy Wilkinson
parent beb40eaaf6
commit b10c57551c

@ -107,7 +107,7 @@ dependencies {
exclude group: "commons-logging", module: "commons-logging"
}
optional("org.flywaydb:flyway-core")
optional("org.hibernate:hibernate-core-jakarta")
optional("org.hibernate.orm:hibernate-core")
optional("org.hibernate.validator:hibernate-validator")
optional("org.influxdb:influxdb-java")
optional("org.liquibase:liquibase-core") {

@ -102,10 +102,8 @@ dependencies {
optional("org.flywaydb:flyway-core")
optional("org.flywaydb:flyway-sqlserver")
optional("org.freemarker:freemarker")
optional("org.hibernate:hibernate-core-jakarta")
optional("org.hibernate:hibernate-jcache") {
exclude group: "org.hibernate", module: "hibernate-core"
}
optional("org.hibernate.orm:hibernate-core")
optional("org.hibernate.orm:hibernate-jcache")
optional("org.hibernate.validator:hibernate-validator")
optional("org.influxdb:influxdb-java")
optional("org.jooq:jooq") {

@ -53,13 +53,6 @@ public class HibernateProperties {
*/
private String ddlAuto;
/**
* 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".
*/
private Boolean useNewIdGeneratorMappings;
public String getDdlAuto() {
return this.ddlAuto;
}
@ -68,14 +61,6 @@ public class HibernateProperties {
this.ddlAuto = ddlAuto;
}
public Boolean isUseNewIdGeneratorMappings() {
return this.useNewIdGeneratorMappings;
}
public void setUseNewIdGeneratorMappings(Boolean useNewIdGeneratorMappings) {
this.useNewIdGeneratorMappings = useNewIdGeneratorMappings;
}
public Naming getNaming() {
return this.naming;
}
@ -97,7 +82,6 @@ public class HibernateProperties {
private Map<String, Object> getAdditionalProperties(Map<String, String> existing, HibernateSettings settings) {
Map<String, Object> result = new HashMap<>(existing);
applyNewIdGeneratorMappings(result);
applyScanner(result);
getNaming().applyNamingStrategies(result);
String ddlAuto = determineDdlAuto(existing, settings::getDdlAuto);
@ -114,15 +98,6 @@ public class HibernateProperties {
return result;
}
private void applyNewIdGeneratorMappings(Map<String, Object> result) {
if (this.useNewIdGeneratorMappings != null) {
result.put(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, this.useNewIdGeneratorMappings.toString());
}
else if (!result.containsKey(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS)) {
result.put(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true");
}
}
private void applyScanner(Map<String, Object> result) {
if (!result.containsKey(AvailableSettings.SCANNER) && ClassUtils.isPresent(DISABLED_SCANNER_CLASS, null)) {
result.put(AvailableSettings.SCANNER, DISABLED_SCANNER_CLASS);

@ -1100,6 +1100,15 @@
"name": "spring.groovy.template.suffix",
"defaultValue": ".tpl"
},
{
"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.http.converters.preferred-json-mapper",
"type": "java.lang.String",

@ -93,19 +93,6 @@ class HibernatePropertiesTests {
}));
}
@Test
void useNewIdGeneratorMappingsDefault() {
this.contextRunner.run(assertHibernateProperties((hibernateProperties) -> assertThat(hibernateProperties)
.containsEntry(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true")));
}
@Test
void useNewIdGeneratorMappingsFalse() {
this.contextRunner.withPropertyValues("spring.jpa.hibernate.use-new-id-generator-mappings:false")
.run(assertHibernateProperties((hibernateProperties) -> assertThat(hibernateProperties)
.containsEntry(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "false")));
}
@Test
void scannerUsesDisabledScannerByDefault() {
this.contextRunner.run(assertHibernateProperties((hibernateProperties) -> assertThat(hibernateProperties)

@ -4,7 +4,8 @@ databaseChangeLog:
author: dsyer
changes:
- createSequence:
sequenceName: hibernate_sequence
sequenceName: city_seq
incrementBy: 50
- createTable:
tableName: city
columns:

@ -1,4 +1,4 @@
CREATE SEQUENCE HIBERNATE_SEQUENCE;
CREATE SEQUENCE city_seq INCREMENT BY 50;
CREATE TABLE CITY (
id BIGINT GENERATED BY DEFAULT AS IDENTITY,

@ -353,22 +353,23 @@ bom {
]
}
}
library("Hibernate", "5.6.10.Final") {
group("org.hibernate") {
library("Hibernate", "6.1.1.Final") {
group("org.hibernate.orm") {
modules = [
"hibernate-agroal",
"hibernate-ant",
"hibernate-c3p0",
"hibernate-core-jakarta",
"hibernate-ehcache",
"hibernate-entitymanager",
"hibernate-envers-jakarta",
"hibernate-community-dialects",
"hibernate-core",
"hibernate-envers",
"hibernate-graalvm",
"hibernate-hikaricp",
"hibernate-java8",
"hibernate-jcache",
"hibernate-jpamodelgen-jakarta",
"hibernate-jpamodelgen",
"hibernate-micrometer",
"hibernate-proxool",
"hibernate-spatial",
"hibernate-testing-jakarta",
"hibernate-testing",
"hibernate-vibur"
]
}

@ -45,7 +45,7 @@ dependencies {
optional("io.r2dbc:r2dbc-spi")
optional("jakarta.servlet:jakarta.servlet-api")
optional("org.apache.derby:derbytools")
optional("org.hibernate:hibernate-core-jakarta")
optional("org.hibernate.orm:hibernate-core")
optional("org.springframework:spring-jdbc")
optional("org.springframework:spring-orm")
optional("org.springframework:spring-web")

@ -99,7 +99,7 @@ dependencies {
implementation("org.assertj:assertj-core")
implementation("org.cache2k:cache2k-spring")
implementation("org.apache.groovy:groovy")
implementation("org.hibernate:hibernate-jcache") {
implementation("org.hibernate.orm:hibernate-jcache") {
exclude group: "javax.activation", module: "javax.activation-api"
exclude group: "javax.persistence", module: "javax.persistence-api"
exclude group: "javax.xml.bind", module: "jaxb-api"

@ -246,7 +246,7 @@ See {spring-boot-autoconfigure-module-code}/orm/jpa/HibernateJpaAutoConfiguratio
Hibernate {hibernate-docs}#caching[second-level cache] can be configured for a range of cache providers.
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:hibernate-jcache` is available on the classpath.
To do this with JCache, first make sure that `org.hibernate.orm:hibernate-jcache` is available on the classpath.
Then, add a `HibernatePropertiesCustomizer` bean as shown in the following example:
include::code:MyHibernateSecondLevelCacheConfiguration[]

@ -7,9 +7,7 @@ description = "Starter for using Spring Data JPA with Hibernate"
dependencies {
api(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-aop"))
api(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-jdbc"))
api("org.hibernate:hibernate-core-jakarta") {
exclude group: "jakarta.activation", module: "jakarta.activation-api"
}
api("org.hibernate.orm:hibernate-core")
api("org.springframework.data:spring-data-jpa")
api("org.springframework:spring-aspects")
}

@ -23,7 +23,7 @@ dependencies {
optional("net.sourceforge.htmlunit:htmlunit") {
exclude group: "commons-logging", module: "commons-logging"
}
optional("org.hibernate:hibernate-core-jakarta")
optional("org.hibernate.orm:hibernate-core")
optional("org.junit.jupiter:junit-jupiter-api")
optional("org.seleniumhq.selenium:htmlunit-driver") {
exclude group: "commons-logging", module: "commons-logging"

@ -72,7 +72,7 @@ dependencies {
}
optional("org.flywaydb:flyway-core")
optional("org.hamcrest:hamcrest-library")
optional("org.hibernate:hibernate-core-jakarta")
optional("org.hibernate.orm:hibernate-core")
optional("org.hibernate.validator:hibernate-validator")
optional("org.jooq:jooq") {
exclude(group: "javax.xml.bind", module: "jaxb-api")

@ -10,12 +10,7 @@ dependencies {
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-web"))
implementation("jakarta.persistence:jakarta.persistence-api")
implementation("jakarta.xml.bind:jakarta.xml.bind-api")
implementation("org.hibernate:hibernate-core-jakarta") {
exclude group: "javax.activation", module: "javax.activation-api"
exclude group: "javax.persistence", module: "javax.persistence-api"
exclude group: "javax.xml.bind", module: "jaxb-api"
exclude group: "org.jboss.spec.javax.transaction", module: "jboss-transaction-api_1.2_spec"
}
implementation("org.hibernate.orm:hibernate-core")
implementation("org.springframework:spring-orm")
runtimeOnly("com.h2database:h2")

Loading…
Cancel
Save