File tree Expand file tree Collapse file tree 1 file changed +7
-15
lines changed
spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert Expand file tree Collapse file tree 1 file changed +7
-15
lines changed Original file line number Diff line number Diff line change @@ -351,31 +351,23 @@ private Object readFrom(RelationalPersistentProperty property) {
351
351
@ Nullable
352
352
private Object readEmbeddedEntityFrom (@ Nullable Object idValue , RelationalPersistentProperty property ) {
353
353
354
- ReadingContext <?> ctx = extendBy (property );
355
- return hasInstanceValues (property , ctx ) ? ctx .createInstanceInternal (idValue ) : null ;
354
+ ReadingContext <?> newContext = extendBy (property );
355
+ return newContext . hasInstanceValues (idValue ) ? newContext .createInstanceInternal (idValue ) : null ;
356
356
}
357
357
358
- private boolean hasInstanceValues (RelationalPersistentProperty property , ReadingContext <?> ctx ) {
358
+ private boolean hasInstanceValues (Object idValue ) {
359
359
360
- RelationalPersistentEntity <?> persistentEntity = getMappingContext ()
361
- .getPersistentEntity (property .getTypeInformation ());
362
-
363
- PersistentPropertyPathExtension extension = ctx .path ;
360
+ RelationalPersistentEntity <?> persistentEntity = path .getLeafEntity ();
364
361
365
362
for (RelationalPersistentProperty embeddedProperty : persistentEntity ) {
366
363
364
+ // if the embedded contains Lists, Sets or Maps we consider it non-empty
367
365
if (embeddedProperty .isQualified () || embeddedProperty .isReference ()) {
368
366
return true ;
369
367
}
370
368
371
- try {
372
- if (ctx .getObjectFromResultSet (extension .extendBy (embeddedProperty ).getColumnName ()) != null ) {
373
- return true ;
374
- }
375
- } catch (MappingException e ) {
376
- if (ctx .getObjectFromResultSet (extension .extendBy (embeddedProperty ).getReverseColumnNameAlias ()) != null ) {
377
- return true ;
378
- }
369
+ if (readOrLoadProperty (idValue , embeddedProperty ) != null ) {
370
+ return true ;
379
371
}
380
372
}
381
373
You can’t perform that action at this time.
0 commit comments