17
17
18
18
import java .lang .reflect .Constructor ;
19
19
import 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 ;
21
30
import java .util .function .Predicate ;
22
31
import java .util .stream .Collectors ;
23
32
41
50
import org .springframework .data .annotation .Reference ;
42
51
import org .springframework .data .convert .CustomConversions ;
43
52
import 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 ;
45
60
import org .springframework .data .mapping .callback .EntityCallbacks ;
46
61
import org .springframework .data .mapping .context .MappingContext ;
47
62
import org .springframework .data .mapping .model .ConvertingPropertyAccessor ;
@@ -1961,6 +1976,8 @@ class AssociationAwareMongoDbPropertyValueProvider extends MongoDbPropertyValueP
1961
1976
@ SuppressWarnings ("unchecked" )
1962
1977
public <T > T getPropertyValue (MongoPersistentProperty property ) {
1963
1978
1979
+ ConversionContext propertyContext = context .forProperty (property );
1980
+
1964
1981
if (property .isDbReference () && property .getDBRef ().lazy ()) {
1965
1982
1966
1983
Object rawRefValue = accessor .get (property );
@@ -1977,9 +1994,16 @@ public <T> T getPropertyValue(MongoPersistentProperty property) {
1977
1994
}
1978
1995
1979
1996
if (property .isDocumentReference ()) {
1997
+
1980
1998
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 ));
1983
2007
}
1984
2008
1985
2009
return super .getPropertyValue (property );
0 commit comments