Я создал два разных 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
с одинаковыми типами?
at 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;
...
}