41
41
import org .springframework .data .mapping .PersistentPropertyAccessor ;
42
42
import org .springframework .data .mapping .PersistentPropertyPathAccessor ;
43
43
import org .springframework .data .mapping .context .MappingContext ;
44
- import org .springframework .data .mapping .model .ConvertingPropertyAccessor ;
45
- import org .springframework .data .mapping .model .DefaultSpELExpressionEvaluator ;
46
- import org .springframework .data .mapping .model .EntityInstantiator ;
47
- import org .springframework .data .mapping .model .ParameterValueProvider ;
48
- import org .springframework .data .mapping .model .PersistentEntityParameterValueProvider ;
49
- import org .springframework .data .mapping .model .PropertyValueProvider ;
50
- import org .springframework .data .mapping .model .SimpleTypeHolder ;
51
- import org .springframework .data .mapping .model .SpELContext ;
52
- import org .springframework .data .mapping .model .SpELExpressionEvaluator ;
53
- import org .springframework .data .mapping .model .SpELExpressionParameterValueProvider ;
44
+ import org .springframework .data .mapping .model .*;
54
45
import org .springframework .data .projection .EntityProjection ;
55
46
import org .springframework .data .projection .EntityProjectionIntrospector ;
56
47
import org .springframework .data .projection .EntityProjectionIntrospector .ProjectionPredicate ;
@@ -561,15 +552,16 @@ private Object readEmbedded(ConversionContext conversionContext, RelationalPrope
561
552
RowDocumentAccessor source , RelationalPersistentProperty property ,
562
553
RelationalPersistentEntity <?> persistentEntity ) {
563
554
564
- if (shouldReadEmbeddable (conversionContext , property , persistentEntity , provider )) {
555
+ if (shouldReadEmbeddable (conversionContext , property , persistentEntity , provider , source )) {
565
556
return read (conversionContext , persistentEntity , source );
566
557
}
567
558
568
559
return null ;
569
560
}
570
561
571
562
private boolean shouldReadEmbeddable (ConversionContext context , RelationalPersistentProperty property ,
572
- RelationalPersistentEntity <?> unwrappedEntity , RelationalPropertyValueProvider propertyValueProvider ) {
563
+ RelationalPersistentEntity <?> unwrappedEntity , RelationalPropertyValueProvider propertyValueProvider ,
564
+ RowDocumentAccessor source ) {
573
565
574
566
OnEmpty onEmpty = property .getRequiredAnnotation (Embedded .class ).onEmpty ();
575
567
@@ -579,8 +571,19 @@ private boolean shouldReadEmbeddable(ConversionContext context, RelationalPersis
579
571
580
572
for (RelationalPersistentProperty persistentProperty : unwrappedEntity ) {
581
573
582
- RelationalPropertyValueProvider contextual = propertyValueProvider
583
- .withContext (context .forProperty (persistentProperty ));
574
+ ConversionContext nestedContext = context .forProperty (persistentProperty );
575
+ RelationalPropertyValueProvider contextual = propertyValueProvider .withContext (nestedContext );
576
+
577
+ if (persistentProperty .isEmbedded ()) {
578
+
579
+ TypeInformation <?> typeInformation = persistentProperty .getTypeInformation ();
580
+
581
+ RelationalPersistentEntity <?> nestedEntity = getMappingContext ().getPersistentEntity (typeInformation );
582
+
583
+ if (readEmbedded (nestedContext , contextual , source , persistentProperty , nestedEntity ) != null ) {
584
+ return true ;
585
+ }
586
+ }
584
587
585
588
if (contextual .hasValue (persistentProperty )) {
586
589
return true ;
0 commit comments