Skip to content

Commit 36240cc

Browse files
committed
[#1613] Minor clean up
1 parent e9404ec commit 36240cc

File tree

6 files changed

+23
-43
lines changed

6 files changed

+23
-43
lines changed

hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveCollectionLoader.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,17 @@
1313
import org.hibernate.loader.ast.spi.CollectionLoader;
1414
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
1515
import org.hibernate.reactive.logging.impl.Log;
16-
import org.hibernate.reactive.logging.impl.LoggerFactory;
1716

18-
public interface ReactiveCollectionLoader extends CollectionLoader {
17+
import static org.hibernate.reactive.logging.impl.LoggerFactory.make;
1918

20-
Log LOG = LoggerFactory.make( Log.class, MethodHandles.lookup() );
19+
public interface ReactiveCollectionLoader extends CollectionLoader {
2120

2221
@Override
2322
PluralAttributeMapping getLoadable();
2423

2524
@Override
2625
default PersistentCollection<?> load(Object key, SharedSessionContractImplementor session) {
27-
throw LOG.nonReactiveMethodCall( "reactiveLoad(Object, SharedSessionContractImplementor)" );
26+
throw make( Log.class, MethodHandles.lookup() ).nonReactiveMethodCall( "reactiveLoad(Object, SharedSessionContractImplementor)" );
2827
}
2928

3029
/**

hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/spi/ReactiveSingleIdEntityLoader.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99

1010
import org.hibernate.engine.spi.SharedSessionContractImplementor;
1111
import org.hibernate.loader.ast.spi.SingleIdEntityLoader;
12+
import org.hibernate.reactive.logging.impl.Log;
13+
14+
import static java.lang.invoke.MethodHandles.lookup;
15+
import static org.hibernate.reactive.logging.impl.LoggerFactory.make;
1216

1317
/**
1418
* Reactive version of {@link SingleIdEntityLoader}.
@@ -22,7 +26,7 @@ public interface ReactiveSingleIdEntityLoader<T> extends SingleIdEntityLoader<Co
2226
@Deprecated
2327
@Override
2428
default Object[] loadDatabaseSnapshot(Object id, SharedSessionContractImplementor session) {
25-
throw new UnsupportedOperationException("Use the reactive method: loadDatabaseSnapshot(Object, SharedSessionContractImplementor)");
29+
throw make( Log.class, lookup() ).nonReactiveMethodCall( "reactiveLoadDatabaseSnapshot" );
2630
}
2731

2832
CompletionStage<Object[]> reactiveLoadDatabaseSnapshot(Object id, SharedSessionContractImplementor session);

hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/collection/impl/ReactiveAbstractCollectionPersister.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
*/
2323
public interface ReactiveAbstractCollectionPersister extends ReactiveCollectionPersister {
2424

25-
Log LOG = LoggerFactory.make( Log.class, MethodHandles.lookup() );
26-
2725
default ReactiveConnection getReactiveConnection(SharedSessionContractImplementor session) {
2826
return ( (ReactiveConnectionSupplier) session ).getReactiveConnection();
2927
}

hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/collection/impl/ReactiveCollectionPersister.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,22 @@
1313
import org.hibernate.engine.spi.SharedSessionContractImplementor;
1414
import org.hibernate.persister.collection.CollectionPersister;
1515
import org.hibernate.reactive.logging.impl.Log;
16-
import org.hibernate.reactive.logging.impl.LoggerFactory;
16+
17+
import static org.hibernate.reactive.logging.impl.LoggerFactory.make;
1718

1819
/**
1920
* A reactive {@link CollectionPersister}
2021
*/
2122
public interface ReactiveCollectionPersister extends CollectionPersister {
2223

23-
Log LOG = LoggerFactory.make( Log.class, MethodHandles.lookup() );
24-
2524
/**
2625
* Reactive version of {@link CollectionPersister#recreate(PersistentCollection, Object, SharedSessionContractImplementor)}
2726
*/
2827
CompletionStage<Void> reactiveRecreate(PersistentCollection<?> collection, Object id, SharedSessionContractImplementor session);
2928

3029
@Override
3130
default void remove(Object id, SharedSessionContractImplementor session) {
32-
throw LOG.nonReactiveMethodCall( "reactiveRemove" );
31+
throw make( Log.class, MethodHandles.lookup() ).nonReactiveMethodCall( "reactiveRemove" );
3332
}
3433

3534
/**
@@ -39,7 +38,7 @@ default void remove(Object id, SharedSessionContractImplementor session) {
3938

4039
@Override
4140
default void deleteRows(PersistentCollection<?> collection, Object key, SharedSessionContractImplementor session) {
42-
throw LOG.nonReactiveMethodCall( "reactiveDeleteRows" );
41+
throw make( Log.class, MethodHandles.lookup() ).nonReactiveMethodCall( "reactiveDeleteRows" );
4342
}
4443

4544
/**
@@ -49,7 +48,7 @@ default void deleteRows(PersistentCollection<?> collection, Object key, SharedSe
4948

5049
@Override
5150
default void insertRows(PersistentCollection<?> collection, Object key, SharedSessionContractImplementor session) {
52-
throw LOG.nonReactiveMethodCall( "reactiveInsertRows" );
51+
throw make( Log.class, MethodHandles.lookup() ).nonReactiveMethodCall( "reactiveInsertRows" );
5352
}
5453

5554
/**
@@ -59,7 +58,7 @@ default void insertRows(PersistentCollection<?> collection, Object key, SharedSe
5958

6059
@Override
6160
default void updateRows(PersistentCollection<?> collection, Object key, SharedSessionContractImplementor session) {
62-
throw LOG.nonReactiveMethodCall( "reactiveUpdateRows" );
61+
throw make( Log.class, MethodHandles.lookup() ).nonReactiveMethodCall( "reactiveUpdateRows" );
6362
}
6463

6564
/**
@@ -69,7 +68,7 @@ default void updateRows(PersistentCollection<?> collection, Object key, SharedSe
6968

7069
@Override
7170
default void initialize(Object key, SharedSessionContractImplementor session) throws HibernateException {
72-
throw LOG.nonReactiveMethodCall( "reactiveInitialize" );
71+
throw make( Log.class, MethodHandles.lookup() ).nonReactiveMethodCall( "reactiveInitialize" );
7372
}
7473

7574
/**

hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/impl/ReactiveSessionImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,8 +1294,8 @@ private CompletionStage<Void> fireReactiveLoad(LoadEvent event, LoadEventListene
12941294
private CompletionStage<Void> fireLoadNoChecks(LoadEvent event, LoadEventListener.LoadType loadType) {
12951295
pulseTransactionCoordinator();
12961296

1297-
return fastSessionServices.eventListenerGroup_LOAD.fireEventOnEachListener( event, loadType,
1298-
(ReactiveLoadEventListener l) -> l::reactiveOnLoad
1297+
return fastSessionServices.eventListenerGroup_LOAD
1298+
.fireEventOnEachListener( event, loadType,(ReactiveLoadEventListener l) -> l::reactiveOnLoad
12991299
);
13001300
}
13011301

@@ -1721,7 +1721,7 @@ public ReactiveConnection getReactiveConnection() {
17211721

17221722
@Override
17231723
public void close() throws HibernateException {
1724-
throw new UnsupportedOperationException( "Non-reactive 'close()' method called. Use 'reactiveClose()' instead." );
1724+
throw LOG.nonReactiveMethodCall( "reactiveClose()" );
17251725
}
17261726

17271727
@Override

hibernate-reactive-core/src/test/java/org/hibernate/reactive/LazyOneToManyAssociationWithFetchTest.java

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
*/
66
package org.hibernate.reactive;
77

8-
import io.vertx.ext.unit.TestContext;
8+
import java.util.ArrayList;
9+
import java.util.Collection;
10+
import java.util.List;
11+
import java.util.Objects;
912

1013
import org.hibernate.Hibernate;
1114
import org.hibernate.annotations.FetchMode;
@@ -14,6 +17,7 @@
1417

1518
import org.junit.Test;
1619

20+
import io.vertx.ext.unit.TestContext;
1721
import jakarta.persistence.Entity;
1822
import jakarta.persistence.EntityGraph;
1923
import jakarta.persistence.FetchType;
@@ -24,37 +28,13 @@
2428
import jakarta.persistence.OneToMany;
2529
import jakarta.persistence.Table;
2630

27-
import java.util.ArrayList;
28-
import java.util.Collection;
29-
import java.util.List;
30-
import java.util.Objects;
31-
import java.util.concurrent.CompletionStage;
32-
33-
import static org.hibernate.reactive.util.impl.CompletionStages.loop;
34-
3531
public class LazyOneToManyAssociationWithFetchTest extends BaseReactiveTest {
3632

3733
@Override
3834
protected Collection<Class<?>> annotatedEntities() {
3935
return List.of( Author.class, Book.class );
4036
}
4137

42-
@Override
43-
public CompletionStage<Void> deleteEntities(Class<?>... entities) {
44-
return getSessionFactory()
45-
.withTransaction( s -> loop( entities, entityClass -> s
46-
.createQuery( "from " + entityName( entityClass ), entityClass )
47-
.getResultList()
48-
.thenCompose( list -> loop( list, entity -> s.remove( entity ) ) ) ) );
49-
}
50-
51-
private String entityName(Class<?> entityClass) {
52-
if ( Author.class.equals( entityClass ) ) {
53-
return "Writer";
54-
}
55-
return "Tome";
56-
}
57-
5838
@Test
5939
public void findBookWithFetchAuthors(TestContext context) {
6040
final Book goodOmens = new Book(

0 commit comments

Comments
 (0)