47
47
import org .springframework .data .mapping .model .SpELExpressionParameterValueProvider ;
48
48
import org .springframework .data .relational .core .conversion .BasicRelationalConverter ;
49
49
import org .springframework .data .relational .core .conversion .RelationalConverter ;
50
- import org .springframework .data .relational .core .mapping .PersistentPropertyPathExtension ;
50
+ import org .springframework .data .relational .core .mapping .AggregatePath ;
51
+ import org .springframework .data .relational .core .mapping .RelationalMappingContext ;
51
52
import org .springframework .data .relational .core .mapping .RelationalPersistentEntity ;
52
53
import org .springframework .data .relational .core .mapping .RelationalPersistentProperty ;
53
54
import org .springframework .data .relational .core .sql .IdentifierProcessing ;
@@ -86,14 +87,14 @@ public class BasicJdbcConverter extends BasicRelationalConverter implements Jdbc
86
87
* Creates a new {@link BasicRelationalConverter} given {@link MappingContext} and a
87
88
* {@link JdbcTypeFactory#unsupported() no-op type factory} throwing {@link UnsupportedOperationException} on type
88
89
* creation. Use
89
- * {@link #BasicJdbcConverter(MappingContext , RelationResolver, CustomConversions, JdbcTypeFactory, IdentifierProcessing)}
90
+ * {@link #BasicJdbcConverter(RelationalMappingContext , RelationResolver, CustomConversions, JdbcTypeFactory, IdentifierProcessing)}
90
91
* (MappingContext, RelationResolver, JdbcTypeFactory)} to convert arrays and large objects into JDBC-specific types.
91
92
*
92
93
* @param context must not be {@literal null}.
93
94
* @param relationResolver used to fetch additional relations from the database. Must not be {@literal null}.
94
95
*/
95
96
public BasicJdbcConverter (
96
- MappingContext <? extends RelationalPersistentEntity <?>, ? extends RelationalPersistentProperty > context ,
97
+ RelationalMappingContext context ,
97
98
RelationResolver relationResolver ) {
98
99
99
100
super (context , new JdbcCustomConversions ());
@@ -116,7 +117,7 @@ public BasicJdbcConverter(
116
117
* @since 2.0
117
118
*/
118
119
public BasicJdbcConverter (
119
- MappingContext <? extends RelationalPersistentEntity <?>, ? extends RelationalPersistentProperty > context ,
120
+ RelationalMappingContext context ,
120
121
RelationResolver relationResolver , CustomConversions conversions , JdbcTypeFactory typeFactory ,
121
122
IdentifierProcessing identifierProcessing ) {
122
123
@@ -300,12 +301,13 @@ private JdbcValue tryToConvertToJdbcValue(@Nullable Object value) {
300
301
301
302
@ Override
302
303
public <T > T mapRow (RelationalPersistentEntity <T > entity , ResultSet resultSet , Object key ) {
303
- return new ReadingContext <T >(new PersistentPropertyPathExtension ( getMappingContext (), entity ),
304
+ return new ReadingContext <T >(getMappingContext (). getAggregatePath ( entity ),
304
305
new ResultSetAccessor (resultSet ), Identifier .empty (), key ).mapRow ();
305
306
}
306
307
308
+
307
309
@ Override
308
- public <T > T mapRow (PersistentPropertyPathExtension path , ResultSet resultSet , Identifier identifier , Object key ) {
310
+ public <T > T mapRow (AggregatePath path , ResultSet resultSet , Identifier identifier , Object key ) {
309
311
return new ReadingContext <T >(path , new ResultSetAccessor (resultSet ), identifier , key ).mapRow ();
310
312
}
311
313
@@ -350,8 +352,8 @@ private class ReadingContext<T> {
350
352
351
353
private final RelationalPersistentEntity <T > entity ;
352
354
353
- private final PersistentPropertyPathExtension rootPath ;
354
- private final PersistentPropertyPathExtension path ;
355
+ private final AggregatePath rootPath ;
356
+ private final AggregatePath path ;
355
357
private final Identifier identifier ;
356
358
private final Object key ;
357
359
@@ -360,26 +362,27 @@ private class ReadingContext<T> {
360
362
private final ResultSetAccessor accessor ;
361
363
362
364
@ SuppressWarnings ("unchecked" )
363
- private ReadingContext (PersistentPropertyPathExtension rootPath , ResultSetAccessor accessor , Identifier identifier ,
365
+ private ReadingContext (AggregatePath rootPath , ResultSetAccessor accessor , Identifier identifier ,
364
366
Object key ) {
365
367
RelationalPersistentEntity <T > entity = (RelationalPersistentEntity <T >) rootPath .getLeafEntity ();
366
368
367
369
Assert .notNull (entity , "The rootPath must point to an entity" );
368
370
369
371
this .entity = entity ;
370
372
this .rootPath = rootPath ;
371
- this .path = new PersistentPropertyPathExtension ( getMappingContext (), this .entity );
373
+ this .path = getMappingContext (). getAggregatePath ( this .entity );
372
374
this .identifier = identifier ;
373
375
this .key = key ;
374
376
this .propertyValueProvider = new JdbcPropertyValueProvider (path , accessor );
375
377
this .backReferencePropertyValueProvider = new JdbcBackReferencePropertyValueProvider (path , accessor );
376
378
this .accessor = accessor ;
377
379
}
378
380
379
- private ReadingContext (RelationalPersistentEntity <T > entity , PersistentPropertyPathExtension rootPath ,
380
- PersistentPropertyPathExtension path , Identifier identifier , Object key ,
381
+ private ReadingContext (RelationalPersistentEntity <T > entity , AggregatePath rootPath ,
382
+ AggregatePath path , Identifier identifier , Object key ,
381
383
JdbcPropertyValueProvider propertyValueProvider ,
382
384
JdbcBackReferencePropertyValueProvider backReferencePropertyValueProvider , ResultSetAccessor accessor ) {
385
+
383
386
this .entity = entity ;
384
387
this .rootPath = rootPath ;
385
388
this .path = path ;
@@ -393,7 +396,7 @@ private ReadingContext(RelationalPersistentEntity<T> entity, PersistentPropertyP
393
396
private <S > ReadingContext <S > extendBy (RelationalPersistentProperty property ) {
394
397
return new ReadingContext <>(
395
398
(RelationalPersistentEntity <S >) getMappingContext ().getRequiredPersistentEntity (property .getActualType ()),
396
- rootPath .extendBy (property ), path .extendBy (property ), identifier , key ,
399
+ rootPath .append (property ), path .append (property ), identifier , key ,
397
400
propertyValueProvider .extendBy (property ), backReferencePropertyValueProvider .extendBy (property ), accessor );
398
401
}
399
402
@@ -453,10 +456,10 @@ private Object readOrLoadProperty(@Nullable Object id, RelationalPersistentPrope
453
456
private Iterable <Object > resolveRelation (@ Nullable Object id , RelationalPersistentProperty property ) {
454
457
455
458
Identifier identifier = id == null //
456
- ? this .identifier .withPart (rootPath .getQualifierColumn (), key , Object .class ) //
457
- : Identifier .of (rootPath .extendBy (property ).getReverseColumnName (), id , Object .class );
459
+ ? this .identifier .withPart (rootPath .getTableInfo (). qualifierColumnInfo (). name (), key , Object .class ) //
460
+ : Identifier .of (rootPath .append (property ).getTableInfo (). reverseColumnInfo (). name (), id , Object .class );
458
461
459
- PersistentPropertyPath <? extends RelationalPersistentProperty > propertyPath = path .extendBy (property )
462
+ PersistentPropertyPath <? extends RelationalPersistentProperty > propertyPath = path .append (property )
460
463
.getRequiredPersistentPropertyPath ();
461
464
462
465
return relationResolver .findAllByPath (identifier , propertyPath );
0 commit comments