我需要Device\Software
从Entity
到Entity
的参数不同。
Device\Software
将存储在数据库中,一旦新的Entity
被创建,它将与已存储的某些Device\Software
建立关系,但其参数可能会因不同的Entities
而异(参数数量或其值。)
我尝试直接在图表的边缘保存其他参数(在RelationshipEntity
和Entity
之间的Device\Software
),但似乎在实施某些网络比较算法时会增加复杂性
有没有人有类似的情况?什么是最佳实践方法?
@NodeEntity
public class Entity {
@GraphId
protected Long id;
protected String title;
/**
* More fields here
*/
@Fetch
@RelatedTo(direction = Direction.BOTH, type = "has_devices")
protected Set<Device> devices = new HashSet<>();
@Fetch
@RelatedTo(direction = Direction.BOTH, type = "has_software")
protected Set<Software> software = new HashSet<>();
}
@NodeEntity
public class Device {
@GraphId
protected Long id;
protected String identifier;
/**
* More fields here
*/
@Fetch
@RelatedTo(direction = Direction.BOTH, type = "has_parameter")
protected Collection<ParameterEntity> parameter = new HashSet<>();
}
@NodeEntity
public class Software {
@GraphId
protected Long id;
protected String identifier;
/**
* More fields here
*/
@Fetch
@RelatedTo(direction = Direction.BOTH, type = "has_parameter")
protected Collection<ParameterEntity> parameter = new HashSet<>();
}
ParameterEntity
只是键值对象。
答案 0 :(得分:1)
不确定你的参数是什么意思。但是保存他们的关系应该有效。如果您不需要,可以忽略算法中的参数。
这实际上取决于你的参数只是量化关系,还是它们本身就是真实的实体。