@@ -73,16 +73,19 @@ class JdbcAggregateChangeExecutionContext {
7373
7474 <T > void executeInsertRoot (DbAction .InsertRoot <T > insert ) {
7575
76- Object id = accessStrategy .insert (insert .getEntity (), insert .getEntityType (), Identifier .empty (), insert .getIdValueSource ());
76+ Object id = accessStrategy .insert (insert .getEntity (), insert .getEntityType (), Identifier .empty (),
77+ insert .getIdValueSource ());
7778 add (new DbActionExecutionResult (insert , id ));
7879 }
7980
8081 <T > void executeBatchInsertRoot (DbAction .BatchInsertRoot <T > batchInsertRoot ) {
8182
8283 List <DbAction .InsertRoot <T >> inserts = batchInsertRoot .getActions ();
83- List <InsertSubject <T >> insertSubjects = inserts .stream ().map (insert -> InsertSubject .describedBy (insert .getEntity (), Identifier .empty ())).collect (Collectors .toList ());
84+ List <InsertSubject <T >> insertSubjects = inserts .stream ()
85+ .map (insert -> InsertSubject .describedBy (insert .getEntity (), Identifier .empty ())).collect (Collectors .toList ());
8486
85- Object [] ids = accessStrategy .insert (insertSubjects , batchInsertRoot .getEntityType (), batchInsertRoot .getBatchValue ());
87+ Object [] ids = accessStrategy .insert (insertSubjects , batchInsertRoot .getEntityType (),
88+ batchInsertRoot .getBatchValue ());
8689
8790 for (int i = 0 ; i < inserts .size (); i ++) {
8891 add (new DbActionExecutionResult (inserts .get (i ), ids .length > 0 ? ids [i ] : null ));
@@ -92,14 +95,17 @@ <T> void executeBatchInsertRoot(DbAction.BatchInsertRoot<T> batchInsertRoot) {
9295 <T > void executeInsert (DbAction .Insert <T > insert ) {
9396
9497 Identifier parentKeys = getParentKeys (insert , converter );
95- Object id = accessStrategy .insert (insert .getEntity (), insert .getEntityType (), parentKeys , insert .getIdValueSource ());
98+ Object id = accessStrategy .insert (insert .getEntity (), insert .getEntityType (), parentKeys ,
99+ insert .getIdValueSource ());
96100 add (new DbActionExecutionResult (insert , id ));
97101 }
98102
99103 <T > void executeBatchInsert (DbAction .BatchInsert <T > batchInsert ) {
100104
101105 List <DbAction .Insert <T >> inserts = batchInsert .getActions ();
102- List <InsertSubject <T >> insertSubjects = inserts .stream ().map (insert -> InsertSubject .describedBy (insert .getEntity (), getParentKeys (insert , converter ))).collect (Collectors .toList ());
106+ List <InsertSubject <T >> insertSubjects = inserts .stream ()
107+ .map (insert -> InsertSubject .describedBy (insert .getEntity (), getParentKeys (insert , converter )))
108+ .collect (Collectors .toList ());
103109
104110 Object [] ids = accessStrategy .insert (insertSubjects , batchInsert .getEntityType (), batchInsert .getBatchValue ());
105111
@@ -174,7 +180,8 @@ private Identifier getParentKeys(DbAction.WithDependingOn<?> action, JdbcConvert
174180 .forBackReferences (converter , context .getAggregatePath (action .getPropertyPath ()),
175181 getValueProvider (id , context .getAggregatePath (action .getPropertyPath ()), converter ));
176182
177- for (Map .Entry <PersistentPropertyPath <RelationalPersistentProperty >, Object > qualifier : action .getQualifiers ().entrySet ()) {
183+ for (Map .Entry <PersistentPropertyPath <RelationalPersistentProperty >, Object > qualifier : action .getQualifiers ()
184+ .entrySet ()) {
178185 identifier = identifier .withQualifier (context .getAggregatePath (qualifier .getKey ()), qualifier .getValue ());
179186 }
180187
@@ -183,7 +190,8 @@ private Identifier getParentKeys(DbAction.WithDependingOn<?> action, JdbcConvert
183190
184191 static Function <AggregatePath , Object > getValueProvider (Object idValue , AggregatePath path , JdbcConverter converter ) {
185192
186- RelationalPersistentEntity <?> entity = converter .getMappingContext ().getPersistentEntity (path .getIdDefiningParentPath ().getRequiredIdProperty ().getType ());
193+ RelationalPersistentEntity <?> entity = converter .getMappingContext ()
194+ .getPersistentEntity (path .getIdDefiningParentPath ().getRequiredIdProperty ().getType ());
187195
188196 Function <AggregatePath , Object > valueProvider = ap -> {
189197 if (entity == null ) {
@@ -198,7 +206,8 @@ static Function<AggregatePath, Object> getValueProvider(Object idValue, Aggregat
198206
199207 private Object getParentId (DbAction .WithDependingOn <?> action ) {
200208
201- DbAction .WithEntity <?> idOwningAction = getIdOwningAction (action , context .getAggregatePath (action .getPropertyPath ()).getIdDefiningParentPath ());
209+ DbAction .WithEntity <?> idOwningAction = getIdOwningAction (action ,
210+ context .getAggregatePath (action .getPropertyPath ()).getIdDefiningParentPath ());
202211
203212 return getPotentialGeneratedIdFrom (idOwningAction );
204213 }
@@ -207,7 +216,8 @@ private DbAction.WithEntity<?> getIdOwningAction(DbAction.WithEntity<?> action,
207216
208217 if (!(action instanceof DbAction .WithDependingOn <?> withDependingOn )) {
209218
210- Assert .state (idPath .isRoot (), "When the id path is not empty the id providing action should be of type WithDependingOn" );
219+ Assert .state (idPath .isRoot (),
220+ "When the id path is not empty the id providing action should be of type WithDependingOn" );
211221
212222 return action ;
213223 }
@@ -284,7 +294,9 @@ <T> List<T> populateIdsIfNecessary() {
284294 }
285295
286296 if (roots .isEmpty ()) {
287- throw new IllegalStateException (String .format ("Cannot retrieve the resulting instance(s) unless a %s or %s action was successfully executed" , DbAction .InsertRoot .class .getName (), DbAction .UpdateRoot .class .getName ()));
297+ throw new IllegalStateException (
298+ String .format ("Cannot retrieve the resulting instance(s) unless a %s or %s action was successfully executed" ,
299+ DbAction .InsertRoot .class .getName (), DbAction .UpdateRoot .class .getName ()));
288300 }
289301
290302 Collections .reverse (roots );
@@ -293,19 +305,23 @@ <T> List<T> populateIdsIfNecessary() {
293305 }
294306
295307 @ SuppressWarnings ("unchecked" )
296- private <S > Object setIdAndCascadingProperties (DbAction .WithEntity <S > action , @ Nullable Object generatedId , StagedValues cascadingValues ) {
308+ private <S > Object setIdAndCascadingProperties (DbAction .WithEntity <S > action , @ Nullable Object generatedId ,
309+ StagedValues cascadingValues ) {
297310
298311 S originalEntity = action .getEntity ();
299312
300- RelationalPersistentEntity <S > persistentEntity = (RelationalPersistentEntity <S >) context .getRequiredPersistentEntity (action .getEntityType ());
301- PersistentPropertyPathAccessor <S > propertyAccessor = converter .getPropertyAccessor (persistentEntity , originalEntity );
313+ RelationalPersistentEntity <S > persistentEntity = (RelationalPersistentEntity <S >) context
314+ .getRequiredPersistentEntity (action .getEntityType ());
315+ PersistentPropertyPathAccessor <S > propertyAccessor = converter .getPropertyAccessor (persistentEntity ,
316+ originalEntity );
302317
303318 if (IdValueSource .GENERATED .equals (action .getIdValueSource ())) {
304319 propertyAccessor .setProperty (persistentEntity .getRequiredIdProperty (), generatedId );
305320 }
306321
307322 // set values of changed immutables referenced by this entity
308- cascadingValues .forEachPath (action , (persistentPropertyPath , o ) -> propertyAccessor .setProperty (getRelativePath (action , persistentPropertyPath ), o ));
323+ cascadingValues .forEachPath (action , (persistentPropertyPath , o ) -> propertyAccessor
324+ .setProperty (getRelativePath (action , persistentPropertyPath ), o ));
309325
310326 return propertyAccessor .getBean ();
311327 }
@@ -337,7 +353,8 @@ private <T> void updateWithoutVersion(DbAction.UpdateRoot<T> update) {
337353
338354 if (!accessStrategy .update (update .getEntity (), update .getEntityType ())) {
339355
340- throw new IncorrectUpdateSemanticsDataAccessException (String .format (UPDATE_FAILED , update .getEntity (), getIdFrom (update )));
356+ throw new IncorrectUpdateSemanticsDataAccessException (
357+ String .format (UPDATE_FAILED , update .getEntity (), getIdFrom (update )));
341358 }
342359 }
343360
@@ -358,20 +375,21 @@ private <T> void updateWithVersion(DbAction.UpdateRoot<T> update) {
358375 */
359376 private static class StagedValues {
360377
361- static final List <MultiValueAggregator <?>> aggregators = Arrays .asList (SetAggregator .INSTANCE , MapAggregator .INSTANCE , ListAggregator .INSTANCE , SingleElementAggregator .INSTANCE );
378+ static final List <MultiValueAggregator <?>> aggregators = Arrays .asList (SetAggregator .INSTANCE ,
379+ MapAggregator .INSTANCE , ListAggregator .INSTANCE , SingleElementAggregator .INSTANCE );
362380
363381 Map <DbAction , Map <PersistentPropertyPath , StagedValue >> values = new HashMap <>();
364382
365383 /**
366384 * Adds a value that needs to be set in an entity higher up in the tree of entities in the aggregate. If the
367385 * attribute to be set is multivalued this method expects only a single element.
368386 *
369- * @param action The action responsible for persisting the entity that needs the added value set. Must not be
370- * {@literal null}.
371- * @param path The path to the property in which to set the value. Must not be {@literal null}.
387+ * @param action The action responsible for persisting the entity that needs the added value set. Must not be
388+ * {@literal null}.
389+ * @param path The path to the property in which to set the value. Must not be {@literal null}.
372390 * @param qualifier If {@code path} is a qualified multivalued properties this parameter contains the qualifier. May
373- * be {@literal null}.
374- * @param value The value to be set. Must not be {@literal null}.
391+ * be {@literal null}.
392+ * @param value The value to be set. Must not be {@literal null}.
375393 */
376394 void stage (DbAction <?> action , PersistentPropertyPath path , @ Nullable Object qualifier , Object value ) {
377395
@@ -384,9 +402,11 @@ <T> StagedValue gather(DbAction<?> action, PersistentPropertyPath path, @Nullabl
384402
385403 MultiValueAggregator <T > aggregator = getAggregatorFor (path );
386404
387- Map <PersistentPropertyPath , StagedValue > valuesForPath = this .values .computeIfAbsent (action , dbAction -> new HashMap <>());
405+ Map <PersistentPropertyPath , StagedValue > valuesForPath = this .values .computeIfAbsent (action ,
406+ dbAction -> new HashMap <>());
388407
389- StagedValue stagedValue = valuesForPath .computeIfAbsent (path , persistentPropertyPath -> new StagedValue (aggregator .createEmptyInstance ()));
408+ StagedValue stagedValue = valuesForPath .computeIfAbsent (path ,
409+ persistentPropertyPath -> new StagedValue (aggregator .createEmptyInstance ()));
390410 T currentValue = (T ) stagedValue .value ;
391411
392412 stagedValue .value = aggregator .add (currentValue , qualifier , value );
@@ -426,8 +446,7 @@ void forEachPath(DbAction<?> dbAction, BiConsumer<PersistentPropertyPath, Object
426446 }
427447
428448 private static class StagedValue {
429- @ Nullable
430- Object value ;
449+ @ Nullable Object value ;
431450 boolean isStaged ;
432451
433452 public StagedValue (@ Nullable Object value ) {
0 commit comments