File tree 2 files changed +30
-2
lines changed
main/java/org/springframework/data/neo4j/core/mapping
test/java/org/springframework/data/neo4j/core/mapping
2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change 16
16
package org .springframework .data .neo4j .core .mapping ;
17
17
18
18
import java .lang .reflect .Field ;
19
+ import java .util .Collections ;
19
20
import java .util .Optional ;
20
21
21
22
import org .springframework .data .annotation .ReadOnlyProperty ;
@@ -209,7 +210,13 @@ public boolean isAssociation() {
209
210
210
211
@ Override
211
212
public boolean isEntity () {
212
- return super .isEntity () && !isWritableProperty .get ();
213
+ return super .isEntity () && !isWritableProperty .get () && !this .isAnnotationPresent (ConvertWith .class );
214
+ }
215
+
216
+ @ Override
217
+ public Iterable <? extends TypeInformation <?>> getPersistentEntityTypeInformation () {
218
+ return this .isAnnotationPresent (ConvertWith .class ) ? Collections .emptyList ()
219
+ : super .getPersistentEntityTypeInformation ();
213
220
}
214
221
215
222
@ Override
@@ -219,7 +226,7 @@ public boolean isEntityWithRelationshipProperties() {
219
226
220
227
@ Override
221
228
public Neo4jPersistentPropertyConverter <?> getOptionalConverter () {
222
- return customConversion .getOptional ()
229
+ return isEntity () ? null : customConversion .getOptional ()
223
230
.map (Neo4jPersistentPropertyConverter .class ::cast )
224
231
.orElse (null );
225
232
}
Original file line number Diff line number Diff line change 34
34
import org .springframework .data .annotation .Transient ;
35
35
import org .springframework .data .mapping .AssociationHandler ;
36
36
import org .springframework .data .mapping .MappingException ;
37
+ import org .springframework .data .neo4j .core .convert .ConvertWith ;
37
38
import org .springframework .data .neo4j .core .schema .DynamicLabels ;
38
39
import org .springframework .data .neo4j .core .schema .GeneratedValue ;
39
40
import org .springframework .data .neo4j .core .schema .Id ;
@@ -57,6 +58,16 @@ void persistentEntityCreationWorksForCorrectEntity() {
57
58
neo4jMappingContext .getPersistentEntity (CorrectEntity2 .class );
58
59
}
59
60
61
+ @ Test
62
+ void skipsEntityTypeDetectionForConvertedProperties () {
63
+
64
+ Neo4jPersistentEntity <?> entity = new Neo4jMappingContext ().getRequiredPersistentEntity (WithConvertedProperty .class );
65
+ Neo4jPersistentProperty property = entity .getRequiredPersistentProperty ("converted" );
66
+
67
+ assertThat (property .isEntity ()).isFalse ();
68
+ assertThat (property .getPersistentEntityTypeInformation ()).isEmpty ();
69
+ }
70
+
60
71
@ Nested
61
72
class ReadOnlyProperties {
62
73
@@ -730,4 +741,14 @@ static class WithAnnotatedProperties {
730
741
@ Property (readOnly = false )
731
742
private String writableProperty ;
732
743
}
744
+
745
+ static class WithConvertedProperty {
746
+
747
+ @ ConvertWith
748
+ IWillBeConverted converted ;
749
+ }
750
+
751
+ static class IWillBeConverted {
752
+
753
+ }
733
754
}
You can’t perform that action at this time.
0 commit comments