我需要一些建议来给关系命名。另外,我不确定如何用弹簧数据注释我的域实体。我见过的大多数示例都是单向的,并且选择的名称非常简单。
假设以下示例:
@NodeEntity
public class Person {
@Indexed
private String name;
@RelatedTo(type="OWNS", direction=Direction.OUTGOING)
private Set<Car> cars;
}
关系名称似乎还可以,没问题。
现在假设我想让这种关系是双向的。以下方法有什么区别(以及优缺点)。
1) 使关系的双方direction=Direction.BOTH 并调用关系type="OWNERSHIP"?
@NodeEntity
public class Person {
@Indexed
private String name;
@RelatedTo(type="OWNERSHIP", direction=Direction.BOTH)
private Set<Car> cars;
}
@NodeEntity
public class Car {
@Indexed
private String description;
@RelatedTo(type="OWNERSHIP", direction=Direction.BOTH)
private Person person;
}
2) 两边都使用方向?
@NodeEntity
public class Person {
@Indexed
private String name;
@RelatedTo(type="OWNS", direction=Direction.OUTGOING)
private Set<Car> cars;
}
@NodeEntity
public class Car {
@Indexed
private String description;
@RelatedTo(type="OWNED_BY", direction=Direction.INCOMING)
private Person person;
}