【发布时间】:2016-04-02 16:05:55
【问题描述】:
我需要新建一个A类的节点,和User节点有关系:
@NodeEntity
public class A implements Serializable {
/**
* Graph node identifier
*/
@GraphId
private Long nodeId;
/**
* Enity identifier
*/
private String id;
//... more properties ...
@Relationship(type = "HAS_ADVERTISER", direction = Relationship.OUTGOING)
private User user;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof IdentifiableEntity)) return false;
IdentifiableEntity entity = (IdentifiableEntity) o;
if (!super.equals(o)) return false;
if (id != null) {
if (!id.equals(entity.id)) return false;
} else {
if (entity.id != null) return false;
}
return true;
}
}
@NodeEntity
public class User implements Serializable {
/**
* Graph node identifier
*/
@GraphId
private Long nodeId;
/**
* Enity identifier
*/
private String id;
//... more properties ...
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof IdentifiableEntity)) return false;
IdentifiableEntity entity = (IdentifiableEntity) o;
if (!super.equals(o)) return false;
if (id != null) {
if (!id.equals(entity.id)) return false;
} else {
if (entity.id != null) return false;
}
return true;
}
}
现在,假设我们有新节点 A 的以下数据:
{
"id": 1,
"nodeId": "0001-0001",
"user": {
"id": 4,
"nodeId": "0002-0002",
"name": null,
"firstName": null
}
}
我正在尝试使用新节点 A 与具有“id”:4 和“nodeId”:“0002-0002”(唯一节点标识符),但用户节点将字段“name”和“firstName”更新为null。
我正在使用 GraphRepository 代理来创建它:
@Repository
public interface ARepository extends GraphRepository<A> {
}
有没有什么办法不用这个更新,只和User节点建立关系?
【问题讨论】:
标签: neo4j spring-data-neo4j spring-data-neo4j-4