I need to create a new node of the class A, which has a relationship with the User node:
@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;
}
}
Now, let's suppose we have the following data for the new node A:
{
"id": 1,
"nodeId": "0001-0001",
"user": {
"id": 4,
"nodeId": "0002-0002",
"name": null,
"firstName": null
}
}
I'm trying to create the node A with a relationship between the new node A and the (already existing) node of the User who has the "id":4 and "nodeId":"0002-0002" (unique node identifier), but instead of that, the User node updates the fields "name" and "firstName" with to null
.
I'm using the GraphRepository proxy to create it:
@Repository
public interface ARepository extends GraphRepository<A> {
}
Is there any way to do it without this update, only making the relationship with the User node?