File tree Expand file tree Collapse 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 Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change 1616package org .springframework .data .neo4j .core .mapping ;
1717
1818import java .lang .reflect .Field ;
19+ import java .util .Collections ;
1920import java .util .Optional ;
2021
2122import org .springframework .data .annotation .ReadOnlyProperty ;
@@ -209,7 +210,13 @@ public boolean isAssociation() {
209210
210211 @ Override
211212 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 ();
213220 }
214221
215222 @ Override
@@ -219,7 +226,7 @@ public boolean isEntityWithRelationshipProperties() {
219226
220227 @ Override
221228 public Neo4jPersistentPropertyConverter <?> getOptionalConverter () {
222- return customConversion .getOptional ()
229+ return isEntity () ? null : customConversion .getOptional ()
223230 .map (Neo4jPersistentPropertyConverter .class ::cast )
224231 .orElse (null );
225232 }
Original file line number Diff line number Diff line change 3434import org .springframework .data .annotation .Transient ;
3535import org .springframework .data .mapping .AssociationHandler ;
3636import org .springframework .data .mapping .MappingException ;
37+ import org .springframework .data .neo4j .core .convert .ConvertWith ;
3738import org .springframework .data .neo4j .core .schema .DynamicLabels ;
3839import org .springframework .data .neo4j .core .schema .GeneratedValue ;
3940import org .springframework .data .neo4j .core .schema .Id ;
@@ -57,6 +58,16 @@ void persistentEntityCreationWorksForCorrectEntity() {
5758 neo4jMappingContext .getPersistentEntity (CorrectEntity2 .class );
5859 }
5960
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+
6071 @ Nested
6172 class ReadOnlyProperties {
6273
@@ -730,4 +741,14 @@ static class WithAnnotatedProperties {
730741 @ Property (readOnly = false )
731742 private String writableProperty ;
732743 }
744+
745+ static class WithConvertedProperty {
746+
747+ @ ConvertWith
748+ IWillBeConverted converted ;
749+ }
750+
751+ static class IWillBeConverted {
752+
753+ }
733754}
You can’t perform that action at this time.
0 commit comments