1515 */
1616package org .springframework .data .jdbc .core ;
1717
18- import java .util .*;
18+ import java .util .ArrayList ;
19+ import java .util .Arrays ;
20+ import java .util .Collections ;
21+ import java .util .HashMap ;
22+ import java .util .HashSet ;
23+ import java .util .LinkedHashMap ;
24+ import java .util .List ;
25+ import java .util .Map ;
26+ import java .util .Optional ;
27+ import java .util .Set ;
1928import java .util .function .BiConsumer ;
2029import java .util .function .Function ;
2130import java .util .stream .Collectors ;
@@ -176,9 +185,9 @@ private Identifier getParentKeys(DbAction.WithDependingOn<?> action, JdbcConvert
176185
177186 Object id = getParentId (action );
178187
188+ AggregatePath aggregatePath = context .getAggregatePath (action .getPropertyPath ());
179189 JdbcIdentifierBuilder identifier = JdbcIdentifierBuilder //
180- .forBackReferences (converter , context .getAggregatePath (action .getPropertyPath ()),
181- getValueProvider (id , context .getAggregatePath (action .getPropertyPath ()), converter ));
190+ .forBackReferences (converter , aggregatePath , getIdMapper (id , aggregatePath , converter ));
182191
183192 for (Map .Entry <PersistentPropertyPath <RelationalPersistentProperty >, Object > qualifier : action .getQualifiers ()
184193 .entrySet ()) {
@@ -188,20 +197,17 @@ private Identifier getParentKeys(DbAction.WithDependingOn<?> action, JdbcConvert
188197 return identifier .build ();
189198 }
190199
191- static Function <AggregatePath , Object > getValueProvider (Object idValue , AggregatePath path , JdbcConverter converter ) {
200+ static Function <AggregatePath , Object > getIdMapper (Object idValue , AggregatePath path , JdbcConverter converter ) {
192201
193202 RelationalPersistentEntity <?> entity = converter .getMappingContext ()
194- .getPersistentEntity (path .getIdDefiningParentPath ().getRequiredIdProperty (). getType () );
203+ .getPersistentEntity (path .getIdDefiningParentPath ().getRequiredIdProperty ());
195204
196- Function <AggregatePath , Object > valueProvider = ap -> {
197- if (entity == null ) {
198- return idValue ;
199- } else {
200- PersistentPropertyPathAccessor <Object > propertyPathAccessor = entity .getPropertyPathAccessor (idValue );
201- return propertyPathAccessor .getProperty (ap .getRequiredPersistentPropertyPath ());
202- }
203- };
204- return valueProvider ;
205+ if (entity == null ) {
206+ return aggregatePath -> idValue ;
207+ }
208+
209+ PersistentPropertyPathAccessor <Object > propertyPathAccessor = entity .getPropertyPathAccessor (idValue );
210+ return aggregatePath -> propertyPathAccessor .getProperty (aggregatePath .getRequiredPersistentPropertyPath ());
205211 }
206212
207213 private Object getParentId (DbAction .WithDependingOn <?> action ) {
0 commit comments