44
44
import org .hibernate .reactive .engine .impl .ReactiveEntityActionVetoException ;
45
45
import org .hibernate .reactive .engine .impl .ReactiveEntityDeleteAction ;
46
46
import org .hibernate .reactive .engine .impl .ReactiveEntityInsertAction ;
47
+ import org .hibernate .reactive .engine .impl .ReactiveEntityInsertActionHolder ;
47
48
import org .hibernate .reactive .engine .impl .ReactiveEntityRegularInsertAction ;
48
49
import org .hibernate .reactive .engine .impl .ReactiveEntityUpdateAction ;
49
50
import org .hibernate .reactive .engine .impl .ReactiveOrphanRemovalAction ;
@@ -78,7 +79,7 @@ public class ReactiveActionQueue {
78
79
// Object insertions, updates, and deletions have list semantics because
79
80
// they must happen in the right order to respect referential
80
81
// integrity
81
- private ExecutableList <ReactiveEntityInsertAction > insertions ;
82
+ private ExecutableList <ReactiveEntityInsertActionHolder > insertions ;
82
83
private ExecutableList <ReactiveEntityDeleteAction > deletions ;
83
84
private ExecutableList <ReactiveEntityUpdateAction > updates ;
84
85
// Actually the semantics of the next three are really "Bag"
@@ -281,7 +282,7 @@ private CompletionStage<Void> addResolvedEntityInsertAction(ReactiveEntityInsert
281
282
else {
282
283
LOG .trace ( "Adding resolved non-early insert action." );
283
284
OrderedActions .EntityInsertAction .ensureInitialized ( this );
284
- this .insertions .add ( insert );
285
+ this .insertions .add ( new ReactiveEntityInsertActionHolder ( insert ) );
285
286
ret = voidFuture ();
286
287
}
287
288
@@ -1016,34 +1017,35 @@ public CompletionStage<Void> afterTransactionCompletion(boolean success) {
1016
1017
*
1017
1018
* @author Jay Erb
1018
1019
*/
1019
- private static class InsertActionSorter implements ExecutableList .Sorter <ReactiveEntityInsertAction > {
1020
+ private static class InsertActionSorter implements ExecutableList .Sorter <ReactiveEntityInsertActionHolder > {
1020
1021
/**
1021
1022
* Singleton access
1022
1023
*/
1023
1024
public static final InsertActionSorter INSTANCE = new InsertActionSorter ();
1024
1025
// the map of batch numbers to EntityInsertAction lists
1025
- private Map <BatchIdentifier , List <ReactiveEntityInsertAction >> actionBatches ;
1026
+ private Map <BatchIdentifier , List <ReactiveEntityInsertActionHolder >> actionBatches ;
1026
1027
1027
1028
public InsertActionSorter () {
1028
1029
}
1029
1030
1030
1031
/**
1031
1032
* Sort the insert actions.
1032
1033
*/
1033
- public void sort (List <ReactiveEntityInsertAction > insertions ) {
1034
+ public void sort (List <ReactiveEntityInsertActionHolder > insertions ) {
1034
1035
// optimize the hash size to eliminate a rehash.
1035
1036
this .actionBatches = new HashMap <>();
1036
1037
1037
1038
// the mapping of entity names to their latest batch numbers.
1038
1039
final List <BatchIdentifier > latestBatches = new ArrayList <>();
1039
1040
1040
- for ( ReactiveEntityInsertAction action : insertions ) {
1041
+ for ( ReactiveEntityInsertActionHolder action : insertions ) {
1042
+ final ReactiveEntityInsertAction actionDelegate = action .getDelegate ();
1041
1043
BatchIdentifier batchIdentifier = new BatchIdentifier (
1042
- action .getEntityName (),
1043
- action .getSession ()
1044
+ actionDelegate .getEntityName (),
1045
+ actionDelegate .getSession ()
1044
1046
.getFactory ()
1045
1047
.getMetamodel ()
1046
- .entityPersister ( action .getEntityName () )
1048
+ .entityPersister ( actionDelegate .getEntityName () )
1047
1049
.getRootEntityName ()
1048
1050
);
1049
1051
@@ -1055,8 +1057,8 @@ public void sort(List<ReactiveEntityInsertAction> insertions) {
1055
1057
else {
1056
1058
latestBatches .add ( batchIdentifier );
1057
1059
}
1058
- addParentChildEntityNames ( action , batchIdentifier );
1059
- addToBatch ( batchIdentifier , action );
1060
+ addParentChildEntityNames ( actionDelegate , batchIdentifier );
1061
+ addToBatch ( batchIdentifier , actionDelegate );
1060
1062
}
1061
1063
insertions .clear ();
1062
1064
@@ -1233,10 +1235,10 @@ else if ( type.isComponentType() && value != null ) {
1233
1235
}
1234
1236
1235
1237
private void addToBatch (BatchIdentifier batchIdentifier , ReactiveEntityInsertAction action ) {
1236
- List <ReactiveEntityInsertAction > actions = actionBatches
1238
+ List <ReactiveEntityInsertActionHolder > actions = actionBatches
1237
1239
.computeIfAbsent ( batchIdentifier , k -> new LinkedList <>() );
1238
1240
1239
- actions .add ( action );
1241
+ actions .add ( new ReactiveEntityInsertActionHolder ( action ) );
1240
1242
}
1241
1243
1242
1244
private static class BatchIdentifier {
0 commit comments