@@ -405,35 +405,53 @@ protected void writePartialUpdate(PartialUpdate<?> update, RedisData sink) {
405
405
ClassTypeInformation .OBJECT , sink );
406
406
continue ;
407
407
}
408
- if (targetProperty .isCollectionLike ()) {
409
408
410
- Collection <Object > c = pUpdate .getValue () instanceof Collection ? (Collection <Object >) pUpdate .getValue ()
409
+ if (targetProperty .isAssociation ()) {
410
+
411
+ if (targetProperty .isCollectionLike ()) {
412
+
413
+ KeyValuePersistentEntity <?> ref = mappingContext .getPersistentEntity (
414
+ targetProperty .getAssociation ().getInverse ().getTypeInformation ().getComponentType ().getActualType ());
415
+
416
+ int i = 0 ;
417
+ for (Object o : (Collection <?>) pUpdate .getValue ()) {
418
+
419
+ Object refId = ref .getPropertyAccessor (o ).getProperty (ref .getIdProperty ());
420
+ sink .getBucket ().put (pUpdate .getPropertyPath () + ".[" + i + "]" ,
421
+ toBytes (ref .getKeySpace () + ":" + refId ));
422
+ i ++;
423
+ }
424
+ } else {
425
+
426
+ KeyValuePersistentEntity <?> ref = mappingContext
427
+ .getPersistentEntity (targetProperty .getAssociation ().getInverse ().getTypeInformation ());
428
+
429
+ Object refId = ref .getPropertyAccessor (pUpdate .getValue ()).getProperty (ref .getIdProperty ());
430
+ sink .getBucket ().put (pUpdate .getPropertyPath (), toBytes (ref .getKeySpace () + ":" + refId ));
431
+ }
432
+ }
433
+
434
+ else if (targetProperty .isCollectionLike ()) {
435
+
436
+ Collection <?> collection = pUpdate .getValue () instanceof Collection ? (Collection <?>) pUpdate .getValue ()
411
437
: Collections .<Object > singleton (pUpdate .getValue ());
412
- writeCollection (entity .getKeySpace (), pUpdate .getPropertyPath (), c , targetProperty . getTypeInformation () ,
413
- sink );
438
+ writeCollection (entity .getKeySpace (), pUpdate .getPropertyPath (), collection ,
439
+ targetProperty . getTypeInformation (), sink );
414
440
} else if (targetProperty .isMap ()) {
415
441
416
442
Map <Object , Object > map = new HashMap <Object , Object >();
417
443
418
444
if (pUpdate .getValue () instanceof Map ) {
419
- map .putAll ((Map ) pUpdate .getValue ());
445
+ map .putAll ((Map <?, ?> ) pUpdate .getValue ());
420
446
} else if (pUpdate .getValue () instanceof Map .Entry ) {
421
- map .put (((Map .Entry ) pUpdate .getValue ()).getKey (), ((Map .Entry ) pUpdate .getValue ()).getValue ());
447
+ map .put (((Map .Entry <?, ?> ) pUpdate .getValue ()).getKey (), ((Map .Entry <?, ?> ) pUpdate .getValue ()).getValue ());
422
448
} else {
423
449
throw new MappingException (
424
450
String .format ("Cannot set update value for map property '%s' to '%s'. Please use a Map or Map.Entry." ,
425
451
pUpdate .getPropertyPath (), pUpdate .getValue ()));
426
452
}
427
453
428
454
writeMap (entity .getKeySpace (), pUpdate .getPropertyPath (), targetProperty .getMapValueType (), map , sink );
429
- } else if (targetProperty .isAssociation ()) {
430
-
431
- KeyValuePersistentEntity <?> ref = mappingContext
432
- .getPersistentEntity (targetProperty .getAssociation ().getInverse ().getTypeInformation ());
433
-
434
- Object refId = ref .getPropertyAccessor (pUpdate .getValue ()).getProperty (ref .getIdProperty ());
435
-
436
- sink .getBucket ().put (pUpdate .getPropertyPath (), toBytes (ref .getKeySpace () + ":" + refId ));
437
455
} else {
438
456
439
457
writeInternal (entity .getKeySpace (), pUpdate .getPropertyPath (), pUpdate .getValue (),
0 commit comments