Skip to content

Commit 46fcb04

Browse files
Ensure that the association target type is never null a property
describes an association.
1 parent 91b57a0 commit 46fcb04

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/main/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jPersistentProperty.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ final class DefaultNeo4jPersistentProperty extends AnnotationBasedPersistentProp
7070
this.graphPropertyName = Lazy.of(this::computeGraphPropertyName);
7171
this.isAssociation = Lazy.of(() -> {
7272

73+
// Bail out early, this is pretty much explicit
74+
if (isAnnotationPresent(Relationship.class)) {
75+
return true;
76+
}
7377
Class<?> targetType = getActualType();
7478
return !(simpleTypeHolder.isSimpleType(targetType) || this.mappingContext.hasCustomWriteTarget(targetType)
7579
|| isAnnotationPresent(TargetNode.class) || isComposite() || isAnnotationPresent(ConvertWith.class));
@@ -166,14 +170,11 @@ private TypeInformation<?> getRelationshipPropertiesTargetType(Class<?> relation
166170
@Override
167171
public Class<?> getAssociationTargetType() {
168172

169-
Class<?> associationTargetType = super.getAssociationTargetType();
170-
if (associationTargetType != null) {
171-
return associationTargetType;
172-
} else if (isDynamicOneToManyAssociation()) {
173+
if (isDynamicOneToManyAssociation()) {
173174
TypeInformation<?> actualType = getTypeInformation().getRequiredActualType();
174175
return actualType.getRequiredComponentType().getType();
175176
} else {
176-
return null;
177+
return getActualType();
177178
}
178179
}
179180

0 commit comments

Comments
 (0)