Skip to content

Commit

Permalink
Merge pull request quarkusio#40102 from yrodiere/orm6.5
Browse files Browse the repository at this point in the history
Upgrade to Hibernate ORM 6.5 / Hibernate Reactive 2.3
  • Loading branch information
yrodiere authored Apr 26, 2024
2 parents 399ba31 + c44e9e1 commit bbe9cbc
Show file tree
Hide file tree
Showing 21 changed files with 114 additions and 41 deletions.
6 changes: 3 additions & 3 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@
bytebuddy.version (just below), hibernate-orm.version-for-documentation (in docs/pom.xml)
and both hibernate-orm.version and antlr.version in build-parent/pom.xml
WARNING again for diffs that don't provide enough context: when updating, see above -->
<hibernate-orm.version>6.4.7.Final</hibernate-orm.version>
<bytebuddy.version>1.14.11</bytebuddy.version> <!-- Version controlled by Hibernate ORM's needs -->
<hibernate-orm.version>6.5.0.Final</hibernate-orm.version>
<bytebuddy.version>1.14.12</bytebuddy.version> <!-- Version controlled by Hibernate ORM's needs -->
<hibernate-commons-annotations.version>6.0.6.Final</hibernate-commons-annotations.version> <!-- version controlled by Hibernate ORM -->
<hibernate-reactive.version>2.2.2.Final</hibernate-reactive.version>
<hibernate-reactive.version>2.3.0.Final</hibernate-reactive.version>
<hibernate-validator.version>8.0.1.Final</hibernate-validator.version>
<!-- When updating, align hibernate-search.version-for-documentation in docs/pom.xml -->
<hibernate-search.version>7.1.1.Final</hibernate-search.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ private HibernateOrmTypes() {
DotName.createSimple("org.hibernate.annotations.Filters"),
DotName.createSimple("org.hibernate.annotations.ForeignKey"),
DotName.createSimple("org.hibernate.annotations.Formula"),
DotName.createSimple("org.hibernate.annotations.FractionalSeconds"),
DotName.createSimple("org.hibernate.annotations.Generated"),
DotName.createSimple("org.hibernate.annotations.GeneratedColumn"),
DotName.createSimple("org.hibernate.annotations.GeneratorType"),
Expand Down Expand Up @@ -287,6 +288,7 @@ private HibernateOrmTypes() {
DotName.createSimple("org.hibernate.annotations.Persister"),
DotName.createSimple("org.hibernate.annotations.Polymorphism"),
DotName.createSimple("org.hibernate.annotations.Proxy"),
DotName.createSimple("org.hibernate.annotations.QueryCacheLayout"),
DotName.createSimple("org.hibernate.annotations.RowId"),
DotName.createSimple("org.hibernate.annotations.SQLDelete"),
DotName.createSimple("org.hibernate.annotations.SQLDeleteAll"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ private RuntimeSettings buildRuntimeSettings(String persistenceUnitName, Recorde
}

// Allow detection of driver/database capabilities on runtime init (was disabled during static init)
runtimeSettingsBuilder.put("hibernate.temp.use_jdbc_metadata_defaults", "true");
runtimeSettingsBuilder.put("hibernate.boot.allow_jdbc_metadata_access", "true");

if (!persistenceUnitConfig.unsupportedProperties().isEmpty()) {
log.warnf("Persistence-unit [%s] sets unsupported properties."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.CriteriaUpdate;

import org.hibernate.Filter;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.SessionFactory;
Expand All @@ -23,6 +24,7 @@
import org.hibernate.query.Query;
import org.hibernate.query.SelectionQuery;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.hibernate.query.criteria.JpaCriteriaInsert;
import org.hibernate.query.criteria.JpaCriteriaInsertSelect;

/**
Expand Down Expand Up @@ -91,6 +93,26 @@ public <T> T get(Class<T> entityClass, Object id, LockMode lockMode) {
return delegate.get().get(entityClass, id, lockMode);
}

@Override
public Filter enableFilter(String filterName) {
return delegate.get().enableFilter(filterName);
}

@Override
public Filter getEnabledFilter(String filterName) {
return delegate.get().getEnabledFilter(filterName);
}

@Override
public void disableFilter(String filterName) {
delegate.get().disableFilter(filterName);
}

@Override
public MutationQuery createMutationQuery(JpaCriteriaInsert insertSelect) {
return delegate.get().createMutationQuery(insertSelect);
}

@Override
public void refresh(Object entity) {
delegate.get().refresh(entity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ private MergedSettings mergeSettings(QuarkusPersistenceUnitDefinition puDefiniti

// Quarkus specific

cfg.put("hibernate.temp.use_jdbc_metadata_defaults", "false");
cfg.put("hibernate.boot.allow_jdbc_metadata_access", "false");

//This shouldn't be encouraged, but sometimes it's really useful - and it used to be the default
//in Hibernate ORM before the JPA spec would require to change this.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.hibernate.query.Query;
import org.hibernate.query.SelectionQuery;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.hibernate.query.criteria.JpaCriteriaInsert;
import org.hibernate.query.criteria.JpaCriteriaInsertSelect;
import org.hibernate.stat.SessionStatistics;

Expand Down Expand Up @@ -1317,6 +1318,14 @@ public MutationQuery createMutationQuery(JpaCriteriaInsertSelect insertSelect) {
}
}

@Override
public MutationQuery createMutationQuery(JpaCriteriaInsert insertSelect) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.session.createMutationQuery(insertSelect);
}
}

@Override
public MutationQuery createNativeMutationQuery(String sqlString) {
checkBlocking();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import jakarta.transaction.TransactionManager;
import jakarta.transaction.TransactionSynchronizationRegistry;

import org.hibernate.Filter;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.SessionFactory;
Expand All @@ -28,6 +29,7 @@
import org.hibernate.query.Query;
import org.hibernate.query.SelectionQuery;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.hibernate.query.criteria.JpaCriteriaInsert;
import org.hibernate.query.criteria.JpaCriteriaInsertSelect;

import io.quarkus.arc.Arc;
Expand Down Expand Up @@ -394,6 +396,30 @@ public Object get(String entityName, Object id, LockMode lockMode) {
}
}

@Override
public Filter enableFilter(String filterName) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.statelessSession.enableFilter(filterName);
}
}

@Override
public Filter getEnabledFilter(String filterName) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.statelessSession.getEnabledFilter(filterName);
}
}

@Override
public void disableFilter(String filterName) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
emr.statelessSession.disableFilter(filterName);
}
}

@Override
public String getTenantIdentifier() {
try (SessionResult emr = acquireSession()) {
Expand Down Expand Up @@ -576,6 +602,14 @@ public MutationQuery createMutationQuery(JpaCriteriaInsertSelect insertSelect) {
}
}

@Override
public MutationQuery createMutationQuery(JpaCriteriaInsert insertSelect) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.statelessSession.createMutationQuery(insertSelect);
}
}

@Override
public MutationQuery createNativeMutationQuery(String sqlString) {
checkBlocking();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<property name="hibernate.archive.autodetection" value="class, hbm"/>

<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
<property name="jakarta.persistence.schema-generation.database.action" value="drop-and-create"/>
</properties>

</persistence-unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<property name="hibernate.archive.autodetection" value="class, hbm"/>

<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
<property name="jakarta.persistence.schema-generation.database.action" value="drop-and-create"/>
</properties>

</persistence-unit>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.quarkus.it.panache.kotlin

enum class Status {
// Make sure to keep the ordinal order different from alphabetical order here
// See io.quarkus.it.panache.TestEndpointRunner
LIVING,
DECEASED
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ class TestEndpointRunner {
con.close()

Assertions.assertEquals(
"CHARACTER VARYING",
// The H2 dialect uses native enums by default for @Enumerated(EnumType.STRING)
// We're also checking enum value order here:
// with @Enumerated(EnumType.STRING), enum values should be in alphabetical order
// (which is different from the ordinal order)
"ENUM('DECEASED', 'LIVING')",
schema["PERSON2"]?.get("STATUS"),
schema.toString()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
<property name="jakarta.persistence.schema-generation.database.action" value="drop-and-create"/>
</properties>

</persistence-unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
<property name="jakarta.persistence.schema-generation.database.action" value="drop-and-create"/>
</properties>

</persistence-unit>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Properties file used by ImageMetricsITCase
image_details.total_bytes=88215776
image_details.total_bytes.tolerance=3
analysis_results.types.reachable=20414
analysis_results.types.reachable=20556
analysis_results.types.reachable.tolerance=3
analysis_results.methods.reachable=100917
analysis_results.methods.reachable=101602
analysis_results.methods.reachable.tolerance=3
analysis_results.fields.reachable=29906
analysis_results.fields.reachable=30176
analysis_results.fields.reachable.tolerance=3
analysis_results.types.reflection=6530
analysis_results.types.reflection=6585
analysis_results.types.reflection.tolerance=3
analysis_results.methods.reflection=4781
analysis_results.methods.reflection=4786
analysis_results.methods.reflection.tolerance=3
analysis_results.fields.reflection=143
analysis_results.fields.reflection=147
analysis_results.fields.reflection.tolerance=3
analysis_results.types.jni=63
analysis_results.types.jni.tolerance=1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Properties file used by ImageMetricsITCase
image_details.total_bytes=91650760
image_details.total_bytes.tolerance=3
analysis_results.types.reachable=20387
analysis_results.types.reachable=20867
analysis_results.types.reachable.tolerance=3
analysis_results.methods.reachable=100956
analysis_results.methods.reachable=103028
analysis_results.methods.reachable.tolerance=3
analysis_results.fields.reachable=29789
analysis_results.fields.reachable=30098
analysis_results.fields.reachable.tolerance=3
analysis_results.types.reflection=6522
analysis_results.types.reflection=6705
analysis_results.types.reflection.tolerance=3
analysis_results.methods.reflection=4893
analysis_results.methods.reflection.tolerance=3
analysis_results.fields.reflection=163
analysis_results.fields.reflection=170
analysis_results.fields.reflection.tolerance=3
analysis_results.types.jni=61
analysis_results.types.jni.tolerance=1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Properties file used by ImageMetricsITCase
image_details.total_bytes=79712248
image_details.total_bytes.tolerance=3
analysis_results.types.reachable=19441
analysis_results.types.reachable=19625
analysis_results.types.reachable.tolerance=3
analysis_results.methods.reachable=96417
analysis_results.methods.reachable=97338
analysis_results.methods.reachable.tolerance=3
analysis_results.fields.reachable=27131
analysis_results.fields.reachable=27443
analysis_results.fields.reachable.tolerance=3
analysis_results.types.reflection=6060
analysis_results.types.reflection=6128
analysis_results.types.reflection.tolerance=3
analysis_results.methods.reflection=4600
analysis_results.methods.reflection=4608
analysis_results.methods.reflection.tolerance=3
analysis_results.fields.reflection=170
analysis_results.fields.reflection=176
analysis_results.fields.reflection.tolerance=3
analysis_results.types.jni=63
analysis_results.types.jni.tolerance=1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Properties file used by ImageMetricsITCase
image_details.total_bytes=83036632
image_details.total_bytes.tolerance=3
analysis_results.types.reachable=19394
analysis_results.types.reachable=19853
analysis_results.types.reachable.tolerance=3
analysis_results.methods.reachable=96465
analysis_results.methods.reachable=98606
analysis_results.methods.reachable.tolerance=3
analysis_results.fields.reachable=27025
analysis_results.fields.reachable=27389
analysis_results.fields.reachable.tolerance=3
analysis_results.types.reflection=6100
analysis_results.types.reflection=6232
analysis_results.types.reflection.tolerance=3
analysis_results.methods.reflection=4707
analysis_results.methods.reflection=4708
analysis_results.methods.reflection.tolerance=3
analysis_results.fields.reflection=192
analysis_results.fields.reflection=201
analysis_results.fields.reflection.tolerance=3
analysis_results.types.jni=61
analysis_results.types.jni.tolerance=1
Expand Down
8 changes: 4 additions & 4 deletions integration-tests/jpa/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ I am doing a first pass on the properties and I want to propose the following pr
* `hibernate.dialect`
* `hibernate.show_sql` (and then `hibernate.format_sql` ?)
* should show_sql not do System.out but rather a proper log
* `javax.persistence.schema-generation.database.action`
* `jakarta.persistence.schema-generation.database.action`

Anything else?

I would force the following:

* `javax.persistence.sharedCache.mode` to yes
* `javax.persistence.sql-load-script-source` set to a default file name
* `jakarta.persistence.sharedCache.mode` to yes
* `jakarta.persistence.sql-load-script-source` set to a default file name

Questions do we need:

* `javax.persistence.transactionType`
* `jakarta.persistence.transactionType`


Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
Optimistically create the tables;
will cause background errors being logged if they already exist,
but is practical to retain existing data across runs (or create as needed) -->
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
<property name="jakarta.persistence.schema-generation.database.action" value="drop-and-create"/>

<property name="javax.persistence.validation.mode" value="NONE"/>
<property name="jakarta.persistence.validation.mode" value="NONE"/>
</properties>

</persistence-unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ analysis_results.types.reflection=8927
analysis_results.types.reflection.tolerance=3
analysis_results.methods.reflection=7136
analysis_results.methods.reflection.tolerance=3
analysis_results.fields.reflection=438
analysis_results.fields.reflection=445
analysis_results.fields.reflection.tolerance=3
analysis_results.types.jni=64
analysis_results.types.jni.tolerance=1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ analysis_results.classes.reflection=9118
analysis_results.classes.reflection.tolerance=3
analysis_results.methods.reflection=7741
analysis_results.methods.reflection.tolerance=3
analysis_results.fields.reflection=480
analysis_results.fields.reflection=496
analysis_results.fields.reflection.tolerance=3
# TODO: Switch to using analysis_results.types.jni key once we drop support for GraalVM 22.3.0
analysis_results.classes.jni=62
Expand Down

0 comments on commit bbe9cbc

Please sign in to comment.