@@ -47,7 +47,7 @@ class WritingContext {
47
47
private final PersistentPropertyPaths <?, RelationalPersistentProperty > paths ;
48
48
private final Map <PathNode , DbAction <?>> previousActions = new HashMap <>();
49
49
private final Map <PersistentPropertyPath <RelationalPersistentProperty >, List <PathNode >> nodesCache = new HashMap <>();
50
- private boolean rootIncludeId ;
50
+ private final boolean rootIncludeId ;
51
51
52
52
WritingContext (RelationalMappingContext context , Object root , MutableAggregateChange <?> aggregateChange ) {
53
53
@@ -126,9 +126,7 @@ private List<DbAction<?>> insertReferenced() {
126
126
private List <? extends DbAction <?>> insertAll (PersistentPropertyPath <RelationalPersistentProperty > path ) {
127
127
128
128
RelationalPersistentEntity <?> persistentEntity = context .getRequiredPersistentEntity (path .getRequiredLeafProperty ());
129
- TreeMap <Boolean , List <DbAction .Insert <Object >>> insertsPartitionedByHasId = new TreeMap <>(BooleanComparator .TRUE_HIGH );
130
- insertsPartitionedByHasId .put (true , new ArrayList <>());
131
- insertsPartitionedByHasId .put (false , new ArrayList <>());
129
+ List <DbAction .Insert <Object >> inserts = new ArrayList <>();
132
130
from (path ).forEach (node -> {
133
131
134
132
DbAction .WithEntity <?> parentAction = getAction (node .getParent ());
@@ -150,11 +148,12 @@ private List<? extends DbAction<?>> insertAll(PersistentPropertyPath<RelationalP
150
148
}
151
149
boolean includeId = persistentEntity .getIdentifierAccessor (instance ).getIdentifier () != null ;
152
150
DbAction .Insert <Object > insert = new DbAction .Insert <>(instance , path , parentAction , qualifiers , includeId );
153
- insertsPartitionedByHasId .get (includeId )
154
- .add (insert );
151
+ inserts .add (insert );
155
152
previousActions .put (node , insert );
156
153
});
157
- return insertsPartitionedByHasId .entrySet ().stream ()
154
+ return inserts .stream ()
155
+ .collect (Collectors .partitioningBy (DbAction .Insert ::isIncludeId ))
156
+ .entrySet ().stream ()
158
157
.filter (entry -> (!entry .getValue ().isEmpty ()))
159
158
.map (entry -> {
160
159
List <DbAction .Insert <Object >> batch = entry .getValue ();
0 commit comments