Skip to content

Upgrade Hibernate ORM to 7.0.0.Final #2260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Hibernate Reactive has been tested with:
- CockroachDB v24
- MS SQL Server 2022
- Oracle 23
- [Hibernate ORM][] 7.0.0.CR1
- [Hibernate ORM][] 7.0.0.Final
- [Vert.x Reactive PostgreSQL Client](https://vertx.io/docs/vertx-pg-client/java/) 4.5.14
- [Vert.x Reactive MySQL Client](https://vertx.io/docs/vertx-mysql-client/java/) 4.5.14
- [Vert.x Reactive Db2 Client](https://vertx.io/docs/vertx-db2-client/java/) 4.5.14
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ org.gradle.java.installations.auto-download=false
#enableMavenLocalRepo = true

# The default Hibernate ORM version (override using `-PhibernateOrmVersion=the.version.you.want`)
hibernateOrmVersion = 7.0.0.CR2
hibernateOrmVersion = 7.0.0.Final

# Override default Hibernate ORM Gradle plugin version
# Using the stable version because I don't know how to configure the build to download the snapshot version from
# a remote repository
#hibernateOrmGradlePluginVersion = 7.0.0.CR1
#hibernateOrmGradlePluginVersion = 7.0.0.Final

# If set to true, skip Hibernate ORM version parsing (default is true, if set to null)
# this is required when using intervals or weird versions or the build will fail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,7 @@ public final <K> CompletionStage<List<T>> reactiveLoad(K[] ids, MultiIdLoadOptio

protected abstract <K> CompletionStage<List<T>> performUnorderedMultiLoad(K[] ids, MultiIdLoadOptions loadOptions, SharedSessionContractImplementor session);

protected boolean isIdCoercionEnabled() {
return !getSessionFactory().getSessionFactoryOptions().getJpaCompliance().isLoadByIdComplianceEnabled();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected <K> CompletionStage<List<E>> performOrderedMultiLoad(
);
}

final boolean coerce = !getSessionFactory().getJpaMetamodel().getJpaCompliance().isLoadByIdComplianceEnabled();
final boolean coerce = isIdCoercionEnabled();
final LockOptions lockOptions = ( loadOptions.getLockOptions() == null )
? new LockOptions( LockMode.NONE )
: loadOptions.getLockOptions();
Expand Down Expand Up @@ -312,7 +312,7 @@ protected final <R, K> K[] processResolvableEntities(
return ids;
}

final boolean coerce = !getSessionFactory().getJpaMetamodel().getJpaCompliance().isLoadByIdComplianceEnabled();
final boolean coerce = isIdCoercionEnabled();

boolean foundAnyResolvedEntities = false;
List<K> nonResolvedIds = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected CompletionStage<List<T>> performOrderedMultiLoad(
final List<Object> idsInBatch = new ArrayList<>();
final List<Integer> elementPositionsLoadedByBatch = new ArrayList<>();

final boolean coerce = !getSessionFactory().getJpaMetamodel().getJpaCompliance().isLoadByIdComplianceEnabled();
final boolean coerce = isIdCoercionEnabled();
return loop( 0, ids.length, i -> {
final Object id = coerce
? getEntityDescriptor().getIdentifierMapping().getJavaType().coerce( ids[i], session )
Expand Down Expand Up @@ -311,7 +311,7 @@ protected CompletionStage<List<T>> performUnorderedMultiLoad(
boolean foundAnyManagedEntities = false;
final List<Object> nonManagedIds = new ArrayList<>();

final boolean coerce = !getSessionFactory().getJpaMetamodel().getJpaCompliance().isLoadByIdComplianceEnabled();
final boolean coerce = isIdCoercionEnabled();
for ( Object o : ids ) {
final Object id = coerce
? getEntityDescriptor().getIdentifierMapping().getJavaType().coerce( o, session )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ public <R> ReactiveQuery<R> createReactiveQuery(CriteriaQuery<R> criteriaQuery)
return createReactiveCriteriaQuery( selectStatement, criteriaQuery.getResultType() );
}
catch (RuntimeException e) {
if ( getSessionFactory().getJpaMetamodel().getJpaCompliance().isJpaTransactionComplianceEnabled() ) {
if ( getSessionFactory().getSessionFactoryOptions().getJpaCompliance().isJpaTransactionComplianceEnabled() ) {
markForRollbackOnly();
}
throw getExceptionConverter().convert( e );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ public <R> ReactiveQuery<R> createReactiveQuery(CriteriaQuery<R> criteriaQuery)
return createReactiveCriteriaQuery( selectStatement, criteriaQuery.getResultType() );
}
catch (RuntimeException e) {
if ( getSessionFactory().getJpaMetamodel().getJpaCompliance().isJpaTransactionComplianceEnabled() ) {
if ( getSessionFactory().getSessionFactoryOptions().getJpaCompliance().isJpaTransactionComplianceEnabled() ) {
markForRollbackOnly();
}
throw getExceptionConverter().convert( e );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
*/
package org.hibernate.reactive;

import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Objects;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

Expand All @@ -26,12 +21,13 @@
import jakarta.persistence.Table;
import jakarta.persistence.Temporal;
import jakarta.persistence.TemporalType;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Objects;

import static java.util.concurrent.TimeUnit.MINUTES;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.assertj.core.api.Assertions.assertThat;

@Timeout(value = 10, timeUnit = MINUTES)

Expand All @@ -56,9 +52,8 @@ public void testRootClassViaAssociation(VertxTestContext context) {
.thenCompose( v -> openSession() )
.thenCompose( s2 -> s2.find( Author.class, author.getId() ) )
.thenAccept( auth -> {
assertNotNull( auth );
assertEquals( author, auth );
assertEquals( book.getTitle(), auth.getBook().getTitle() );
assertThat( auth ).isEqualTo( author );
assertThat( auth.getBook().getTitle() ).isEqualTo( book.getTitle() );
} )
)
);
Expand All @@ -77,17 +72,15 @@ public void testSubclassViaAssociation(VertxTestContext context) {
.thenCompose( v -> s.flush() )
.thenCompose( v -> s.find( Author.class, author.getId() ) )
.thenAccept( auth -> {
assertNotNull( auth );
assertEquals( author, auth );
assertEquals( book.getTitle(), auth.getBook().getTitle() );
assertThat( auth ).isEqualTo( author );
assertThat( auth.getBook().getTitle() ).isEqualTo( book.getTitle() );
} )
)
);
}

@Test
public void testRootClassViaFind(VertxTestContext context) {

final Book novel = new Book( 6, "The Boy, The Mole, The Fox and The Horse", new Date());
final Author author = new Author( "Charlie Mackesy", novel );

Expand All @@ -99,9 +92,8 @@ public void testRootClassViaFind(VertxTestContext context) {
.thenCompose( v -> openSession()
.thenCompose( s -> s.find(Book.class, 6) ) )
.thenAccept(book -> {
assertNotNull(book);
assertFalse(book instanceof SpellBook);
assertEquals(book.getTitle(), "The Boy, The Mole, The Fox and The Horse");
assertThat( book ).isNotInstanceOf( SpellBook.class );
assertThat( book.getTitle() ).isEqualTo( "The Boy, The Mole, The Fox and The Horse" );
}));
}

Expand All @@ -117,35 +109,41 @@ public void testSubclassViaFind(VertxTestContext context) {
.thenCompose( v -> s.flush() ) )
.thenCompose( v -> openSession().thenCompose( s -> s.find(Book.class, 6) ) )
.thenAccept(book -> {
assertNotNull(book);
assertTrue(book instanceof SpellBook);
assertEquals(book.getTitle(), "Necronomicon");
assertThat( book ).isInstanceOf( SpellBook.class );
assertThat( book.getTitle() ).isEqualTo( "Necronomicon" );
}));
}

@Test
public void testQueryUpdate(VertxTestContext context) {
final SpellBook spells = new SpellBook( 6, "Necronomicon", true, new Date() );
// final Author author = new Author( "Abdul Alhazred", spells );

test( context,
test(
context,
openSession()
.thenCompose( s -> s.persist(spells).thenCompose( v -> s.flush() ) )
.thenCompose( s -> s.persist( spells ).thenCompose( v -> s.flush() ) )
.thenCompose( vv -> openSession()
.thenCompose( s -> s.withTransaction( t -> s.createMutationQuery("update SpellBook set title='x' where forbidden=false").executeUpdate() )
.thenCompose( v -> s.withTransaction( t -> s.createMutationQuery("update SpellBook set forbidden=false where title='Necronomicon'").executeUpdate() ) )
.thenCompose( v -> s.withTransaction( t -> s.createMutationQuery("update Book set title=title||' II' where title='Necronomicon'").executeUpdate() ) )
.thenCompose( v -> s.find(Book.class, 6) )
.thenCompose( s -> s.withTransaction( t -> s
.createMutationQuery( "update SpellBook set title='x' where forbidden=false" )
.executeUpdate() )
.thenCompose( v -> s.withTransaction( t -> s
.createMutationQuery( "update SpellBook set forbidden=false where title='Necronomicon'" )
.executeUpdate() ) )
.thenCompose( v -> s.withTransaction( t -> s
.createMutationQuery( "update Book set title=title||' II' where title='Necronomicon'" )
.executeUpdate() ) )
.thenCompose( v -> s.find( Book.class, 6 ) )
.thenAccept( book -> {
assertNotNull(book);
assertTrue(book instanceof SpellBook);
assertEquals(book.getTitle(), "Necronomicon II");
assertThat( book ).isInstanceOf( SpellBook.class );
assertThat( book.getTitle() ).isEqualTo( "Necronomicon II" );
} )
) )
) )
.thenCompose( vv -> openSession()
.thenCompose( s -> s.withTransaction( t -> s.createMutationQuery("delete Book where title='Necronomicon II'").executeUpdate() ) )
.thenCompose( s -> s.withTransaction( t -> s
.createMutationQuery( "delete Book where title='Necronomicon II'" )
.executeUpdate() ) )
.thenCompose( v -> openSession() )
.thenCompose( s -> s.find(Book.class, 6) )
.thenCompose( s -> s.find( Book.class, 6 ) )
.thenAccept( Assertions::assertNull )
)
);
Expand All @@ -154,7 +152,6 @@ public void testQueryUpdate(VertxTestContext context) {
@Test
public void testQueryUpdateWithParameters(VertxTestContext context) {
final SpellBook spells = new SpellBook( 6, "Necronomicon", true, new Date() );
// final Author author = new Author( "Abdul Alhazred", spells );

test( context,
openSession()
Expand All @@ -174,11 +171,9 @@ public void testQueryUpdateWithParameters(VertxTestContext context) {
.thenCompose( v -> openSession()
.thenCompose( s -> s.find( Book.class, 6) )
.thenAccept( book -> {
assertNotNull(book);
assertTrue(book instanceof SpellBook);
assertEquals(book.getTitle(), "Necronomicon II");
}
)
assertThat( book ).isInstanceOf( SpellBook.class );
assertThat( book.getTitle() ).isEqualTo( "Necronomicon II" );
} )
)
.thenCompose( v -> openSession()
.thenCompose( s -> s.withTransaction( t -> s.createMutationQuery("delete Book where title=:tit")
Expand Down Expand Up @@ -207,6 +202,11 @@ public SpellBook(Integer id, String title, boolean forbidden, Date published) {
public boolean getForbidden() {
return forbidden;
}

@Override
public String toString() {
return "SpellBook{" + super.toString() + ",forbidden=" + forbidden + '}';
}
}

@Entity(name="Book")
Expand Down Expand Up @@ -268,6 +268,11 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash( title );
}

@Override
public String toString() {
return id + ", " + title + ", " + published;
}
}

@Entity(name = "Author")
Expand Down
Loading