4444import org .hibernate .reactive .engine .impl .ReactiveEntityActionVetoException ;
4545import org .hibernate .reactive .engine .impl .ReactiveEntityDeleteAction ;
4646import org .hibernate .reactive .engine .impl .ReactiveEntityInsertAction ;
47+ import org .hibernate .reactive .engine .impl .ReactiveEntityInsertActionHolder ;
4748import org .hibernate .reactive .engine .impl .ReactiveEntityRegularInsertAction ;
4849import org .hibernate .reactive .engine .impl .ReactiveEntityUpdateAction ;
4950import org .hibernate .reactive .engine .impl .ReactiveOrphanRemovalAction ;
@@ -78,7 +79,7 @@ public class ReactiveActionQueue {
7879 // Object insertions, updates, and deletions have list semantics because
7980 // they must happen in the right order to respect referential
8081 // integrity
81- private ExecutableList <ReactiveEntityInsertAction > insertions ;
82+ private ExecutableList <ReactiveEntityInsertActionHolder > insertions ;
8283 private ExecutableList <ReactiveEntityDeleteAction > deletions ;
8384 private ExecutableList <ReactiveEntityUpdateAction > updates ;
8485 // Actually the semantics of the next three are really "Bag"
@@ -281,7 +282,7 @@ private CompletionStage<Void> addResolvedEntityInsertAction(ReactiveEntityInsert
281282 else {
282283 LOG .trace ( "Adding resolved non-early insert action." );
283284 OrderedActions .EntityInsertAction .ensureInitialized ( this );
284- this .insertions .add ( insert );
285+ this .insertions .add ( new ReactiveEntityInsertActionHolder ( insert ) );
285286 ret = voidFuture ();
286287 }
287288
@@ -1016,34 +1017,35 @@ public CompletionStage<Void> afterTransactionCompletion(boolean success) {
10161017 *
10171018 * @author Jay Erb
10181019 */
1019- private static class InsertActionSorter implements ExecutableList .Sorter <ReactiveEntityInsertAction > {
1020+ private static class InsertActionSorter implements ExecutableList .Sorter <ReactiveEntityInsertActionHolder > {
10201021 /**
10211022 * Singleton access
10221023 */
10231024 public static final InsertActionSorter INSTANCE = new InsertActionSorter ();
10241025 // the map of batch numbers to EntityInsertAction lists
1025- private Map <BatchIdentifier , List <ReactiveEntityInsertAction >> actionBatches ;
1026+ private Map <BatchIdentifier , List <ReactiveEntityInsertActionHolder >> actionBatches ;
10261027
10271028 public InsertActionSorter () {
10281029 }
10291030
10301031 /**
10311032 * Sort the insert actions.
10321033 */
1033- public void sort (List <ReactiveEntityInsertAction > insertions ) {
1034+ public void sort (List <ReactiveEntityInsertActionHolder > insertions ) {
10341035 // optimize the hash size to eliminate a rehash.
10351036 this .actionBatches = new HashMap <>();
10361037
10371038 // the mapping of entity names to their latest batch numbers.
10381039 final List <BatchIdentifier > latestBatches = new ArrayList <>();
10391040
1040- for ( ReactiveEntityInsertAction action : insertions ) {
1041+ for ( ReactiveEntityInsertActionHolder action : insertions ) {
1042+ final ReactiveEntityInsertAction actionDelegate = action .getDelegate ();
10411043 BatchIdentifier batchIdentifier = new BatchIdentifier (
1042- action .getEntityName (),
1043- action .getSession ()
1044+ actionDelegate .getEntityName (),
1045+ actionDelegate .getSession ()
10441046 .getFactory ()
10451047 .getMetamodel ()
1046- .entityPersister ( action .getEntityName () )
1048+ .entityPersister ( actionDelegate .getEntityName () )
10471049 .getRootEntityName ()
10481050 );
10491051
@@ -1055,8 +1057,8 @@ public void sort(List<ReactiveEntityInsertAction> insertions) {
10551057 else {
10561058 latestBatches .add ( batchIdentifier );
10571059 }
1058- addParentChildEntityNames ( action , batchIdentifier );
1059- addToBatch ( batchIdentifier , action );
1060+ addParentChildEntityNames ( actionDelegate , batchIdentifier );
1061+ addToBatch ( batchIdentifier , actionDelegate );
10601062 }
10611063 insertions .clear ();
10621064
@@ -1233,10 +1235,10 @@ else if ( type.isComponentType() && value != null ) {
12331235 }
12341236
12351237 private void addToBatch (BatchIdentifier batchIdentifier , ReactiveEntityInsertAction action ) {
1236- List <ReactiveEntityInsertAction > actions = actionBatches
1238+ List <ReactiveEntityInsertActionHolder > actions = actionBatches
12371239 .computeIfAbsent ( batchIdentifier , k -> new LinkedList <>() );
12381240
1239- actions .add ( action );
1241+ actions .add ( new ReactiveEntityInsertActionHolder ( action ) );
12401242 }
12411243
12421244 private static class BatchIdentifier {
0 commit comments