SDN5:找到多个匹配的@RelationshipEntity(14762) - [CONTAINS] - >(14781)但无法分辨使用哪一个

时间:2018-04-29 12:53:03

标签: java neo4j neo4j-ogm spring-data-neo4j-5 spring-data-neo4

我创建了两个不同的Spring Data Neo4j 5 @RelationshipEntity,它们的类型相同:

@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;

...

}

0 个答案:

没有答案