44
44
import org .springframework .data .mapping .PersistentPropertyPath ;
45
45
import org .springframework .data .mapping .PersistentPropertyPaths ;
46
46
import org .springframework .data .mapping .PropertyPath ;
47
+ import org .springframework .data .mapping .model .BeanWrapperPropertyAccessorFactory ;
47
48
import org .springframework .data .mapping .model .ClassGeneratingPropertyAccessorFactory ;
48
49
import org .springframework .data .mapping .model .EntityInstantiators ;
49
50
import org .springframework .data .mapping .model .InstantiationAwarePropertyAccessorFactory ;
85
86
public abstract class AbstractMappingContext <E extends MutablePersistentEntity <?, P >, P extends PersistentProperty <P >>
86
87
implements MappingContext <E , P >, ApplicationEventPublisherAware , ApplicationContextAware , InitializingBean {
87
88
89
+ private static final boolean IN_NATIVE_IMAGE = System .getProperty ("org.graalvm.nativeimage.imagecode" ) != null ;
90
+
88
91
private final Optional <E > NONE = Optional .empty ();
89
92
private final Map <TypeInformation <?>, Optional <E >> persistentEntities = new HashMap <>();
90
93
private final PersistentPropertyAccessorFactory persistentPropertyAccessorFactory ;
@@ -106,7 +109,8 @@ protected AbstractMappingContext() {
106
109
this .persistentPropertyPathFactory = new PersistentPropertyPathFactory <>(this );
107
110
108
111
EntityInstantiators instantiators = new EntityInstantiators ();
109
- ClassGeneratingPropertyAccessorFactory accessorFactory = new ClassGeneratingPropertyAccessorFactory ();
112
+ PersistentPropertyAccessorFactory accessorFactory = IN_NATIVE_IMAGE ? BeanWrapperPropertyAccessorFactory .INSTANCE
113
+ : new ClassGeneratingPropertyAccessorFactory ();
110
114
111
115
this .persistentPropertyAccessorFactory = new InstantiationAwarePropertyAccessorFactory (accessorFactory ,
112
116
instantiators );
0 commit comments