Neo4j 实现NodeEntity基类,标签的含义
对于每个继承的节点类,我希望有以下类型的基类Neo4j 实现NodeEntity基类,标签的含义,neo4j,spring-data-neo4j,Neo4j,Spring Data Neo4j,对于每个继承的节点类,我希望有以下类型的基类 @NodeEntity public abstract class NodeEntityBase { // id is not used with advanced mapping spring-data-neo4j. @GraphId protected Long id; @Indexed(unique = true) @NotNull protected String appId; 但如果我实现了这一点,Spring-data-neo4j
@NodeEntity
public abstract class NodeEntityBase {
// id is not used with advanced mapping spring-data-neo4j.
@GraphId
protected Long id;
@Indexed(unique = true)
@NotNull
protected String appId;
但如果我实现了这一点,Spring-data-neo4j将为每个节点创建NodeEntityBase标签。我真的没有用这个标签做任何事情,我担心这是否会成为以后的性能问题(或其他一些问题)。我知道标签索引中的条目有20亿(int max)的限制,这可能会成为一个问题,因此我想解决这个问题
是否有好的解决方法或设计来实现这一点?我非常希望有一个基类,我可以在其中放置几乎每个节点都继承的属性(如创建的时间戳等)。我知道我可以使用接口(如果接口也被标记,我还没有测试),但我更高兴的是,我不需要将setter/getter放在每个继承的类中
当有数百万个节点时,性能会下降吗?我再说一遍,我不会在查询中使用这个标签。20亿的限制可能足够大了,所以我可以忘记这一点。你可以尝试只在你的具体类上设置@NodeEntity
@NodeEntity
public abstract class NodeEntityBase {
// id is not used with advanced mapping spring-data-neo4j.
@GraphId
protected Long id;
@Indexed(unique = true)
@NotNull
protected String appId;
或者使用TypeRepresentationStrategy的一个实现,它只写一个标签
像这样
appId最好是@index(unique=true,level=INSTANCE),但这不是问题所在