48
48
import org .springframework .data .mapping .PersistentPropertyPath ;
49
49
import org .springframework .data .mapping .PersistentPropertyPaths ;
50
50
import org .springframework .data .mapping .PropertyPath ;
51
+ import org .springframework .data .mapping .model .BeanWrapperPropertyAccessorFactory ;
51
52
import org .springframework .data .mapping .model .ClassGeneratingPropertyAccessorFactory ;
52
53
import org .springframework .data .mapping .model .EntityInstantiators ;
53
54
import org .springframework .data .mapping .model .InstantiationAwarePropertyAccessorFactory ;
89
90
public abstract class AbstractMappingContext <E extends MutablePersistentEntity <?, P >, P extends PersistentProperty <P >>
90
91
implements MappingContext <E , P >, ApplicationEventPublisherAware , ApplicationContextAware , InitializingBean {
91
92
93
+ private static final boolean IN_NATIVE_IMAGE = System .getProperty ("org.graalvm.nativeimage.imagecode" ) != null ;
94
+
92
95
private final Optional <E > NONE = Optional .empty ();
93
96
private final Map <TypeInformation <?>, Optional <E >> persistentEntities = new HashMap <>();
94
97
private final PersistentPropertyAccessorFactory persistentPropertyAccessorFactory ;
@@ -110,7 +113,8 @@ protected AbstractMappingContext() {
110
113
this .persistentPropertyPathFactory = new PersistentPropertyPathFactory <>(this );
111
114
112
115
EntityInstantiators instantiators = new EntityInstantiators ();
113
- ClassGeneratingPropertyAccessorFactory accessorFactory = new ClassGeneratingPropertyAccessorFactory ();
116
+ PersistentPropertyAccessorFactory accessorFactory = IN_NATIVE_IMAGE ? BeanWrapperPropertyAccessorFactory .INSTANCE
117
+ : new ClassGeneratingPropertyAccessorFactory ();
114
118
115
119
this .persistentPropertyAccessorFactory = new InstantiationAwarePropertyAccessorFactory (accessorFactory ,
116
120
instantiators );
0 commit comments