15
15
*/
16
16
package org .springframework .data .jdbc .core ;
17
17
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 ;
19
28
import java .util .function .BiConsumer ;
20
29
import java .util .function .Function ;
21
30
import java .util .stream .Collectors ;
@@ -176,9 +185,9 @@ private Identifier getParentKeys(DbAction.WithDependingOn<?> action, JdbcConvert
176
185
177
186
Object id = getParentId (action );
178
187
188
+ AggregatePath aggregatePath = context .getAggregatePath (action .getPropertyPath ());
179
189
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 ));
182
191
183
192
for (Map .Entry <PersistentPropertyPath <RelationalPersistentProperty >, Object > qualifier : action .getQualifiers ()
184
193
.entrySet ()) {
@@ -188,20 +197,17 @@ private Identifier getParentKeys(DbAction.WithDependingOn<?> action, JdbcConvert
188
197
return identifier .build ();
189
198
}
190
199
191
- static Function <AggregatePath , Object > getValueProvider (Object idValue , AggregatePath path , JdbcConverter converter ) {
200
+ static Function <AggregatePath , Object > getIdMapper (Object idValue , AggregatePath path , JdbcConverter converter ) {
192
201
193
202
RelationalPersistentEntity <?> entity = converter .getMappingContext ()
194
- .getPersistentEntity (path .getIdDefiningParentPath ().getRequiredIdProperty (). getType () );
203
+ .getPersistentEntity (path .getIdDefiningParentPath ().getRequiredIdProperty ());
195
204
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 ());
205
211
}
206
212
207
213
private Object getParentId (DbAction .WithDependingOn <?> action ) {
0 commit comments