在代码中有一个静态变量,用于初始化Node Entity的变量classID,
@NodeEntity
public class Person{
@GraphId
Long id;
@Indexed(unique = true)
private Integer personID;
private static int nextID = 0;
public Person(){
this.personID=nextID++;
} }
执行时,我得到一个用于nextID变量的NPE。我们如何在SDN的aspectj映射中设置静态变量 提前谢谢。
答案 0 :(得分:1)
personID
?使用@GraphId id
用于生成唯一的节点ID,因此我没有看到为1个实体/节点使用2个唯一ID的重点。@GraphId
生成ID是糟糕的设计。每当您重新启动应用程序时,您都会在数据库中获得重复项(nextID将设置为0)。