java - SDN5:为 (14762)-[CONTAINS]->(14781) 找到多个匹配的 @RelationshipEntity,但无法确定使用哪一个
问题描述
我创建了两个@RelationshipEntity
具有相同类型的不同 Spring Data Neo4j 5:
@RelationshipEntity(type = "CONTAINS")
public class CharacteristicRelationship {
@Id
@GeneratedValue
private Long id;
@StartNode
private CharacteristicGroup characteristicGroup;
@EndNode
private Characteristic characteristic;
}
@RelationshipEntity(type = "CONTAINS")
public class DecisionGroupRelationship {
@Id
@GeneratedValue
private Long id;
@StartNode
private Decision decision;
@EndNode
private DecisionGroup childGroup;
}
一切正常,我成功地通过了所有测试,但现在我在控制台中不断收到以下错误:
2018-04-29 15:36:52.387 ERROR 7664 --- [ main] org.neo4j.ogm.context.GraphEntityMapper : Found more than one matching @RelationshipEntity for (14762)-[CONTAINS]->(14781) but cannot tell which one to use
2018-04-29 15:36:52.390 ERROR 7664 --- [ main] org.neo4j.ogm.context.GraphEntityMapper : Found more than one matching @RelationshipEntity for (14762)-[CONTAINS]->(14779) but cannot tell which one to use
2018-04-29 15:36:52.391 ERROR 7664 --- [ main] org.neo4j.ogm.context.GraphEntityMapper : Found more than one matching @RelationshipEntity for (14762)-[CONTAINS]->(14774) but cannot tell which one to use
我做错了什么以及如何解决?是否允许@RelationshipEntity
相同类型的不同?
在org.neo4j.ogm.context.GraphEntityMapper.getRelationshipEntity(Edge)
我可以看到以下代码:
} else {
// almost definitely a user bug
logger.error("Found more than one matching @RelationshipEntity for {} but cannot tell which one to use",
edge.toString());
}
那只是打印错误日志,就是这样。从中真的很难理解 - 这是一个错误或否以及如何处理它。
课程:
@NodeEntity
public class CharacteristicGroup extends BaseEntity {
private static final String DEFINED_BY = "DEFINED_BY";
private static final String CONTAINS = "CONTAINS";
@Index(unique = true)
private Long id;
@Index(unique = false)
private String name;
@Index(unique = false)
private String lowerName;
@Relationship(type = DEFINED_BY, direction = Relationship.OUTGOING)
private Set<DecisionGroup> decisionGroups;
@Relationship(type = CONTAINS, direction = Relationship.OUTGOING)
private Set<CharacteristicRelationship> characteristicRelationships;
...
}
@NodeEntity
public class Characteristic extends BaseEntity {
private static final String CONTAINS = "CONTAINS";
@Index(unique = true)
private Long id;
@Index(unique = false)
private String name;
@Index(unique = false)
private String lowerName;
@Relationship(type = CONTAINS, direction = Relationship.OUTGOING)
private Set<CharacteristicProperty> properties;
@Relationship(type = CONTAINS, direction = Relationship.INCOMING)
private Set<CharacteristicRelationship> characteristicRelationships;
...
}
@NodeEntity
public class DecisionGroup extends BaseEntity {
private static final String CONTAINS_DECISION_GROUP = "CONTAINS_DECISION_GROUP";
@Index(unique = true)
private Long id;
@Index(unique = false)
private String name;
@Index(unique = false)
private String lowerName;
@Relationship(type = CONTAINS_DECISION_GROUP, direction = Relationship.INCOMING)
private Set<DecisionGroupRelationship> decisionGroupRelationships;
@Index(unique = false)
private int totalChildDecisions;
...
}
@NodeEntity
public class Decision extends BaseEntity {
private static final String DEFINED_BY = "DEFINED_BY";
private static final String CONTAINS = "CONTAINS";
private static final String CONTAINS_DECISION_GROUP = "CONTAINS_DECISION_GROUP";
public static final String FOLLOWS = "FOLLOWS";
@Index(unique = true)
private Long id;
@Index(unique = false)
private String name;
@Index(unique = false)
private String lowerName;
@Relationship(type = CONTAINS, direction = Relationship.INCOMING)
private Set<DecisionGroup> parentGroups;
@Relationship(type = CONTAINS_DECISION_GROUP, direction = Relationship.OUTGOING)
private Set<DecisionGroupRelationship> childGroupRelationships;
@Relationship(type = DEFINED_BY, direction = Relationship.INCOMING)
private Set<Media> medias;
@Index(unique = false)
private int totalViews;
...
}
@NodeEntity
public abstract class BaseEntity implements BaseEntityVisitable {
private static final String CREATED_BY = "CREATED_BY";
private static final String UPDATED_BY = "UPDATED_BY";
private static final String OWNED_BY = "OWNED_BY";
private static final String CONTAINS = "CONTAINS";
@Id
@GeneratedValue
private Long graphId;
@Index(unique = true)
private String uuid;
@Index(unique = true)
private String customId;
@DateLong
@Index(unique = false)
private Date createDate;
@Relationship(type = CREATED_BY, direction = Relationship.OUTGOING)
private User createUser;
@DateLong
@Index(unique = false)
private Date updateDate;
@Relationship(type = UPDATED_BY, direction = Relationship.OUTGOING)
private User updateUser;
@Relationship(type = OWNED_BY, direction = Relationship.OUTGOING)
private Set<BaseEntity> ownerEntities;
@Relationship(type = CONTAINS, direction = Relationship.OUTGOING)
private Set<Translation> translations;
...
}
解决方案
推荐阅读
- aframe - 带有 envmap 的 Aframe gltf-model 演示
- android - 在列表视图上编辑列表项
- kubernetes - Grafana 仪表板不显示 pod 名称,而是显示 pod_name
- blender - Blender 2.8 渲染选项卡中不显示照明
- bash - 在 BASH 中使用带有函数的等待命令后不保留变量
- python - 使用 Python 作为 ETL 工具
- python - 如何使用获取请求将默认值传递给表单?
- django - 如何通过在 django 中传递 url 和用户名 var 来确认删除用户
- html - 如何在这个 Angular 6 index.html 中添加元描述?
- ruby-on-rails - 如何在 Github 上更新已删除的文件