1717
1818import java .lang .reflect .Constructor ;
1919import java .lang .reflect .Method ;
20- import java .util .*;
20+ import java .util .ArrayList ;
21+ import java .util .Arrays ;
22+ import java .util .Collection ;
23+ import java .util .Collections ;
24+ import java .util .HashSet ;
25+ import java .util .LinkedHashMap ;
26+ import java .util .List ;
27+ import java .util .Map ;
28+ import java .util .Optional ;
29+ import java .util .Set ;
2130import java .util .function .Predicate ;
2231import java .util .stream .Collectors ;
2332
4150import org .springframework .data .annotation .Reference ;
4251import org .springframework .data .convert .CustomConversions ;
4352import org .springframework .data .convert .TypeMapper ;
44- import org .springframework .data .mapping .*;
53+ import org .springframework .data .mapping .Association ;
54+ import org .springframework .data .mapping .InstanceCreatorMetadata ;
55+ import org .springframework .data .mapping .MappingException ;
56+ import org .springframework .data .mapping .Parameter ;
57+ import org .springframework .data .mapping .PersistentEntity ;
58+ import org .springframework .data .mapping .PersistentProperty ;
59+ import org .springframework .data .mapping .PersistentPropertyAccessor ;
4560import org .springframework .data .mapping .callback .EntityCallbacks ;
4661import org .springframework .data .mapping .context .MappingContext ;
4762import org .springframework .data .mapping .model .ConvertingPropertyAccessor ;
@@ -1961,6 +1976,8 @@ class AssociationAwareMongoDbPropertyValueProvider extends MongoDbPropertyValueP
19611976 @ SuppressWarnings ("unchecked" )
19621977 public <T > T getPropertyValue (MongoPersistentProperty property ) {
19631978
1979+ ConversionContext propertyContext = context .forProperty (property );
1980+
19641981 if (property .isDbReference () && property .getDBRef ().lazy ()) {
19651982
19661983 Object rawRefValue = accessor .get (property );
@@ -1977,9 +1994,16 @@ public <T> T getPropertyValue(MongoPersistentProperty property) {
19771994 }
19781995
19791996 if (property .isDocumentReference ()) {
1997+
19801998 return (T ) dbRefResolver .resolveReference (property ,
1981- new DocumentReferenceSource (accessor .getDocument (), accessor .get (property )),
1982- referenceLookupDelegate , context ::convert );
1999+ new DocumentReferenceSource (accessor .getDocument (), accessor .get (property )), referenceLookupDelegate ,
2000+ context ::convert );
2001+ }
2002+
2003+ if (property .isUnwrapped ()) {
2004+
2005+ return (T ) readUnwrapped (propertyContext , accessor , property ,
2006+ mappingContext .getRequiredPersistentEntity (property ));
19832007 }
19842008
19852009 return super .getPropertyValue (property );
0 commit comments