4949 * @author Umut Erturk
5050 * @author Myeonghyeon Lee
5151 * @author Chirag Tailor
52+ * @author Mark Paluch
5253 */
5354@ SuppressWarnings ("rawtypes" )
5455class JdbcAggregateChangeExecutionContext {
@@ -268,12 +269,10 @@ <T> List<T> populateIdsIfNecessary() {
268269
269270 cascadingValues .stage (insert .getDependingOn (), insert .getPropertyPath (),
270271 qualifierValue , newEntity );
271-
272272 } else if (insert .getPropertyPath ().getLeafProperty ().isCollectionLike ()) {
273273
274274 cascadingValues .gather (insert .getDependingOn (), insert .getPropertyPath (),
275275 qualifierValue , newEntity );
276-
277276 }
278277 }
279278 }
@@ -289,6 +288,7 @@ <T> List<T> populateIdsIfNecessary() {
289288 return roots ;
290289 }
291290
291+ @ SuppressWarnings ("unchecked" )
292292 private <S > Object setIdAndCascadingProperties (DbAction .WithEntity <S > action , @ Nullable Object generatedId ,
293293 StagedValues cascadingValues ) {
294294
@@ -328,6 +328,7 @@ private PersistentPropertyPath<?> getRelativePath(DbAction<?> action, Persistent
328328 throw new IllegalArgumentException (String .format ("DbAction of type %s is not supported" , action .getClass ()));
329329 }
330330
331+ @ SuppressWarnings ("unchecked" )
331332 private <T > RelationalPersistentEntity <T > getRequiredPersistentEntity (Class <T > type ) {
332333 return (RelationalPersistentEntity <T >) context .getRequiredPersistentEntity (type );
333334 }
@@ -358,7 +359,7 @@ private <T> void updateWithVersion(DbAction.UpdateRoot<T> update) {
358359 */
359360 private static class StagedValues {
360361
361- static final List <MultiValueAggregator > aggregators = Arrays .asList (SetAggregator .INSTANCE , MapAggregator .INSTANCE ,
362+ static final List <MultiValueAggregator <?> > aggregators = Arrays .asList (SetAggregator .INSTANCE , MapAggregator .INSTANCE ,
362363 ListAggregator .INSTANCE , SingleElementAggregator .INSTANCE );
363364
364365 Map <DbAction , Map <PersistentPropertyPath , StagedValue >> values = new HashMap <>();
@@ -374,13 +375,14 @@ private static class StagedValues {
374375 * be {@literal null}.
375376 * @param value The value to be set. Must not be {@literal null}.
376377 */
377- @ SuppressWarnings ( "unchecked" )
378- < T > void stage ( DbAction <?> action , PersistentPropertyPath path , @ Nullable Object qualifier , Object value ) {
379- gather (action , path , qualifier , value );
380- values . get ( action ). get ( path ) .isStaged = true ;
378+ void stage ( DbAction <?> action , PersistentPropertyPath path , @ Nullable Object qualifier , Object value ) {
379+
380+ StagedValue gather = gather (action , path , qualifier , value );
381+ gather .isStaged = true ;
381382 }
382383
383- <T > void gather (DbAction <?> action , PersistentPropertyPath path , @ Nullable Object qualifier , Object value ) {
384+ @ SuppressWarnings ("unchecked" )
385+ <T > StagedValue gather (DbAction <?> action , PersistentPropertyPath path , @ Nullable Object qualifier , Object value ) {
384386
385387 MultiValueAggregator <T > aggregator = getAggregatorFor (path );
386388
@@ -391,19 +393,20 @@ <T> void gather(DbAction<?> action, PersistentPropertyPath path, @Nullable Objec
391393 persistentPropertyPath -> new StagedValue (aggregator .createEmptyInstance ()));
392394 T currentValue = (T ) stagedValue .value ;
393395
394- Object newValue = aggregator .add (currentValue , qualifier , value );
395-
396- stagedValue .value = newValue ;
396+ stagedValue .value = aggregator .add (currentValue , qualifier , value );
397397
398398 valuesForPath .put (path , stagedValue );
399+
400+ return stagedValue ;
399401 }
400402
401- private MultiValueAggregator getAggregatorFor (PersistentPropertyPath path ) {
403+ @ SuppressWarnings ("unchecked" )
404+ private <T > MultiValueAggregator <T > getAggregatorFor (PersistentPropertyPath path ) {
402405
403406 PersistentProperty property = path .getLeafProperty ();
404- for (MultiValueAggregator aggregator : aggregators ) {
407+ for (MultiValueAggregator <?> aggregator : aggregators ) {
405408 if (aggregator .handles (property )) {
406- return aggregator ;
409+ return ( MultiValueAggregator < T >) aggregator ;
407410 }
408411 }
409412
@@ -427,10 +430,10 @@ void forEachPath(DbAction<?> dbAction, BiConsumer<PersistentPropertyPath, Object
427430 }
428431
429432 private static class StagedValue {
430- Object value ;
433+ @ Nullable Object value ;
431434 boolean isStaged ;
432435
433- public StagedValue (Object value ) {
436+ public StagedValue (@ Nullable Object value ) {
434437 this .value = value ;
435438 }
436439 }
0 commit comments