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
- GH-2973: Persist type information on relationship properties (#2974) Add an optional parameter to `@RelationshipProperties` that allows users to persist the type information on this relationship. Thi... — committed to spring-projects/spring-data-neo4j by yangyaofei 2 years ago
- GH-2973: Persist type information on relationship properties (#2974) Add an optional parameter to `@RelationshipProperties` that allows users to persist the type information on this relationship. Thi... — committed to spring-projects/spring-data-neo4j by yangyaofei 2 years ago
- GH-2973: Persist type information on relationship properties (#2974) Add an optional parameter to `@RelationshipProperties` that allows users to persist the type information on this relationship. Thi... — committed to spring-projects/spring-data-neo4j by yangyaofei 2 years ago
- GH-2973: Persist type information on relationship properties (#2974) Add an optional parameter to `@RelationshipProperties` that allows users to persist the type information on this relationship. T... — committed to injectives/spring-data-neo4j by yangyaofei 2 years ago
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.