spring-data-neo4j: [BUG] Multi Relationships cannot get right conversion

If I have a BaseNode with Map type relationships defined with a base class

@Node
public class BaseNode {
    @Id
    @GeneratedValue
    private UUID id;

    @Relationship(direction = Relationship.Direction.OUTGOING)
    private Map<String, List<BaseRelationship>> relationships = new HashMap<>();
}

@RelationshipProperties
public abstract class BaseRelationship {
    @RelationshipId
    @GeneratedValue
    private Long id;
    @TargetNode
    private BaseNode targetNode;
}

And I have two real class for relationship:

@RelationshipProperties
public class Relationship extend BaseRelationship{

}

@RelationshipProperties
public class AnotherRelationship extend BaseRelationship{

}

If there is a BaseNode with both two relationships :

var node = new BaseNode();
node.setRelationships(Map.of(
    "relation", List.of(
        new Relationship(), new AnotherRelationship()
    )
))
baseNodeRepository.save(node)
// the node and relations store in neo4j is good with clear type

Since SDN in node can get right instance, I think the relationship will get right, but the code below, the relationships will get same type of instance, both the Relationship or AnotherRelationship, cannot Get Proper type.

var node = baseNodeRepository.findById(id);
List<BaseRelationship> relationships = node.getRelationships().get("relation");

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Take your time. And don’t hesitate to ask questions or push unpolished code. We will support you.

@meistermeier okay, I will try this tomorrow.