diff --git a/gradle.properties b/gradle.properties index 6b68188f8..65275802a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -29,18 +29,18 @@ org.gradle.java.installations.auto-download=false #db = MSSQL # Enable the SonatypeOS maven repository (mainly for Vert.x snapshots) when present (value ignored) -#enableSonatypeOpenSourceSnapshotsRep = true +enableSonatypeOpenSourceSnapshotsRep = true # Enable the maven local repository (for local development when needed) when present (value ignored) #enableMavenLocalRepo = true # Override default Hibernate ORM version -#hibernateOrmVersion = 6.2.3.Final +hibernateOrmVersion = 6.2.4-SNAPSHOT # 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 = 6.2.3.Final +hibernateOrmGradlePluginVersion = 6.2.3.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 diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/ReactiveActionQueue.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/ReactiveActionQueue.java index a8d55c2b3..608e627b8 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/ReactiveActionQueue.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/ReactiveActionQueue.java @@ -6,11 +6,9 @@ package org.hibernate.reactive.engine; import java.io.Serializable; -import java.lang.invoke.MethodHandles; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; -import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -23,7 +21,6 @@ import org.hibernate.AssertionFailure; import org.hibernate.HibernateException; import org.hibernate.PropertyValueException; -import org.hibernate.action.internal.AbstractEntityInsertAction; import org.hibernate.action.internal.BulkOperationCleanupAction; import org.hibernate.action.internal.EntityDeleteAction; import org.hibernate.action.internal.UnresolvedEntityInsertActions; @@ -32,11 +29,11 @@ import org.hibernate.action.spi.Executable; import org.hibernate.cache.CacheException; import org.hibernate.engine.spi.ActionQueue; +import org.hibernate.engine.spi.ComparableExecutable; import org.hibernate.engine.spi.EntityEntry; import org.hibernate.engine.spi.ExecutableList; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; -import org.hibernate.internal.util.collections.CollectionHelper; import org.hibernate.metadata.ClassMetadata; import org.hibernate.metamodel.spi.MappingMetamodelImplementor; import org.hibernate.proxy.HibernateProxy; @@ -47,13 +44,12 @@ import org.hibernate.reactive.engine.impl.ReactiveCollectionUpdateAction; import org.hibernate.reactive.engine.impl.ReactiveEntityActionVetoException; import org.hibernate.reactive.engine.impl.ReactiveEntityDeleteAction; -import org.hibernate.reactive.engine.impl.ReactiveEntityIdentityInsertAction; import org.hibernate.reactive.engine.impl.ReactiveEntityInsertAction; +import org.hibernate.reactive.engine.impl.ReactiveEntityInsertActionHolder; import org.hibernate.reactive.engine.impl.ReactiveEntityRegularInsertAction; import org.hibernate.reactive.engine.impl.ReactiveEntityUpdateAction; import org.hibernate.reactive.engine.impl.ReactiveOrphanRemovalAction; import org.hibernate.reactive.logging.impl.Log; -import org.hibernate.reactive.logging.impl.LoggerFactory; import org.hibernate.reactive.session.ReactiveSession; import org.hibernate.type.CollectionType; import org.hibernate.type.CompositeType; @@ -61,6 +57,8 @@ import org.hibernate.type.ForeignKeyDirection; import org.hibernate.type.Type; +import static java.lang.invoke.MethodHandles.lookup; +import static org.hibernate.reactive.logging.impl.LoggerFactory.make; import static org.hibernate.reactive.util.impl.CompletionStages.failedFuture; import static org.hibernate.reactive.util.impl.CompletionStages.loop; import static org.hibernate.reactive.util.impl.CompletionStages.voidFuture; @@ -71,121 +69,8 @@ */ public class ReactiveActionQueue { - private static final Log LOG = LoggerFactory.make( Log.class, MethodHandles.lookup() ); + private static final Log LOG = make( Log.class, lookup() ); - /** - * A LinkedHashMap containing providers for all the ExecutableLists, inserted in execution order - */ - private static final LinkedHashMap, ListProvider> EXECUTABLE_LISTS_MAP; - - static { - EXECUTABLE_LISTS_MAP = CollectionHelper.linkedMapOfSize( 8 ); - - EXECUTABLE_LISTS_MAP.put( - ReactiveOrphanRemovalAction.class, - new ListProvider() { - ExecutableList get(ReactiveActionQueue instance) { - return instance.orphanRemovals; - } - ExecutableList init(ReactiveActionQueue instance) { - // OrphanRemovalAction executables never require sorting. - return instance.orphanRemovals = new ExecutableList<>( false ); - } - } - ); - EXECUTABLE_LISTS_MAP.put( - ReactiveEntityInsertAction.class, - new ListProvider() { - ExecutableList get(ReactiveActionQueue instance) { - return instance.insertions; - } - - ExecutableList init(ReactiveActionQueue instance) { - instance.insertions = instance.isOrderInsertsEnabled() - ? new ExecutableList<>( new InsertActionSorter() ) - : new ExecutableList<>( false ); - return instance.insertions; - } - } - ); - EXECUTABLE_LISTS_MAP.put( - ReactiveEntityUpdateAction.class, - new ListProvider() { - ExecutableList get(ReactiveActionQueue instance) { - return instance.updates; - } - - ExecutableList init(ReactiveActionQueue instance) { - return instance.updates = new ExecutableList<>( instance.isOrderUpdatesEnabled() ); - } - } - ); - EXECUTABLE_LISTS_MAP.put( - QueuedOperationCollectionAction.class, - new ListProvider() { - ExecutableList get(ReactiveActionQueue instance) { - return instance.collectionQueuedOps; - } - ExecutableList init(ReactiveActionQueue instance) { - return instance.collectionQueuedOps = new ExecutableList<>( - instance.isOrderUpdatesEnabled() - ); - } - } - ); - EXECUTABLE_LISTS_MAP.put( - ReactiveCollectionRemoveAction.class, - new ListProvider() { - ExecutableList get(ReactiveActionQueue instance) { - return instance.collectionRemovals; - } - ExecutableList init(ReactiveActionQueue instance) { - return instance.collectionRemovals = new ExecutableList<>( - instance.isOrderUpdatesEnabled() - ); - } - } - ); - EXECUTABLE_LISTS_MAP.put( - ReactiveCollectionUpdateAction.class, - new ListProvider() { - ExecutableList get(ReactiveActionQueue instance) { - return instance.collectionUpdates; - } - ExecutableList init(ReactiveActionQueue instance) { - return instance.collectionUpdates = new ExecutableList<>( - instance.isOrderUpdatesEnabled() - ); - } - } - ); - EXECUTABLE_LISTS_MAP.put( - ReactiveCollectionRecreateAction.class, - new ListProvider() { - ExecutableList get(ReactiveActionQueue instance) { - return instance.collectionCreations; - } - ExecutableList init(ReactiveActionQueue instance) { - return instance.collectionCreations = new ExecutableList<>( - instance.isOrderUpdatesEnabled() - ); - } - } - ); - EXECUTABLE_LISTS_MAP.put( - ReactiveEntityDeleteAction.class, - new ListProvider() { - ExecutableList get(ReactiveActionQueue instance) { - return instance.deletions; - } - - ExecutableList init(ReactiveActionQueue instance) { - // EntityDeleteAction executables never require sorting. - return instance.deletions = new ExecutableList<>( false ); - } - } - ); - } // NOTE: ExecutableList fields must be instantiated via ListProvider#init or #getOrInit // to ensure that they are instantiated consistently. @@ -195,7 +80,7 @@ ExecutableList init(ReactiveActionQueue instance) { // Object insertions, updates, and deletions have list semantics because // they must happen in the right order to respect referential // integrity - private ExecutableList insertions; + private ExecutableList insertions; private ExecutableList deletions; private ExecutableList updates; // Actually the semantics of the next three are really "Bag" @@ -213,6 +98,116 @@ ExecutableList init(ReactiveActionQueue instance) { private AfterTransactionCompletionProcessQueue afterTransactionProcesses; private BeforeTransactionCompletionProcessQueue beforeTransactionProcesses; + //Extract this as a constant to perform efficient iterations: + //method values() otherwise allocates a new array on each invocation. + private static final ReactiveActionQueue.OrderedActions[] ORDERED_OPERATIONS = ReactiveActionQueue.OrderedActions.values(); + + //The order of these operations is very important + private enum OrderedActions { + CollectionRemoveAction { + @Override + public ExecutableList getActions(ReactiveActionQueue instance) { + return instance.collectionRemovals; + } + @Override + public void ensureInitialized(ReactiveActionQueue instance) { + if ( instance.collectionRemovals == null ) { + instance.collectionRemovals = new ExecutableList<>( instance.isOrderUpdatesEnabled() ); + } + } + }, + OrphanRemovalAction { + @Override + public ExecutableList getActions(ReactiveActionQueue instance) { + return instance.orphanRemovals; + } + @Override + public void ensureInitialized(ReactiveActionQueue instance) { + if ( instance.orphanRemovals == null ) { + instance.orphanRemovals = new ExecutableList<>( false ); + } + } + }, + EntityInsertAction { + @Override + public ExecutableList getActions(ReactiveActionQueue instance) { + return instance.insertions; + } + @Override + public void ensureInitialized(final ReactiveActionQueue instance) { + if ( instance.insertions == null ) { + //Special case of initialization + instance.insertions = instance.isOrderInsertsEnabled() + ? new ExecutableList<>( ReactiveActionQueue.InsertActionSorter.INSTANCE ) + : new ExecutableList<>( false ); + } + } + }, + EntityUpdateAction { + @Override + public ExecutableList getActions(ReactiveActionQueue instance) { + return instance.updates; + } + @Override + public void ensureInitialized(ReactiveActionQueue instance) { + if ( instance.updates == null ) { + instance.updates = new ExecutableList<>( instance.isOrderUpdatesEnabled() ); + } + } + }, + QueuedOperationCollectionAction { + @Override + public ExecutableList getActions(ReactiveActionQueue instance) { + return instance.collectionQueuedOps; + } + @Override + public void ensureInitialized(ReactiveActionQueue instance) { + if ( instance.collectionQueuedOps == null ) { + instance.collectionQueuedOps = new ExecutableList<>( instance.isOrderUpdatesEnabled() ); + } + } + }, + CollectionUpdateAction { + @Override + public ExecutableList getActions(ReactiveActionQueue instance) { + return instance.collectionUpdates; + } + @Override + public void ensureInitialized(ReactiveActionQueue instance) { + if ( instance.collectionUpdates == null ) { + instance.collectionUpdates = new ExecutableList<>( instance.isOrderUpdatesEnabled() ); + } + } + }, + CollectionRecreateAction { + @Override + public ExecutableList getActions(ReactiveActionQueue instance) { + return instance.collectionCreations; + } + @Override + public void ensureInitialized(ReactiveActionQueue instance) { + if ( instance.collectionCreations == null ) { + instance.collectionCreations = new ExecutableList<>( instance.isOrderUpdatesEnabled() ); + } + } + }, + EntityDeleteAction { + @Override + public ExecutableList getActions(ReactiveActionQueue instance) { + return instance.deletions; + } + @Override + public void ensureInitialized(ReactiveActionQueue instance) { + if ( instance.deletions == null ) { + instance.deletions = new ExecutableList<>( false ); + } + } + }; + + public abstract ExecutableList getActions(ReactiveActionQueue instance); + public abstract void ensureInitialized(ReactiveActionQueue instance); + } + /** * Constructs an action queue bound to the given session. * @@ -223,54 +218,11 @@ public ReactiveActionQueue(ReactiveSession session) { isTransactionCoordinatorShared = false; } - private static String[] convertTimestampSpaces(Serializable[] spaces) { - return (String[]) spaces; - } - - private static boolean areTablesToBeUpdated( - ExecutableList actions, - @SuppressWarnings("rawtypes") Set tableSpaces) { - if ( actions == null || actions.isEmpty() ) { - return false; - } - - for ( Serializable actionSpace : actions.getQuerySpaces() ) { - if ( tableSpaces.contains( actionSpace ) ) { - LOG.debugf( "Changes must be flushed to space: %s", actionSpace ); - return true; - } - } - - return false; - } - - private static boolean areTablesToBeUpdated( - UnresolvedEntityInsertActions actions, - @SuppressWarnings("rawtypes") Set tableSpaces) { - for ( Executable action : actions.getDependentEntityInsertActions() ) { - for ( Serializable space : action.getPropertySpaces() ) { - if ( tableSpaces.contains( space ) ) { - LOG.debugf( "Changes must be flushed to space: %s", space ); - return true; - } - } - } - return false; - } - - private static String[] convertTimestampSpaces(Set spaces) { - return spaces.toArray( new String[0] ); - } - - private static String toString(ExecutableList q) { - return q == null ? "ExecutableList{size=0}" : q.toString(); - } - public void clear() { - for ( ListProvider listProvider : EXECUTABLE_LISTS_MAP.values() ) { - ExecutableList l = listProvider.get( this ); - if ( l != null ) { - l.clear(); + for ( OrderedActions value : ORDERED_OPERATIONS ) { + final ExecutableList list = value.getActions( this ); + if ( list != null ) { + list.clear(); } } if ( unresolvedInsertions != null ) { @@ -278,27 +230,18 @@ public void clear() { } } + /** * Adds an entity (REGULAR) insert action * * @param action The action representing the entity insertion */ - public CompletionStage addAction(ReactiveEntityRegularInsertAction action) { + public CompletionStage addAction(ReactiveEntityInsertAction action) { LOG.tracev( "Adding a ReactiveEntityRegularInsertAction for [{0}] object", action.getEntityName() ); return addInsertAction( action ); } - /** - * Adds an entity (IDENTITY) insert action - * - * @param action The action representing the entity insertion - */ - public CompletionStage addAction(ReactiveEntityIdentityInsertAction action) { - LOG.tracev( "Adding a ReactiveEntityIdentityInsertAction for [{0}] object", action.getEntityName() ); - return addInsertAction( action ); - } - - private CompletionStage addInsertAction(D insert) { + private CompletionStage addInsertAction( ReactiveEntityInsertAction insert) { CompletionStage ret = voidFuture(); if ( insert.isEarlyInsert() ) { // For early inserts, must execute inserts before finding non-nullable transient entities. @@ -321,7 +264,7 @@ private Comp if ( unresolvedInsertions == null ) { unresolvedInsertions = new UnresolvedEntityInsertActions(); } - unresolvedInsertions.addUnresolvedEntityInsertAction( insert, nonNullables ); + unresolvedInsertions.addUnresolvedEntityInsertAction( insert.asAbstractEntityInsertAction(), nonNullables ); return voidFuture(); } } ); @@ -339,7 +282,8 @@ private CompletionStage addResolvedEntityInsertAction(ReactiveEntityInsert } else { LOG.trace( "Adding resolved non-early insert action." ); - addAction( ReactiveEntityInsertAction.class, insert ); + OrderedActions.EntityInsertAction.ensureInitialized( this ); + this.insertions.add( new ReactiveEntityInsertActionHolder( insert ) ); ret = voidFuture(); } @@ -357,19 +301,52 @@ private CompletionStage addResolvedEntityInsertAction(ReactiveEntityInsert } } else { - // FIXME: Add it to the Log interface throw new ReactiveEntityActionVetoException( "The ReactiveEntityInsertAction was vetoed.", insert ); } } ); } - private > void addAction(Class executableClass, T action) { - getExecutableList(executableClass).getOrInit( this ).add( action ); + private static String[] convertTimestampSpaces(Serializable[] spaces) { + return (String[]) spaces; } - @SuppressWarnings("unchecked") - private > ListProvider getExecutableList(Class executableClass) { - return (ListProvider) EXECUTABLE_LISTS_MAP.get( executableClass ); + private static boolean areTablesToBeUpdated( + ExecutableList actions, + @SuppressWarnings("rawtypes") Set tableSpaces) { + if ( actions == null || actions.isEmpty() ) { + return false; + } + + for ( Serializable actionSpace : actions.getQuerySpaces() ) { + if ( tableSpaces.contains( actionSpace ) ) { + LOG.debugf( "Changes must be flushed to space: %s", actionSpace ); + return true; + } + } + + return false; + } + + private static boolean areTablesToBeUpdated( + UnresolvedEntityInsertActions actions, + @SuppressWarnings("rawtypes") Set tableSpaces) { + for ( Executable action : actions.getDependentEntityInsertActions() ) { + for ( Serializable space : action.getPropertySpaces() ) { + if ( tableSpaces.contains( space ) ) { + LOG.debugf( "Changes must be flushed to space: %s", space ); + return true; + } + } + } + return false; + } + + private static String[] convertTimestampSpaces(Set spaces) { + return spaces.toArray( new String[0] ); + } + + private static String toString(ExecutableList q) { + return q == null ? "ExecutableList{size=0}" : q.toString(); } /** @@ -378,7 +355,8 @@ private > ListProvider g * @param action The action representing the entity deletion */ public void addAction(ReactiveEntityDeleteAction action) { - addAction( ReactiveEntityDeleteAction.class, action ); + OrderedActions.EntityDeleteAction.ensureInitialized( this ); + this.deletions.add( action ); } /** @@ -387,7 +365,8 @@ public void addAction(ReactiveEntityDeleteAction action) { * @param action The action representing the orphan removal */ public void addAction(ReactiveOrphanRemovalAction action) { - addAction( ReactiveOrphanRemovalAction.class, action ); + OrderedActions.OrphanRemovalAction.ensureInitialized( this ); + this.orphanRemovals.add( action ); } /** @@ -396,7 +375,8 @@ public void addAction(ReactiveOrphanRemovalAction action) { * @param action The action representing the entity update */ public void addAction(ReactiveEntityUpdateAction action) { - addAction( ReactiveEntityUpdateAction.class, action ); + OrderedActions.EntityUpdateAction.ensureInitialized( this ); + this.updates.add( action ); } /** @@ -405,7 +385,8 @@ public void addAction(ReactiveEntityUpdateAction action) { * @param action The action representing the (re)creation of a collection */ public void addAction(ReactiveCollectionRecreateAction action) { - addAction( ReactiveCollectionRecreateAction.class, action ); + OrderedActions.CollectionRecreateAction.ensureInitialized( this ); + this.collectionCreations.add( action ); } /** @@ -414,7 +395,8 @@ public void addAction(ReactiveCollectionRecreateAction action) { * @param action The action representing the removal of a collection */ public void addAction(ReactiveCollectionRemoveAction action) { - addAction( ReactiveCollectionRemoveAction.class, action ); + OrderedActions.CollectionRemoveAction.ensureInitialized( this ); + this.collectionRemovals.add( action ); } /** @@ -423,7 +405,8 @@ public void addAction(ReactiveCollectionRemoveAction action) { * @param action The action representing the update of a collection */ public void addAction(ReactiveCollectionUpdateAction action) { - addAction( ReactiveCollectionUpdateAction.class, action ); + OrderedActions.CollectionUpdateAction.ensureInitialized( this ); + this.collectionUpdates.add( action ); } /** @@ -432,7 +415,8 @@ public void addAction(ReactiveCollectionUpdateAction action) { * @param action The action representing the queued operation */ public void addAction(QueuedOperationCollectionAction action) { - addAction( QueuedOperationCollectionAction.class, action ); + OrderedActions.QueuedOperationCollectionAction.ensureInitialized( this ); + this.collectionQueuedOps.add( action ); } /** @@ -537,11 +521,9 @@ public CompletionStage executeActions() { } CompletionStage ret = voidFuture(); - for ( ListProvider listProvider : EXECUTABLE_LISTS_MAP.values() ) { - ExecutableList l = listProvider.get( this ); - if ( l != null && !l.isEmpty() ) { - ret = ret.thenCompose( v -> executeActions( l ) ); - } + + for ( OrderedActions action : ORDERED_OPERATIONS ) { + ret = ret.thenCompose( v -> executeActions( action.getActions( this ) ) ); } return ret; } @@ -618,9 +600,9 @@ public boolean areTablesToBeUpdated(@SuppressWarnings("rawtypes") Set tables) { if ( tables.isEmpty() ) { return false; } - for ( ListProvider listProvider : EXECUTABLE_LISTS_MAP.values() ) { - ExecutableList l = listProvider.get( this ); - if ( areTablesToBeUpdated( l, tables ) ) { + for ( OrderedActions action : ORDERED_OPERATIONS ) { + final ExecutableList list = action.getActions( this ); + if ( areTablesToBeUpdated( list, tables ) ) { return true; } } @@ -637,6 +619,9 @@ public boolean areTablesToBeUpdated(@SuppressWarnings("rawtypes") Set tables) { */ private CompletionStage executeActions( ExecutableList list) throws HibernateException { + if ( list == null || list.isEmpty() ) { + return voidFuture(); + } // todo : consider ways to improve the double iteration of Executables here: // 1) we explicitly iterate list here to perform Executable#execute() // 2) ExecutableList#getQuerySpaces also iterates the Executables to collect query spaces. @@ -1033,13 +1018,13 @@ public CompletionStage afterTransactionCompletion(boolean success) { * * @author Jay Erb */ - private static class InsertActionSorter implements ExecutableList.Sorter { + private static class InsertActionSorter implements ExecutableList.Sorter { /** * Singleton access */ public static final InsertActionSorter INSTANCE = new InsertActionSorter(); // the map of batch numbers to EntityInsertAction lists - private Map> actionBatches; + private Map> actionBatches; public InsertActionSorter() { } @@ -1047,20 +1032,22 @@ public InsertActionSorter() { /** * Sort the insert actions. */ - public void sort(List insertions) { + @Override + public void sort(List insertions) { // optimize the hash size to eliminate a rehash. this.actionBatches = new HashMap<>(); // the mapping of entity names to their latest batch numbers. final List latestBatches = new ArrayList<>(); - for ( ReactiveEntityInsertAction action : insertions ) { + for ( ReactiveEntityInsertActionHolder action : insertions ) { + final ReactiveEntityInsertAction actionDelegate = action.getDelegate(); BatchIdentifier batchIdentifier = new BatchIdentifier( - action.getEntityName(), - action.getSession() + actionDelegate.getEntityName(), + actionDelegate.getSession() .getFactory() .getMetamodel() - .entityPersister( action.getEntityName() ) + .entityPersister( actionDelegate.getEntityName() ) .getRootEntityName() ); @@ -1072,8 +1059,8 @@ public void sort(List insertions) { else { latestBatches.add( batchIdentifier ); } - addParentChildEntityNames( action, batchIdentifier ); - addToBatch( batchIdentifier, action ); + addParentChildEntityNames( actionDelegate, batchIdentifier ); + addToBatch( batchIdentifier, actionDelegate ); } insertions.clear(); @@ -1250,10 +1237,10 @@ else if ( type.isComponentType() && value != null ) { } private void addToBatch(BatchIdentifier batchIdentifier, ReactiveEntityInsertAction action) { - List actions = actionBatches + List actions = actionBatches .computeIfAbsent( batchIdentifier, k -> new LinkedList<>() ); - actions.add( action ); + actions.add( new ReactiveEntityInsertActionHolder( action ) ); } private static class BatchIdentifier { @@ -1347,17 +1334,4 @@ private boolean hasParent(BatchIdentifier batchIdentifier, List } - private abstract static class ListProvider & Serializable> { - abstract ExecutableList get(ReactiveActionQueue instance); - - abstract ExecutableList init(ReactiveActionQueue instance); - - ExecutableList getOrInit(ReactiveActionQueue instance) { - ExecutableList list = get( instance ); - if ( list == null ) { - list = init( instance ); - } - return list; - } - } } diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/ReactiveEntityIdentityInsertAction.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/ReactiveEntityIdentityInsertAction.java index 357128db8..7ad13ddce 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/ReactiveEntityIdentityInsertAction.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/ReactiveEntityIdentityInsertAction.java @@ -8,6 +8,7 @@ import java.util.concurrent.CompletionStage; import org.hibernate.HibernateException; +import org.hibernate.action.internal.AbstractEntityInsertAction; import org.hibernate.action.internal.EntityIdentityInsertAction; import org.hibernate.engine.spi.EntityKey; import org.hibernate.engine.spi.PersistenceContext; @@ -109,6 +110,11 @@ public EntityKey getEntityKey() { return super.getEntityKey(); } + @Override + public AbstractEntityInsertAction asAbstractEntityInsertAction() { + return this; + } + @Override protected void markExecuted() { super.markExecuted(); diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/ReactiveEntityInsertAction.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/ReactiveEntityInsertAction.java index 318b77715..ef48ba006 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/ReactiveEntityInsertAction.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/ReactiveEntityInsertAction.java @@ -8,10 +8,11 @@ import java.util.concurrent.CompletionStage; import org.hibernate.LockMode; -import org.hibernate.action.internal.ComparableEntityAction; +import org.hibernate.action.internal.AbstractEntityInsertAction; import org.hibernate.engine.internal.NonNullableTransientDependencies; import org.hibernate.engine.internal.Nullability; import org.hibernate.engine.internal.Versioning; +import org.hibernate.engine.spi.ComparableExecutable; import org.hibernate.engine.spi.EntityKey; import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; @@ -28,7 +29,7 @@ * * @see org.hibernate.action.internal.AbstractEntityInsertAction */ -public interface ReactiveEntityInsertAction extends ReactiveExecutable, ComparableEntityAction { +public interface ReactiveEntityInsertAction extends ReactiveExecutable, ComparableExecutable { boolean isEarlyInsert(); NonNullableTransientDependencies findNonNullableTransientEntities(); SharedSessionContractImplementor getSession(); @@ -94,4 +95,11 @@ default CompletionStage reactiveMakeEntityManaged() { default CompletionStage reactiveFindNonNullableTransientEntities() { return ForeignKeys.findNonNullableTransientEntities( getPersister().getEntityName(), getInstance(), getState(), isEarlyInsert(), getSession() ); } + + AbstractEntityInsertAction asAbstractEntityInsertAction(); + + default int compareActionTo(ReactiveEntityInsertAction delegate) { + return asAbstractEntityInsertAction().compareTo( delegate.asAbstractEntityInsertAction() ); + } + } diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/ReactiveEntityInsertActionHolder.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/ReactiveEntityInsertActionHolder.java new file mode 100644 index 000000000..9cfff7f3b --- /dev/null +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/ReactiveEntityInsertActionHolder.java @@ -0,0 +1,83 @@ +/* Hibernate, Relational Persistence for Idiomatic Java + * + * SPDX-License-Identifier: Apache-2.0 + * Copyright: Red Hat Inc. and Hibernate Authors + */ +package org.hibernate.reactive.engine.impl; + +import java.io.Serializable; +import java.util.Objects; +import java.util.concurrent.CompletionStage; + +import org.hibernate.HibernateException; +import org.hibernate.action.spi.AfterTransactionCompletionProcess; +import org.hibernate.action.spi.BeforeTransactionCompletionProcess; +import org.hibernate.action.spi.Executable; +import org.hibernate.engine.spi.ComparableExecutable; +import org.hibernate.event.spi.EventSource; +import org.hibernate.reactive.engine.ReactiveExecutable; + +public final class ReactiveEntityInsertActionHolder implements Executable, ReactiveExecutable, ComparableExecutable, + Serializable { + + private final ReactiveEntityInsertAction delegate; + + public ReactiveEntityInsertActionHolder(ReactiveEntityInsertAction delegate) { + Objects.requireNonNull( delegate ); + this.delegate = delegate; + } + + @Override + public Serializable[] getPropertySpaces() { + return delegate.getPropertySpaces(); + } + + @Override + public void beforeExecutions() throws HibernateException { + delegate.beforeExecutions(); + } + + @Override + public void execute() throws HibernateException { + delegate.execute(); + } + + @Override + public AfterTransactionCompletionProcess getAfterTransactionCompletionProcess() { + return delegate.getAfterTransactionCompletionProcess(); + } + + @Override + public BeforeTransactionCompletionProcess getBeforeTransactionCompletionProcess() { + return delegate.getBeforeTransactionCompletionProcess(); + } + + @Override + public void afterDeserialize(EventSource session) { + delegate.afterDeserialize( session ); + } + + @Override + public CompletionStage reactiveExecute() { + return delegate.reactiveExecute(); + } + + public ReactiveEntityInsertAction getDelegate() { + return delegate; + } + + @Override + public String getPrimarySortClassifier() { + return delegate.getPrimarySortClassifier(); + } + + @Override + public Object getSecondarySortIndex() { + return delegate.getSecondarySortIndex(); + } + + @Override + public int compareTo(final ComparableExecutable o) { + return delegate.compareTo( o ); + } +} diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/ReactiveEntityRegularInsertAction.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/ReactiveEntityRegularInsertAction.java index f113fef89..0e2045521 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/ReactiveEntityRegularInsertAction.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/ReactiveEntityRegularInsertAction.java @@ -9,6 +9,7 @@ import org.hibernate.AssertionFailure; import org.hibernate.HibernateException; +import org.hibernate.action.internal.AbstractEntityInsertAction; import org.hibernate.action.internal.EntityInsertAction; import org.hibernate.cache.spi.access.EntityDataAccess; import org.hibernate.cache.spi.entry.CacheEntry; @@ -150,6 +151,11 @@ public EntityKey getEntityKey() { return super.getEntityKey(); } + @Override + public AbstractEntityInsertAction asAbstractEntityInsertAction() { + return this; + } + @Override protected void markExecuted() { super.markExecuted(); diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/DatabaseSnapshotExecutor.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/DatabaseSnapshotExecutor.java index 625a64d25..077c62c97 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/DatabaseSnapshotExecutor.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/DatabaseSnapshotExecutor.java @@ -40,6 +40,7 @@ import org.hibernate.sql.exec.internal.JdbcParameterImpl; import org.hibernate.sql.exec.spi.JdbcOperationQuerySelect; import org.hibernate.sql.exec.spi.JdbcParameterBindings; +import org.hibernate.sql.exec.spi.JdbcParametersList; import org.hibernate.sql.results.graph.DomainResult; import org.hibernate.sql.results.graph.FetchParent; import org.hibernate.sql.results.graph.internal.ImmutableFetchList; @@ -57,15 +58,14 @@ class DatabaseSnapshotExecutor { private final EntityMappingType entityDescriptor; private final JdbcOperationQuerySelect jdbcSelect; - private final List jdbcParameters; + private final JdbcParametersList jdbcParameters; DatabaseSnapshotExecutor( EntityMappingType entityDescriptor, SessionFactoryImplementor sessionFactory) { this.entityDescriptor = entityDescriptor; - this.jdbcParameters = new ArrayList<>( - entityDescriptor.getIdentifierMapping().getJdbcTypeCount() - ); + JdbcParametersList.Builder jdbcParametersBuilder = JdbcParametersList.newBuilder( + entityDescriptor.getIdentifierMapping().getJdbcTypeCount() ); final QuerySpec rootQuerySpec = new QuerySpec( true ); @@ -118,7 +118,7 @@ class DatabaseSnapshotExecutor { ); final JdbcParameter jdbcParameter = new JdbcParameterImpl( selection.getJdbcMapping() ); - jdbcParameters.add( jdbcParameter ); + jdbcParametersBuilder.add( jdbcParameter ); final ColumnReference columnReference = (ColumnReference) sqlExpressionResolver .resolveSqlExpression( tableReference, selection ); @@ -132,7 +132,7 @@ class DatabaseSnapshotExecutor { ); } ); - + this.jdbcParameters = jdbcParametersBuilder.build(); entityDescriptor.forEachAttributeMapping( attributeMapping -> { diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveCollectionBatchLoaderArrayParam.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveCollectionBatchLoaderArrayParam.java index 6d4a7bcf2..4185d3646 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveCollectionBatchLoaderArrayParam.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveCollectionBatchLoaderArrayParam.java @@ -6,7 +6,6 @@ package org.hibernate.reactive.loader.ast.internal; import java.lang.reflect.Array; -import java.util.Collections; import java.util.concurrent.CompletionStage; import org.hibernate.LockOptions; @@ -33,6 +32,7 @@ import org.hibernate.sql.exec.internal.JdbcParameterImpl; import org.hibernate.sql.exec.spi.JdbcOperationQuerySelect; import org.hibernate.sql.exec.spi.JdbcParameterBindings; +import org.hibernate.sql.exec.spi.JdbcParametersList; import org.hibernate.sql.results.internal.RowTransformerStandardImpl; import org.hibernate.type.BasicType; @@ -145,7 +145,7 @@ private CompletionStage initializeKeys(Object[] keysToInitialize, SharedSe final SubselectFetch.RegistrationHandler subSelectFetchableKeysHandler = SubselectFetch.createRegistrationHandler( session.getPersistenceContext().getBatchFetchQueue(), sqlSelect, - Collections.singletonList( jdbcParameter ), + JdbcParametersList.singleton( jdbcParameter ), jdbcParameterBindings ); diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveCollectionBatchLoaderInPredicate.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveCollectionBatchLoaderInPredicate.java index 8d0aac6c9..92a995620 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveCollectionBatchLoaderInPredicate.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveCollectionBatchLoaderInPredicate.java @@ -6,7 +6,6 @@ package org.hibernate.reactive.loader.ast.internal; import java.util.ArrayList; -import java.util.List; import java.util.concurrent.CompletionStage; import org.hibernate.LockOptions; @@ -22,10 +21,10 @@ import org.hibernate.loader.ast.internal.LoaderSelectBuilder; import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.query.spi.QueryOptions; -import org.hibernate.sql.ast.tree.expression.JdbcParameter; import org.hibernate.sql.ast.tree.select.SelectStatement; import org.hibernate.sql.exec.spi.JdbcOperationQuerySelect; import org.hibernate.sql.exec.spi.JdbcParameterBindings; +import org.hibernate.sql.exec.spi.JdbcParametersList; import static org.hibernate.loader.ast.internal.MultiKeyLoadLogging.MULTI_KEY_LOAD_DEBUG_ENABLED; import static org.hibernate.loader.ast.internal.MultiKeyLoadLogging.MULTI_KEY_LOAD_LOGGER; @@ -37,7 +36,7 @@ public class ReactiveCollectionBatchLoaderInPredicate extends ReactiveAbstractCo private final int keyColumnCount; private final int sqlBatchSize; - private final List jdbcParameters; + private final JdbcParametersList jdbcParameters; private final SelectStatement sqlAst; private final JdbcOperationQuerySelect jdbcSelect; @@ -64,7 +63,7 @@ public ReactiveCollectionBatchLoaderInPredicate( ); } - this.jdbcParameters = new ArrayList<>(); + final JdbcParametersList.Builder jdbcParametersBuilder = JdbcParametersList.newBuilder(); this.sqlAst = LoaderSelectBuilder.createSelect( attributeMapping, null, @@ -73,9 +72,10 @@ public ReactiveCollectionBatchLoaderInPredicate( sqlBatchSize, influencers, LockOptions.NONE, - jdbcParameters::add, + jdbcParametersBuilder::add, sessionFactory ); + this.jdbcParameters = jdbcParametersBuilder.build(); assert this.jdbcParameters.size() == this.sqlBatchSize * this.keyColumnCount; this.jdbcSelect = sessionFactory.getJdbcServices() diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveCollectionLoaderSingleKey.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveCollectionLoaderSingleKey.java index d6495cc24..8606f6b65 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveCollectionLoaderSingleKey.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveCollectionLoaderSingleKey.java @@ -5,8 +5,6 @@ */ package org.hibernate.reactive.loader.ast.internal; -import java.util.ArrayList; -import java.util.List; import java.util.concurrent.CompletionStage; import org.hibernate.LockOptions; @@ -27,12 +25,12 @@ import org.hibernate.reactive.sql.exec.internal.StandardReactiveSelectExecutor; import org.hibernate.reactive.sql.results.spi.ReactiveListResultsConsumer; import org.hibernate.sql.ast.SqlAstTranslatorFactory; -import org.hibernate.sql.ast.tree.expression.JdbcParameter; import org.hibernate.sql.ast.tree.select.SelectStatement; import org.hibernate.sql.exec.internal.BaseExecutionContext; import org.hibernate.sql.exec.internal.JdbcParameterBindingsImpl; import org.hibernate.sql.exec.spi.JdbcOperationQuerySelect; import org.hibernate.sql.exec.spi.JdbcParameterBindings; +import org.hibernate.sql.exec.spi.JdbcParametersList; import org.hibernate.sql.results.graph.entity.LoadingEntityEntry; import org.hibernate.sql.results.internal.RowTransformerStandardImpl; @@ -46,14 +44,14 @@ public class ReactiveCollectionLoaderSingleKey implements ReactiveCollectionLoad private final int keyJdbcCount; private final SelectStatement sqlAst; - private final List jdbcParameters; + private final JdbcParametersList jdbcParameters; public ReactiveCollectionLoaderSingleKey(PluralAttributeMapping attributeMapping, LoadQueryInfluencers influencers, SessionFactoryImplementor sessionFactory) { // PluralAttributeMappingImpl is the only implementation available at the moment in ORM final PluralAttributeMapping reactivePluralAttributeMapping = new ReactivePluralAttributeMapping( (PluralAttributeMappingImpl) attributeMapping ); this.attributeMapping = reactivePluralAttributeMapping; this.keyJdbcCount = reactivePluralAttributeMapping.getKeyDescriptor().getJdbcTypeCount(); - this.jdbcParameters = new ArrayList<>(); + final JdbcParametersList.Builder jdbcParametersBuilder = JdbcParametersList.newBuilder(); this.sqlAst = LoaderSelectBuilder.createSelect( reactivePluralAttributeMapping, null, @@ -62,9 +60,10 @@ public ReactiveCollectionLoaderSingleKey(PluralAttributeMapping attributeMapping 1, influencers, LockOptions.NONE, - jdbcParameters::add, + jdbcParametersBuilder::add, sessionFactory ); + this.jdbcParameters = jdbcParametersBuilder.build(); } @Override @@ -80,7 +79,7 @@ public SelectStatement getSqlAst() { return sqlAst; } - public List getJdbcParameters() { + public JdbcParametersList getJdbcParameters() { return jdbcParameters; } diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveEntityBatchLoaderInPredicate.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveEntityBatchLoaderInPredicate.java index 1570faf90..0a403a174 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveEntityBatchLoaderInPredicate.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveEntityBatchLoaderInPredicate.java @@ -24,10 +24,10 @@ import org.hibernate.metamodel.mapping.EntityIdentifierMapping; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.query.spi.QueryOptions; -import org.hibernate.sql.ast.tree.expression.JdbcParameter; import org.hibernate.sql.ast.tree.select.SelectStatement; import org.hibernate.sql.exec.spi.JdbcOperationQuerySelect; import org.hibernate.sql.exec.spi.JdbcParameterBindings; +import org.hibernate.sql.exec.spi.JdbcParametersList; import static org.hibernate.internal.util.collections.CollectionHelper.arrayList; import static org.hibernate.loader.ast.internal.MultiKeyLoadLogging.MULTI_KEY_LOAD_DEBUG_ENABLED; @@ -42,7 +42,7 @@ public class ReactiveEntityBatchLoaderInPredicate extends ReactiveSingleIdEnt private final int domainBatchSize; private final int sqlBatchSize; - private List jdbcParameters; + private JdbcParametersList jdbcParameters; private SelectStatement sqlAst; private JdbcOperationQuerySelect jdbcSelectOperation; @@ -185,7 +185,7 @@ public void prepare() { final int expectedNumberOfParameters = identifierMapping.getJdbcTypeCount() * sqlBatchSize; - jdbcParameters = arrayList( expectedNumberOfParameters ); + final JdbcParametersList.Builder parametersListBuilder = JdbcParametersList.newBuilder( expectedNumberOfParameters ); sqlAst = LoaderSelectBuilder.createSelect( getLoadable(), // null here means to select everything @@ -195,9 +195,10 @@ public void prepare() { sqlBatchSize, LoadQueryInfluencers.NONE, LockOptions.NONE, - jdbcParameters::add, + parametersListBuilder::add, sessionFactory ); + final JdbcParametersList jdbcParameters = parametersListBuilder.build(); assert jdbcParameters.size() == expectedNumberOfParameters; jdbcSelectOperation = sessionFactory.getJdbcServices() diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveLoaderHelper.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveLoaderHelper.java index 7142ad83f..44c90bfdf 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveLoaderHelper.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveLoaderHelper.java @@ -6,7 +6,6 @@ package org.hibernate.reactive.loader.ast.internal; import java.lang.reflect.Array; -import java.util.Collections; import java.util.List; import java.util.concurrent.CompletionStage; @@ -22,6 +21,7 @@ import org.hibernate.sql.exec.internal.JdbcParameterBindingsImpl; import org.hibernate.sql.exec.spi.JdbcOperationQuerySelect; import org.hibernate.sql.exec.spi.JdbcParameterBindings; +import org.hibernate.sql.exec.spi.JdbcParametersList; import org.hibernate.sql.results.internal.RowTransformerStandardImpl; import static java.util.Objects.requireNonNull; @@ -73,7 +73,7 @@ public static CompletionStage> loadByArrayParameter( final SubselectFetch.RegistrationHandler subSelectFetchableKeysHandler = SubselectFetch.createRegistrationHandler( session.getPersistenceContext().getBatchFetchQueue(), sqlAst, - Collections.singletonList( jdbcParameter ), + JdbcParametersList.singleton( jdbcParameter ), jdbcParameterBindings ); diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveMultiIdEntityLoaderArrayParam.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveMultiIdEntityLoaderArrayParam.java index 5b06f5508..b37a780fd 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveMultiIdEntityLoaderArrayParam.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveMultiIdEntityLoaderArrayParam.java @@ -8,7 +8,6 @@ import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.List; import java.util.concurrent.CompletionStage; @@ -44,6 +43,7 @@ import org.hibernate.sql.exec.internal.JdbcParameterImpl; import org.hibernate.sql.exec.spi.JdbcOperationQuerySelect; import org.hibernate.sql.exec.spi.JdbcParameterBindings; +import org.hibernate.sql.exec.spi.JdbcParametersList; import org.hibernate.sql.results.internal.RowTransformerStandardImpl; import org.hibernate.type.BasicType; import org.hibernate.type.BasicTypeRegistry; @@ -189,7 +189,7 @@ protected CompletionStage> performOrderedMultiLoad( final SubselectFetch.RegistrationHandler subSelectFetchableKeysHandler = SubselectFetch.createRegistrationHandler( batchFetchQueue, sqlAst, - Collections.singletonList( jdbcParameter ), + JdbcParametersList.singleton( jdbcParameter ), jdbcParameterBindings ); diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveMultiIdEntityLoaderStandard.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveMultiIdEntityLoaderStandard.java index 06bef4c56..9a87f2359 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveMultiIdEntityLoaderStandard.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveMultiIdEntityLoaderStandard.java @@ -43,11 +43,11 @@ import org.hibernate.reactive.sql.results.spi.ReactiveListResultsConsumer; import org.hibernate.reactive.util.impl.CompletionStages; import org.hibernate.sql.ast.SqlAstTranslatorFactory; -import org.hibernate.sql.ast.tree.expression.JdbcParameter; import org.hibernate.sql.ast.tree.select.SelectStatement; import org.hibernate.sql.exec.internal.JdbcParameterBindingsImpl; import org.hibernate.sql.exec.spi.JdbcOperationQuerySelect; import org.hibernate.sql.exec.spi.JdbcParameterBindings; +import org.hibernate.sql.exec.spi.JdbcParametersList; import org.hibernate.sql.results.internal.RowTransformerStandardImpl; import static org.hibernate.reactive.util.impl.CompletionStages.completedFuture; @@ -221,8 +221,7 @@ private CompletionStage> loadEntitiesById( LOG.tracef( "#loadEntitiesById(`%s`, `%s`, ..)", getEntityDescriptor().getEntityName(), numberOfIdsInBatch ); } - final List jdbcParameters = new ArrayList<>( numberOfIdsInBatch * idJdbcTypeCount ); - + final JdbcParametersList.Builder jdbcParametersListBuilder = JdbcParametersList.newBuilder( numberOfIdsInBatch * idJdbcTypeCount ); final SelectStatement sqlAst = LoaderSelectBuilder.createSelect( getLoadable(), // null here means to select everything @@ -232,9 +231,10 @@ private CompletionStage> loadEntitiesById( numberOfIdsInBatch, session.getLoadQueryInfluencers(), lockOptions, - jdbcParameters::add, + jdbcParametersListBuilder::add, getSessionFactory() ); + final JdbcParametersList jdbcParameters = jdbcParametersListBuilder.build(); final JdbcServices jdbcServices = getSessionFactory().getJdbcServices(); final JdbcEnvironment jdbcEnvironment = jdbcServices.getJdbcEnvironment(); diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveMultiKeyLoadChunker.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveMultiKeyLoadChunker.java index 90b6b410f..e5ec58e5d 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveMultiKeyLoadChunker.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveMultiKeyLoadChunker.java @@ -5,19 +5,18 @@ */ package org.hibernate.reactive.loader.ast.internal; -import java.util.List; import java.util.concurrent.CompletionStage; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.metamodel.mapping.Bindable; import org.hibernate.reactive.sql.exec.internal.StandardReactiveSelectExecutor; import org.hibernate.reactive.sql.results.spi.ReactiveListResultsConsumer; -import org.hibernate.sql.ast.tree.expression.JdbcParameter; import org.hibernate.sql.ast.tree.select.SelectStatement; import org.hibernate.sql.exec.internal.JdbcParameterBindingsImpl; import org.hibernate.sql.exec.spi.ExecutionContext; import org.hibernate.sql.exec.spi.JdbcOperationQuerySelect; import org.hibernate.sql.exec.spi.JdbcParameterBindings; +import org.hibernate.sql.exec.spi.JdbcParametersList; import org.hibernate.sql.results.internal.RowTransformerStandardImpl; import static org.hibernate.reactive.util.impl.CompletionStages.voidFuture; @@ -53,7 +52,7 @@ interface ChunkBoundaryListener { private final int keyColumnCount; private final Bindable bindable; - private final List jdbcParameters; + private final JdbcParametersList jdbcParameters; private final SelectStatement sqlAst; private final JdbcOperationQuerySelect jdbcSelect; @@ -61,7 +60,7 @@ public ReactiveMultiKeyLoadChunker( int chunkSize, int keyColumnCount, Bindable bindable, - List jdbcParameters, + JdbcParametersList jdbcParameters, SelectStatement sqlAst, JdbcOperationQuerySelect jdbcSelect) { this.chunkSize = chunkSize; diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveNaturalIdLoaderDelegate.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveNaturalIdLoaderDelegate.java index 0619efa9a..8c11c087c 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveNaturalIdLoaderDelegate.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveNaturalIdLoaderDelegate.java @@ -5,8 +5,6 @@ */ package org.hibernate.reactive.loader.ast.internal; -import java.util.ArrayList; -import java.util.List; import java.util.concurrent.CompletionStage; import java.util.function.BiConsumer; import java.util.function.BiFunction; @@ -36,7 +34,6 @@ import org.hibernate.sql.ast.SqlAstTranslatorFactory; import org.hibernate.sql.ast.spi.SimpleFromClauseAccessImpl; import org.hibernate.sql.ast.spi.SqlAliasBaseManager; -import org.hibernate.sql.ast.tree.expression.JdbcParameter; import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.select.QuerySpec; import org.hibernate.sql.ast.tree.select.SelectStatement; @@ -46,6 +43,7 @@ import org.hibernate.sql.exec.spi.Callback; import org.hibernate.sql.exec.spi.JdbcOperationQuerySelect; import org.hibernate.sql.exec.spi.JdbcParameterBindings; +import org.hibernate.sql.exec.spi.JdbcParametersList; import org.hibernate.sql.results.graph.DomainResult; import org.hibernate.sql.results.graph.Fetch; import org.hibernate.sql.results.graph.FetchParent; @@ -148,7 +146,7 @@ public CompletionStage resolveNaturalIdToId( public CompletionStage resolveIdToNaturalId(Object id, SharedSessionContractImplementor session) { final SessionFactoryImplementor sessionFactory = session.getFactory(); - final List jdbcParameters = new ArrayList<>(); + final JdbcParametersList.Builder jdbcParametersListBuilder = JdbcParametersList.newBuilder(); final SelectStatement sqlSelect = LoaderSelectBuilder.createSelect( entityDescriptor(), singletonList( naturalIdMapping() ), @@ -157,9 +155,10 @@ public CompletionStage resolveIdToNaturalId(Object id, SharedSessionCont 1, session.getLoadQueryInfluencers(), LockOptions.NONE, - jdbcParameters::add, + jdbcParametersListBuilder::add, sessionFactory ); + final JdbcParametersList jdbcParameters = jdbcParametersListBuilder.build(); final JdbcServices jdbcServices = sessionFactory.getJdbcServices(); final JdbcEnvironment jdbcEnvironment = jdbcServices.getJdbcEnvironment(); diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveSingleIdArrayLoadPlan.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveSingleIdArrayLoadPlan.java index 8d991518b..b8335cd94 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveSingleIdArrayLoadPlan.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveSingleIdArrayLoadPlan.java @@ -5,14 +5,13 @@ */ package org.hibernate.reactive.loader.ast.internal; -import java.util.List; import java.util.concurrent.CompletionStage; import org.hibernate.LockOptions; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.metamodel.mapping.ModelPart; -import org.hibernate.sql.ast.tree.expression.JdbcParameter; import org.hibernate.sql.ast.tree.select.SelectStatement; +import org.hibernate.sql.exec.spi.JdbcParametersList; import org.hibernate.sql.results.internal.RowTransformerDatabaseSnapshotImpl; import org.hibernate.sql.results.spi.RowTransformer; @@ -24,7 +23,7 @@ public class ReactiveSingleIdArrayLoadPlan extends ReactiveSingleIdLoadPlan jdbcParameters, + JdbcParametersList jdbcParameters, LockOptions lockOptions, SessionFactoryImplementor sessionFactory) { super( null, restrictivePart, sqlAst, jdbcParameters, lockOptions, sessionFactory ); diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveSingleIdEntityLoaderStandardImpl.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveSingleIdEntityLoaderStandardImpl.java index 9dc5a302e..9f2f1d3b2 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveSingleIdEntityLoaderStandardImpl.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveSingleIdEntityLoaderStandardImpl.java @@ -5,9 +5,7 @@ */ package org.hibernate.reactive.loader.ast.internal; -import java.util.ArrayList; import java.util.EnumMap; -import java.util.List; import java.util.concurrent.CompletionStage; import java.util.concurrent.atomic.AtomicInteger; @@ -23,8 +21,8 @@ import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.persister.entity.Loadable; import org.hibernate.reactive.loader.ast.spi.ReactiveSingleIdEntityLoader; -import org.hibernate.sql.ast.tree.expression.JdbcParameter; import org.hibernate.sql.ast.tree.select.SelectStatement; +import org.hibernate.sql.exec.spi.JdbcParametersList; /** * Standard implementation of {@link ReactiveSingleIdEntityLoader}. @@ -195,8 +193,8 @@ private ReactiveSingleIdLoadPlan createLoadPlan( LoadQueryInfluencers queryInfluencers, SessionFactoryImplementor sessionFactory) { - final List jdbcParameters = new ArrayList<>(); + final JdbcParametersList.Builder jdbcParametersListBuilder = JdbcParametersList.newBuilder(); final SelectStatement sqlAst = LoaderSelectBuilder.createSelect( getLoadable(), // null here means to select everything @@ -206,9 +204,10 @@ private ReactiveSingleIdLoadPlan createLoadPlan( 1, queryInfluencers, lockOptions, - jdbcParameters::add, + jdbcParametersListBuilder::add, sessionFactory ); + final JdbcParametersList jdbcParameters = jdbcParametersListBuilder.build(); return new ReactiveSingleIdLoadPlan<>( (Loadable) getLoadable(), diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveSingleIdLoadPlan.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveSingleIdLoadPlan.java index fab75b526..bfe274e13 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveSingleIdLoadPlan.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveSingleIdLoadPlan.java @@ -23,13 +23,13 @@ import org.hibernate.reactive.sql.exec.internal.StandardReactiveSelectExecutor; import org.hibernate.reactive.sql.results.spi.ReactiveListResultsConsumer; import org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor; -import org.hibernate.sql.ast.tree.expression.JdbcParameter; import org.hibernate.sql.ast.tree.select.SelectStatement; import org.hibernate.sql.exec.internal.CallbackImpl; import org.hibernate.sql.exec.internal.JdbcParameterBindingsImpl; import org.hibernate.sql.exec.spi.Callback; import org.hibernate.sql.exec.spi.ExecutionContext; import org.hibernate.sql.exec.spi.JdbcParameterBindings; +import org.hibernate.sql.exec.spi.JdbcParametersList; import org.hibernate.sql.results.graph.entity.LoadingEntityEntry; public class ReactiveSingleIdLoadPlan extends SingleIdLoadPlan> { @@ -38,7 +38,7 @@ public ReactiveSingleIdLoadPlan( Loadable persister, ModelPart restrictivePart, SelectStatement sqlAst, - List jdbcParameters, + JdbcParametersList jdbcParameters, LockOptions lockOptions, SessionFactoryImplementor sessionFactory) { super( persister, restrictivePart, sqlAst, jdbcParameters, lockOptions, sessionFactory ); diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveSingleUniqueKeyEntityLoaderStandard.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveSingleUniqueKeyEntityLoaderStandard.java index 6ee7e65e8..f8ba89540 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveSingleUniqueKeyEntityLoaderStandard.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveSingleUniqueKeyEntityLoaderStandard.java @@ -5,7 +5,6 @@ */ package org.hibernate.reactive.loader.ast.internal; -import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.concurrent.CompletionStage; @@ -29,7 +28,6 @@ import org.hibernate.reactive.sql.exec.internal.StandardReactiveSelectExecutor; import org.hibernate.reactive.sql.results.spi.ReactiveListResultsConsumer; import org.hibernate.sql.ast.SqlAstTranslatorFactory; -import org.hibernate.sql.ast.tree.expression.JdbcParameter; import org.hibernate.sql.ast.tree.select.SelectStatement; import org.hibernate.sql.exec.internal.BaseExecutionContext; import org.hibernate.sql.exec.internal.CallbackImpl; @@ -37,6 +35,7 @@ import org.hibernate.sql.exec.spi.Callback; import org.hibernate.sql.exec.spi.JdbcOperationQuerySelect; import org.hibernate.sql.exec.spi.JdbcParameterBindings; +import org.hibernate.sql.exec.spi.JdbcParametersList; /** * @@ -70,7 +69,7 @@ public CompletionStage load(Object ukValue, LockOptions lockOptions, Boolean final SessionFactoryImplementor sessionFactory = session.getFactory(); // todo (6.0) : cache the SQL AST and JdbcParameters - final List jdbcParameters = new ArrayList<>(); + final JdbcParametersList.Builder jdbcParametersListBuilder = JdbcParametersList.newBuilder(); final SelectStatement sqlAst = LoaderSelectBuilder.createSelectByUniqueKey( entityDescriptor, Collections.emptyList(), @@ -78,9 +77,10 @@ public CompletionStage load(Object ukValue, LockOptions lockOptions, Boolean null, LoadQueryInfluencers.NONE, LockOptions.NONE, - jdbcParameters::add, + jdbcParametersListBuilder::add, sessionFactory ); + final JdbcParametersList jdbcParameters = jdbcParametersListBuilder.build(); final JdbcServices jdbcServices = sessionFactory.getJdbcServices(); final JdbcEnvironment jdbcEnvironment = jdbcServices.getJdbcEnvironment(); @@ -125,7 +125,7 @@ public Object resolveId(Object ukValue, SharedSessionContractImplementor session final SessionFactoryImplementor sessionFactory = session.getFactory(); // todo (6.0) : cache the SQL AST and JdbcParameters - final List jdbcParameters = new ArrayList<>(); + final JdbcParametersList.Builder jdbcParametersListBuilder = JdbcParametersList.newBuilder(); final SelectStatement sqlAst = LoaderSelectBuilder.createSelectByUniqueKey( entityDescriptor, Collections.singletonList( entityDescriptor.getIdentifierMapping() ), @@ -133,9 +133,10 @@ public Object resolveId(Object ukValue, SharedSessionContractImplementor session null, LoadQueryInfluencers.NONE, LockOptions.NONE, - jdbcParameters::add, + jdbcParametersListBuilder::add, sessionFactory ); + final JdbcParametersList jdbcParameters = jdbcParametersListBuilder.build(); final JdbcServices jdbcServices = sessionFactory.getJdbcServices(); final JdbcEnvironment jdbcEnvironment = jdbcServices.getJdbcEnvironment(); diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/entity/impl/ReactiveAbstractEntityPersister.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/entity/impl/ReactiveAbstractEntityPersister.java index 4deaa284a..671dbd0b4 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/entity/impl/ReactiveAbstractEntityPersister.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/entity/impl/ReactiveAbstractEntityPersister.java @@ -51,8 +51,8 @@ import org.hibernate.reactive.session.impl.ReactiveQueryExecutorLookup; import org.hibernate.sql.SimpleSelect; import org.hibernate.sql.Update; -import org.hibernate.sql.ast.tree.expression.JdbcParameter; import org.hibernate.sql.ast.tree.select.SelectStatement; +import org.hibernate.sql.exec.spi.JdbcParametersList; import org.hibernate.type.BasicType; import jakarta.persistence.metamodel.Attribute; @@ -556,7 +556,9 @@ default NaturalIdMapping generateNaturalIdMapping( // in the collected names. iterate here because it is already alphabetical final List collectedAttrMappings = new ArrayList<>(); - for ( AttributeMapping attributeMapping : getAttributeMappings() ) { + final AttributeMappingsList attributeMappings = getAttributeMappings(); + for ( int i = 0; i < attributeMappings.size(); i++ ) { + AttributeMapping attributeMapping = attributeMappings.get( i ); if ( attributeNames.contains( attributeMapping.getAttributeName() ) ) { collectedAttrMappings.add( (SingularAttributeMapping) attributeMapping ); } @@ -613,7 +615,7 @@ default ReactiveSingleIdArrayLoadPlan createLazyLoadPlan(List jdbcParameters = new ArrayList<>(); + final JdbcParametersList.Builder jdbcParametersListBuilder = JdbcParametersList.newBuilder(); final SelectStatement select = LoaderSelectBuilder.createSelect( this, partsToSelect, @@ -622,9 +624,10 @@ default ReactiveSingleIdArrayLoadPlan createLazyLoadPlan(List generatedValuesToSelect; - private final List jdbcParameters; + private final JdbcParametersList jdbcParameters; private final EntityMappingType entityDescriptor; private final SessionFactoryImplementor sessionFactory; ReactiveGeneratedValuesProcessor(SelectStatement selectStatement, List generatedValuesToSelect, - List jdbcParameters, + JdbcParametersList jdbcParameters, EntityMappingType entityDescriptor, SessionFactoryImplementor sessionFactory) { this.selectStatement = selectStatement; diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/query/sqm/iternal/ConcreteSqmSelectReactiveQueryPlan.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/query/sqm/iternal/ConcreteSqmSelectReactiveQueryPlan.java index bcb15efae..8a5130088 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/query/sqm/iternal/ConcreteSqmSelectReactiveQueryPlan.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/query/sqm/iternal/ConcreteSqmSelectReactiveQueryPlan.java @@ -39,10 +39,10 @@ import org.hibernate.sql.ast.SqlAstTranslator; import org.hibernate.sql.ast.SqlAstTranslatorFactory; import org.hibernate.sql.ast.spi.FromClauseAccess; -import org.hibernate.sql.ast.tree.expression.JdbcParameter; import org.hibernate.sql.ast.tree.select.SelectStatement; import org.hibernate.sql.exec.spi.JdbcOperationQuerySelect; import org.hibernate.sql.exec.spi.JdbcParameterBindings; +import org.hibernate.sql.exec.spi.JdbcParametersList; import org.hibernate.sql.results.internal.TupleMetadata; import org.hibernate.sql.results.spi.RowTransformer; @@ -93,7 +93,7 @@ private static CompletionStage> listInterpreter( final JdbcOperationQuerySelect jdbcSelect = sqmInterpretation.getJdbcSelect(); // I'm using a supplier so that the whenComplete at the end will catch any errors, like a finally-block Supplier fetchHandlerSupplier = () -> SubselectFetch - .createRegistrationHandler( session.getPersistenceContext().getBatchFetchQueue(), sqmInterpretation.selectStatement, emptyList(), jdbcParameterBindings ); + .createRegistrationHandler( session.getPersistenceContext().getBatchFetchQueue(), sqmInterpretation.selectStatement, JdbcParametersList.empty(), jdbcParameterBindings ); return completedFuture( fetchHandlerSupplier ) .thenApply( Supplier::get ) .thenCompose( subSelectFetchKeyHandler -> session @@ -212,7 +212,7 @@ private static CacheableSqmInterpretation buildCacheableSqmInterpretation( final SqlAstTranslatorFactory sqlAstTranslatorFactory = jdbcEnvironment.getSqlAstTranslatorFactory(); final SqlAstTranslator selectTranslator = sqlAstTranslatorFactory .buildSelectTranslator( sessionFactory, sqmInterpretation.getSqlAst() ); - final Map, Map, List>>> jdbcParamsXref = SqmUtil + final Map, Map, List>> jdbcParamsXref = SqmUtil .generateJdbcParamsXref( domainParameterXref, sqmInterpretation::getJdbcParamsBySqmParam ); final JdbcParameterBindings jdbcParameterBindings = SqmUtil.createJdbcParameterBindings( executionContext.getQueryParameterBindings(), @@ -258,7 +258,7 @@ private static class CacheableSqmInterpretation { private final SelectStatement selectStatement; private final JdbcOperationQuerySelect jdbcSelect; private final FromClauseAccess tableGroupAccess; - private final Map, Map, List>>> jdbcParamsXref; + private final Map, Map, List>> jdbcParamsXref; private final Map, MappingModelExpressible> sqmParameterMappingModelTypes; private transient JdbcParameterBindings firstParameterBindings; @@ -266,7 +266,7 @@ private static class CacheableSqmInterpretation { SelectStatement selectStatement, JdbcOperationQuerySelect jdbcSelect, FromClauseAccess tableGroupAccess, - Map, Map, List>>> jdbcParamsXref, + Map, Map, List>> jdbcParamsXref, Map, MappingModelExpressible> sqmParameterMappingModelTypes, JdbcParameterBindings firstParameterBindings) { this.selectStatement = selectStatement; @@ -289,7 +289,7 @@ FromClauseAccess getTableGroupAccess() { return tableGroupAccess; } - Map, Map, List>>> getJdbcParamsXref() { + Map, Map, List>> getJdbcParamsXref() { return jdbcParamsXref; } diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/query/sqm/iternal/ReactiveSimpleDeleteQueryPlan.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/query/sqm/iternal/ReactiveSimpleDeleteQueryPlan.java index 746950975..581d62c81 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/query/sqm/iternal/ReactiveSimpleDeleteQueryPlan.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/query/sqm/iternal/ReactiveSimpleDeleteQueryPlan.java @@ -37,13 +37,13 @@ import org.hibernate.sql.ast.SqlAstTranslator; import org.hibernate.sql.ast.tree.delete.DeleteStatement; import org.hibernate.sql.ast.tree.expression.Expression; -import org.hibernate.sql.ast.tree.expression.JdbcParameter; import org.hibernate.sql.ast.tree.from.MutatingTableReferenceGroupWrapper; import org.hibernate.sql.ast.tree.from.NamedTableReference; import org.hibernate.sql.ast.tree.predicate.InSubQueryPredicate; import org.hibernate.sql.ast.tree.select.QuerySpec; import org.hibernate.sql.exec.spi.JdbcOperationQueryDelete; import org.hibernate.sql.exec.spi.JdbcParameterBindings; +import org.hibernate.sql.exec.spi.JdbcParametersList; import org.hibernate.sql.results.internal.SqlSelectionImpl; import static org.hibernate.query.sqm.internal.SqmJdbcExecutionContextAdapter.usingLockingAndPaging; @@ -57,7 +57,7 @@ public class ReactiveSimpleDeleteQueryPlan extends SimpleDeleteQueryPlan impleme private SqmTranslation sqmInterpretation; - private Map, Map, List>>> jdbcParamsXref; + private Map, Map, List>> jdbcParamsXref; public ReactiveSimpleDeleteQueryPlan( EntityMappingType entityDescriptor, diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/query/sqm/iternal/ReactiveSimpleInsertQueryPlan.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/query/sqm/iternal/ReactiveSimpleInsertQueryPlan.java index 33baca7d8..cba5287a9 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/query/sqm/iternal/ReactiveSimpleInsertQueryPlan.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/query/sqm/iternal/ReactiveSimpleInsertQueryPlan.java @@ -31,10 +31,10 @@ import org.hibernate.reactive.sql.exec.internal.StandardReactiveJdbcMutationExecutor; import org.hibernate.sql.ast.SqlAstTranslator; import org.hibernate.sql.ast.spi.FromClauseAccess; -import org.hibernate.sql.ast.tree.expression.JdbcParameter; import org.hibernate.sql.ast.tree.insert.InsertStatement; import org.hibernate.sql.exec.spi.JdbcOperationQueryInsert; import org.hibernate.sql.exec.spi.JdbcParameterBindings; +import org.hibernate.sql.exec.spi.JdbcParametersList; /** * @see org.hibernate.query.sqm.internal.SimpleInsertQueryPlan @@ -49,7 +49,7 @@ public class ReactiveSimpleInsertQueryPlan implements ReactiveNonSelectQueryPlan private JdbcOperationQueryInsert jdbcInsert; private FromClauseAccess tableGroupAccess; - private Map, Map, List>>> jdbcParamsXref; + private Map, Map, List>> jdbcParamsXref; public ReactiveSimpleInsertQueryPlan( SqmInsertStatement sqmInsert, diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/query/sqm/iternal/ReactiveSimpleUpdateQueryPlan.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/query/sqm/iternal/ReactiveSimpleUpdateQueryPlan.java index 7f25ea865..068cb7f18 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/query/sqm/iternal/ReactiveSimpleUpdateQueryPlan.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/query/sqm/iternal/ReactiveSimpleUpdateQueryPlan.java @@ -29,10 +29,10 @@ import org.hibernate.reactive.sql.exec.internal.StandardReactiveJdbcMutationExecutor; import org.hibernate.sql.ast.SqlAstTranslator; import org.hibernate.sql.ast.spi.FromClauseAccess; -import org.hibernate.sql.ast.tree.expression.JdbcParameter; import org.hibernate.sql.ast.tree.update.UpdateStatement; import org.hibernate.sql.exec.spi.JdbcOperationQueryUpdate; import org.hibernate.sql.exec.spi.JdbcParameterBindings; +import org.hibernate.sql.exec.spi.JdbcParametersList; /** @@ -45,7 +45,7 @@ public class ReactiveSimpleUpdateQueryPlan implements ReactiveNonSelectQueryPlan private JdbcOperationQueryUpdate jdbcUpdate; private FromClauseAccess tableGroupAccess; - private Map, Map, List>>> jdbcParamsXref; + private Map, Map, List>> jdbcParamsXref; private Map, MappingModelExpressible> sqmParamMappingTypeResolutions; public ReactiveSimpleUpdateQueryPlan(SqmUpdateStatement sqmUpdate, DomainParameterXref domainParameterXref) { diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/query/sqm/mutation/internal/temptable/ReactiveTableBasedUpdateHandler.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/query/sqm/mutation/internal/temptable/ReactiveTableBasedUpdateHandler.java index a9976809f..db2dc3320 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/query/sqm/mutation/internal/temptable/ReactiveTableBasedUpdateHandler.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/query/sqm/mutation/internal/temptable/ReactiveTableBasedUpdateHandler.java @@ -80,7 +80,7 @@ protected ReactiveExecutionDelegate resolveDelegate(DomainQueryExecutionContext } @Override - protected ReactiveUpdateExcutionDelegate buildExecutionDelegate( + protected ReactiveUpdateExecutionDelegate buildExecutionDelegate( MultiTableSqmMutationConverter sqmConverter, TemporaryTable idTable, AfterUseAction afterUseAction, @@ -93,7 +93,7 @@ protected ReactiveUpdateExcutionDelegate buildExecutionDelegate( Map, List>> parameterResolutions, Map, MappingModelExpressible> paramTypeResolutions, DomainQueryExecutionContext executionContext) { - return new ReactiveUpdateExcutionDelegate( + return new ReactiveUpdateExecutionDelegate( sqmConverter, idTable, afterUseAction, diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/query/sqm/mutation/internal/temptable/ReactiveUpdateExcutionDelegate.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/query/sqm/mutation/internal/temptable/ReactiveUpdateExecutionDelegate.java similarity index 96% rename from hibernate-reactive-core/src/main/java/org/hibernate/reactive/query/sqm/mutation/internal/temptable/ReactiveUpdateExcutionDelegate.java rename to hibernate-reactive-core/src/main/java/org/hibernate/reactive/query/sqm/mutation/internal/temptable/ReactiveUpdateExecutionDelegate.java index b07954738..eedc1f8a0 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/query/sqm/mutation/internal/temptable/ReactiveUpdateExcutionDelegate.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/query/sqm/mutation/internal/temptable/ReactiveUpdateExecutionDelegate.java @@ -57,11 +57,11 @@ import static org.hibernate.reactive.query.sqm.mutation.internal.temptable.ReactiveExecuteWithTemporaryTableHelper.saveMatchingIdsIntoIdTable; import static org.hibernate.reactive.util.impl.CompletionStages.voidFuture; -public class ReactiveUpdateExcutionDelegate extends UpdateExecutionDelegate implements ReactiveTableBasedUpdateHandler.ReactiveExecutionDelegate { +public class ReactiveUpdateExecutionDelegate extends UpdateExecutionDelegate implements ReactiveTableBasedUpdateHandler.ReactiveExecutionDelegate { private static final Log LOG = LoggerFactory.make( Log.class, MethodHandles.lookup() ); - public ReactiveUpdateExcutionDelegate( + public ReactiveUpdateExecutionDelegate( MultiTableSqmMutationConverter sqmConverter, TemporaryTable idTable, AfterUseAction afterUseAction, @@ -214,13 +214,13 @@ private CompletionStage executeUpdate(QuerySpec idTableSubQuery, Execut return StandardReactiveJdbcMutationExecutor.INSTANCE .executeReactive( jdbcUpdate, - getJdbcParameterBindings(), - executionContext.getSession() + getJdbcParameterBindings(), + executionContext.getSession() .getJdbcCoordinator() .getStatementPreparer() ::prepareStatement, - ReactiveUpdateExcutionDelegate::doNothing, - executionContext + ReactiveUpdateExecutionDelegate::doNothing, + executionContext ); } @@ -294,7 +294,7 @@ private CompletionStage executeInsert( .getJdbcCoordinator() .getStatementPreparer() ::prepareStatement, - ReactiveUpdateExcutionDelegate::doNothing, + ReactiveUpdateExecutionDelegate::doNothing, executionContext ); } diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/MultithreadedIdentityGenerationTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/MultithreadedIdentityGenerationTest.java index 5f6ab2dd8..04adbecbf 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/MultithreadedIdentityGenerationTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/MultithreadedIdentityGenerationTest.java @@ -46,6 +46,8 @@ import jakarta.persistence.Table; import static org.hibernate.cfg.AvailableSettings.SHOW_SQL; +import static org.hibernate.reactive.BaseReactiveTest.setDefaultProperties; +import static org.hibernate.reactive.provider.Settings.POOL_CONNECT_TIMEOUT; /** * This is a multi-threaded stress test, intentionally consuming some time. @@ -95,10 +97,10 @@ public static void setupSessionFactory() { vertxOptions.setBlockedThreadCheckIntervalUnit( TimeUnit.MINUTES ); vertx = Vertx.vertx( vertxOptions ); Configuration configuration = new Configuration(); + setDefaultProperties( configuration ); configuration.addAnnotatedClass( EntityWithGeneratedId.class ); - BaseReactiveTest.setDefaultProperties( configuration ); configuration.setProperty( SHOW_SQL, String.valueOf( LOG_SQL ) ); - BaseReactiveTest.setDefaultProperties( configuration ); + configuration.setProperty( POOL_CONNECT_TIMEOUT, String.valueOf( TIMEOUT_MINUTES * 60 * 1000 ) ); StandardServiceRegistryBuilder builder = new ReactiveServiceRegistryBuilder() .applySettings( configuration.getProperties() ) //Inject our custom vert.x instance: diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/MultithreadedInsertionTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/MultithreadedInsertionTest.java index f83bf1d45..3499de06f 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/MultithreadedInsertionTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/MultithreadedInsertionTest.java @@ -36,6 +36,8 @@ import jakarta.persistence.Table; import static org.hibernate.cfg.AvailableSettings.SHOW_SQL; +import static org.hibernate.reactive.BaseReactiveTest.setDefaultProperties; +import static org.hibernate.reactive.provider.Settings.POOL_CONNECT_TIMEOUT; import static org.hibernate.reactive.util.impl.CompletionStages.loop; /** @@ -101,9 +103,10 @@ public static void setupSessionFactory() { vertxOptions.setBlockedThreadCheckIntervalUnit( TimeUnit.MINUTES ); vertx = Vertx.vertx( vertxOptions ); Configuration configuration = new Configuration(); + setDefaultProperties( configuration ); configuration.addAnnotatedClass( EntityWithGeneratedId.class ); - BaseReactiveTest.setDefaultProperties( configuration ); configuration.setProperty( SHOW_SQL, String.valueOf( LOG_SQL ) ); + configuration.setProperty( POOL_CONNECT_TIMEOUT, String.valueOf( TIMEOUT_MINUTES * 60 * 1000 ) ); StandardServiceRegistryBuilder builder = new ReactiveServiceRegistryBuilder() .applySettings( configuration.getProperties() ) //Inject our custom vert.x instance: diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/containers/OracleDatabase.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/containers/OracleDatabase.java index d3f8a950a..6e1694cbc 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/containers/OracleDatabase.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/containers/OracleDatabase.java @@ -85,7 +85,7 @@ class OracleDatabase implements TestableDatabase { } public static final OracleContainer oracle = new OracleContainer( - imageName( "gvenzl/oracle-free", "23-slim-faststart" ) + imageName( "gvenzl/oracle-free", "latest-faststart" ) .asCompatibleSubstituteFor( "gvenzl/oracle-xe" ) ) .withUsername( DatabaseConfiguration.USERNAME ) .withPassword( DatabaseConfiguration.PASSWORD )