Java 保存到Neo4j删除值

Java 保存到Neo4j删除值,java,neo4j,spring-data-neo4j,Java,Neo4j,Spring Data Neo4j,我在应用程序中使用典型的用户->角色关系。我正在利用Neo4j通过RelationshipEntity注释在关系上添加元数据的能力。由于某些无法解释的原因,当我坚持我的关系时,角色的属性被“清空” 这是我的用户 public class Person { @GraphId Long id; private String name; @RelatedToVia(type="HAS_ROLE") @Fetch private Set<UserRol

我在应用程序中使用典型的用户->角色关系。我正在利用Neo4j通过RelationshipEntity注释在关系上添加元数据的能力。由于某些无法解释的原因,当我坚持我的关系时,角色的属性被“清空”

这是我的用户

public class Person {

    @GraphId Long id;

    private String name;

    @RelatedToVia(type="HAS_ROLE")
    @Fetch
    private Set<UserRoleRelationship> roles = new HashSet<UserRoleRelationship>();


    public Person() {}

    public Person(String name) { this.name = name; }
}
在填充与用户和角色的关系时,将设置所有数据。但是,当我坚持使用它时,角色的数据现在为空

// Before Save
UserRoleRelationship [id=null, person=Person [id=26, name=TestUser, roles=1], **role=Role [id=27, roleType=ADMIN, defaultPrivileges=[PRIV4, PRIV1, PRIV2, PRIV3]]**]

// After Save
UserRoleRelationship [id=6,    person=Person [id=26, name=TestUser, roles=0], **role=Role [id=27, roleType=null, defaultPrivileges=null]**]
我的角色对象为什么会出现这种情况

还有,这是我的回购协议

public interface PersonRepository extends CrudRepository<Person, String> {

    Person findByName(String name);

}

public interface RoleRepository extends CRUDRepository<Role> {

    Role findByRoleType(RoleType rt);
    Role findByRoleName(String name);
}

public interface UserRoleRepository extends CrudRepository<UserRoleRelationship, String> {}

它在保存后重新填充UserRoleRelationship

由于起始节点和结束节点上都没有@Fetch注释,因此它只以浅层方式加载它们

我不建议在那里添加@Fetch,因为它可以轻松加载整个图形,所以我可能会使用

template.fetch(rel.person);
template.fetch(rel.role);

发布之前/之后是语句之前和之后调试器中的值?如果是,请发布该语句并使用debuggerYes跟随流程。before是我填充它后的样子。后是我坚持后的回报it@Michael饥饿,有什么建议吗?看起来好像是因为RoleType和neo4j没有识别它。我只是想把它作为一个参考类,有没有其他方法可以做到这一点?
// Before Save
UserRoleRelationship [id=null, person=Person [id=26, name=TestUser, roles=1], **role=Role [id=27, roleType=ADMIN, defaultPrivileges=[PRIV4, PRIV1, PRIV2, PRIV3]]**]

// After Save
UserRoleRelationship [id=6,    person=Person [id=26, name=TestUser, roles=0], **role=Role [id=27, roleType=null, defaultPrivileges=null]**]
public interface PersonRepository extends CrudRepository<Person, String> {

    Person findByName(String name);

}

public interface RoleRepository extends CRUDRepository<Role> {

    Role findByRoleType(RoleType rt);
    Role findByRoleName(String name);
}

public interface UserRoleRepository extends CrudRepository<UserRoleRelationship, String> {}
template.fetch(rel.person);
template.fetch(rel.role);