27
27
import org .springframework .core .CollectionFactory ;
28
28
import org .springframework .core .convert .converter .Converter ;
29
29
import org .springframework .core .log .LogAccessor ;
30
+ import org .springframework .data .mapping .InstanceCreatorMetadata ;
30
31
import org .springframework .data .mapping .MappingException ;
32
+ import org .springframework .data .mapping .Parameter ;
31
33
import org .springframework .data .mapping .PersistentEntity ;
32
34
import org .springframework .data .mapping .PersistentProperty ;
33
35
import org .springframework .data .mapping .PersistentPropertyAccessor ;
34
- import org .springframework .data .mapping .PreferredConstructor ;
35
- import org .springframework .data .mapping .PreferredConstructor .Parameter ;
36
36
import org .springframework .data .mapping .SimplePropertyHandler ;
37
37
import org .springframework .data .mapping .model .ParameterValueProvider ;
38
38
import org .springframework .data .util .ClassTypeInformation ;
@@ -76,8 +76,7 @@ public Object convertDirectly(Object entityInstance) {
76
76
77
77
Neo4jPersistentEntity <?> targetEntity = context .addPersistentEntity (ClassTypeInformation .from (targetType )).orElse (null );
78
78
Assert .notNull (targetEntity , "Target entity could not be created for a DTO" );
79
- PreferredConstructor <?, Neo4jPersistentProperty > constructor = targetEntity
80
- .getPersistenceConstructor ();
79
+ InstanceCreatorMetadata <?> creator = targetEntity .getInstanceCreatorMetadata ();
81
80
82
81
Object dto = context .getInstantiatorFor (targetEntity )
83
82
.createInstance (targetEntity ,
@@ -89,7 +88,7 @@ public Object convertDirectly(Object entityInstance) {
89
88
PersistentPropertyAccessor <Object > dtoAccessor = targetEntity .getPropertyAccessor (dto );
90
89
targetEntity .doWithProperties ((SimplePropertyHandler ) property -> {
91
90
92
- if (constructor != null && constructor . isConstructorParameter (property )) {
91
+ if (creator != null && creator . isCreatorParameter (property )) {
93
92
return ;
94
93
}
95
94
@@ -130,9 +129,9 @@ public Object convert(@Nullable EntityInstanceWithSource entityInstanceAndSource
130
129
PersistentPropertyAccessor <Object > sourceAccessor = sourceEntity .getPropertyAccessor (entityInstance );
131
130
132
131
Neo4jPersistentEntity <?> targetEntity = context .addPersistentEntity (ClassTypeInformation .from (targetType ))
133
- .orElseThrow (() -> new MappingException ("Could not add a persistent entity for the projection target type '" + targetType . getName () + "'." ));
134
- PreferredConstructor <?, ? extends PersistentProperty <?>> constructor = targetEntity
135
- . getPersistenceConstructor ();
132
+ .orElseThrow (() -> new MappingException (
133
+ "Could not add a persistent entity for the projection target type '" + targetType . getName () + "'." ));
134
+ InstanceCreatorMetadata <? extends PersistentProperty <?>> creator = targetEntity . getInstanceCreatorMetadata ();
136
135
137
136
Object dto = context .getInstantiatorFor (targetEntity )
138
137
.createInstance (targetEntity ,
@@ -142,8 +141,8 @@ public Object convert(@Nullable EntityInstanceWithSource entityInstanceAndSource
142
141
);
143
142
144
143
PersistentPropertyAccessor <Object > dtoAccessor = targetEntity .getPropertyAccessor (dto );
145
- targetEntity .doWithAll (property ->
146
- setPropertyOnDtoObject ( entityInstanceAndSource , sourceEntity , sourceAccessor , constructor , dtoAccessor , property ));
144
+ targetEntity .doWithAll (property -> setPropertyOnDtoObject ( entityInstanceAndSource , sourceEntity , sourceAccessor ,
145
+ creator , dtoAccessor , property ));
147
146
148
147
return dto ;
149
148
}
@@ -171,11 +170,12 @@ public <T> T getParameterValue(Parameter<T, Neo4jPersistentProperty> parameter)
171
170
};
172
171
}
173
172
174
- private void setPropertyOnDtoObject (EntityInstanceWithSource entityInstanceAndSource , PersistentEntity <?, ?> sourceEntity ,
175
- PersistentPropertyAccessor <Object > sourceAccessor , @ Nullable PreferredConstructor <?, ?> constructor ,
176
- PersistentPropertyAccessor <Object > dtoAccessor , Neo4jPersistentProperty property ) {
173
+ private void setPropertyOnDtoObject (EntityInstanceWithSource entityInstanceAndSource ,
174
+ PersistentEntity <?, ?> sourceEntity , PersistentPropertyAccessor <Object > sourceAccessor ,
175
+ @ Nullable InstanceCreatorMetadata <?> creator , PersistentPropertyAccessor <Object > dtoAccessor ,
176
+ Neo4jPersistentProperty property ) {
177
177
178
- if (constructor != null && constructor . isConstructorParameter (property )) {
178
+ if (creator != null && creator . isCreatorParameter (property )) {
179
179
return ;
180
180
}
181
181
0 commit comments