diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/event/impl/DefaultReactiveDeleteEventListener.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/event/impl/DefaultReactiveDeleteEventListener.java index 1dbf6db02..ee5d7eb36 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/event/impl/DefaultReactiveDeleteEventListener.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/event/impl/DefaultReactiveDeleteEventListener.java @@ -195,7 +195,7 @@ private CompletionStage fetchAndDelete(DeleteEvent event, DeleteContext tr : !source.contains( objectEvent ); if ( detached ) { // Hibernate Reactive doesn't support detached instances in remove() - throw new IllegalArgumentException( "unmanaged instance passed to remove()" ); + throw new IllegalArgumentException( "Unmanaged instance passed to remove()" ); } //Object entity = persistenceContext.unproxyAndReassociate( event.getObject() ); diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/event/impl/DefaultReactiveLockEventListener.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/event/impl/DefaultReactiveLockEventListener.java index ffd0fcfde..ac3379ff5 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/event/impl/DefaultReactiveLockEventListener.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/event/impl/DefaultReactiveLockEventListener.java @@ -73,7 +73,7 @@ public CompletionStage reactiveOnLock(LockEvent event) throws HibernateExc : !source.contains( event.getObject() ); if ( detached ) { // Hibernate Reactive doesn't support detached instances in refresh() - throw new IllegalArgumentException( "unmanaged instance passed to refresh()" ); + throw new IllegalArgumentException( "Unmanaged instance passed to refresh()" ); } diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/impl/ReactiveExceptionConverter.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/impl/ReactiveExceptionConverter.java deleted file mode 100644 index ca984b9fe..000000000 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/impl/ReactiveExceptionConverter.java +++ /dev/null @@ -1,32 +0,0 @@ -/* Hibernate, Relational Persistence for Idiomatic Java - * - * SPDX-License-Identifier: Apache-2.0 - * Copyright: Red Hat Inc. and Hibernate Authors - */ -package org.hibernate.reactive.session.impl; - -import org.hibernate.HibernateException; -import org.hibernate.engine.spi.SharedSessionContractImplementor; -import org.hibernate.internal.ExceptionConverterImpl; - -/** - * Handle exceptions and convert them following the logic used in Hibernate ORM. - *

- * It converts the exception to a {@link HibernateException} or a - * {@link jakarta.persistence.PersistenceException}. - * - * @see org.hibernate.engine.spi.ExceptionConverter - */ -public class ReactiveExceptionConverter extends ExceptionConverterImpl { - public ReactiveExceptionConverter(SharedSessionContractImplementor sharedSessionContract) { - super( sharedSessionContract ); - } - - @Override - public RuntimeException convert(RuntimeException e) { - if ( !( e instanceof HibernateException ) ) { - return super.convert( new HibernateException( e ) ); - } - return super.convert( e ); - } -} diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/impl/ReactiveSessionFactoryImpl.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/impl/ReactiveSessionFactoryImpl.java index f8029e297..58181a66d 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/impl/ReactiveSessionFactoryImpl.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/impl/ReactiveSessionFactoryImpl.java @@ -9,7 +9,6 @@ import org.hibernate.boot.spi.MetadataImplementor; import org.hibernate.boot.spi.SessionFactoryOptions; import org.hibernate.internal.SessionFactoryImpl; -import org.hibernate.query.spi.QueryEngine; import org.hibernate.reactive.boot.spi.ReactiveMetadataImplementor; import org.hibernate.reactive.mutiny.Mutiny; import org.hibernate.reactive.mutiny.impl.MutinySessionFactoryImpl; @@ -27,11 +26,6 @@ public ReactiveSessionFactoryImpl(MetadataImplementor bootMetamodel, SessionFact super( new ReactiveMetadataImplementor( bootMetamodel ), options, bootstrapContext ); } - @Override - public QueryEngine getQueryEngine() { - return super.getQueryEngine(); - } - @Override public T unwrap(Class type) { if ( type.isAssignableFrom( Stage.SessionFactory.class ) ) { diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/impl/ReactiveSessionImpl.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/impl/ReactiveSessionImpl.java index 93fc8c076..bfc29e32a 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/impl/ReactiveSessionImpl.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/impl/ReactiveSessionImpl.java @@ -37,7 +37,6 @@ import org.hibernate.engine.spi.EffectiveEntityGraph; import org.hibernate.engine.spi.EntityEntry; import org.hibernate.engine.spi.EntityKey; -import org.hibernate.engine.spi.ExceptionConverter; import org.hibernate.engine.spi.PersistenceContext; import org.hibernate.engine.spi.PersistentAttributeInterceptable; import org.hibernate.engine.spi.PersistentAttributeInterceptor; @@ -167,9 +166,6 @@ public class ReactiveSessionImpl extends SessionImpl implements ReactiveSession, private ReactiveConnection reactiveConnection; private final Thread associatedWorkThread; - //Lazily initialized - private transient ExceptionConverter exceptionConverter; - public ReactiveSessionImpl(SessionFactoryImpl delegate, SessionCreationOptions options, ReactiveConnection connection) { super( delegate, options ); InternalStateAssertions.assertUseOnEventLoop(); @@ -1128,14 +1124,6 @@ private CompletionStage doFlush() { } ); } - @Override - public ExceptionConverter getExceptionConverter() { - if ( exceptionConverter == null ) { - exceptionConverter = new ReactiveExceptionConverter( this ); - } - return exceptionConverter; - } - @Override public CompletionStage reactiveRefresh(Object entity, LockOptions lockOptions) { checkOpen(); diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/MutinySessionTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/MutinySessionTest.java index 6fecfbb85..c4443ce91 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/MutinySessionTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/MutinySessionTest.java @@ -10,7 +10,6 @@ import java.util.Objects; import java.util.concurrent.atomic.AtomicInteger; -import org.hibernate.HibernateException; import org.hibernate.LockMode; import org.hibernate.exception.ConstraintViolationException; import org.hibernate.reactive.mutiny.Mutiny; @@ -301,13 +300,10 @@ context, populateDB() .chain( () -> selectNameFromId( 5 ) ) .invoke( name -> assertThat( name ).isNotNull() ) .chain( this::openMutinySession ) - .chain( session -> assertThrown( - HibernateException.class, - session.remove( new GuineaPig( 5, "Aloi" ) ) - ) ) + .chain( session -> assertThrown( IllegalArgumentException.class, session + .remove( new GuineaPig( 5, "Aloi" ) ) ) ) .invoke( e -> assertThat( e ) - .hasMessageContaining( "unmanaged instance passed to remove" ) - ) + .hasMessageContaining( "Unmanaged instance passed to remove" ) ) ); } diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ReactiveSessionTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ReactiveSessionTest.java index d83cb64cd..64a7211d9 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ReactiveSessionTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ReactiveSessionTest.java @@ -10,7 +10,6 @@ import java.util.concurrent.CompletionException; import java.util.concurrent.CompletionStage; -import org.hibernate.HibernateException; import org.hibernate.LockMode; import org.hibernate.reactive.common.AffectedEntities; import org.hibernate.reactive.mutiny.Mutiny; @@ -725,11 +724,11 @@ public void reactiveRemoveTransientEntity(VertxTestContext context) { .thenCompose( v -> selectNameFromId( 5 ) ) .thenAccept( result -> assertThat( result ).isNotNull() ) .thenCompose( v -> openSession() ) - .thenCompose( session -> assertThrown( HibernateException.class, session.remove( new GuineaPig( 5, "Aloi" ) ) ) - ) + .thenCompose( session -> assertThrown( IllegalArgumentException.class, session + .remove( new GuineaPig( 5, "Aloi" ) ) ) ) .thenAccept( t -> assertThat( t ) - .hasCauseInstanceOf( IllegalArgumentException.class ) - .hasMessageContaining( "unmanaged instance" ) + .isInstanceOf( IllegalArgumentException.class ) + .hasMessageContaining( "Unmanaged instance" ) ) ); } diff --git a/integration-tests/hibernate-validator-postgres-it/src/test/java/org/hibernate/reactive/it/quarkus/qe/database/DatabaseHibernateReactiveTest.java b/integration-tests/hibernate-validator-postgres-it/src/test/java/org/hibernate/reactive/it/quarkus/qe/database/DatabaseHibernateReactiveTest.java index 1a4a6ec4c..1d6f000b9 100644 --- a/integration-tests/hibernate-validator-postgres-it/src/test/java/org/hibernate/reactive/it/quarkus/qe/database/DatabaseHibernateReactiveTest.java +++ b/integration-tests/hibernate-validator-postgres-it/src/test/java/org/hibernate/reactive/it/quarkus/qe/database/DatabaseHibernateReactiveTest.java @@ -10,7 +10,6 @@ import java.util.concurrent.TimeUnit; -import org.hibernate.HibernateException; import org.junit.jupiter.api.Test; @@ -43,14 +42,13 @@ public static Uni assertThrown(Class expectedExcepti @Test public void nameIsTooLong(VertxTestContext context) { - test( context, assertThrown( HibernateException.class, getMutinySessionFactory() + test( context, assertThrown( ConstraintViolationException.class, getMutinySessionFactory() .withTransaction( s -> { Author author = new Author(); author.setName( "A very long long long long name ... " ); return s.persist( author ); } ) ) - .invoke( he -> assertThat( he.getCause() ) - .isInstanceOf( ConstraintViolationException.class ) + .invoke( he -> assertThat( he ) .hasMessageContaining( "size must be between" ) ) ); @@ -58,14 +56,13 @@ public void nameIsTooLong(VertxTestContext context) { @Test public void nameIsNull(VertxTestContext context) { - test( context, assertThrown( HibernateException.class, getMutinySessionFactory() + test( context, assertThrown( ConstraintViolationException.class, getMutinySessionFactory() .withTransaction( s -> { Author author = new Author(); author.setName( null ); return s.persist( author ); } ) ) - .invoke( he -> assertThat( he.getCause() ) - .isInstanceOf( ConstraintViolationException.class ) + .invoke( he -> assertThat( he ) .hasMessageContaining( "must not be null" ) ) );