cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

OGM - Java Spring - how to avoid creating dupplicated Relationshis as MERGE

MalteR
Node Link

Dear sirs or madams,

I want to create a merge like statement which either merges a Relationships with an existing one or creates one if not existing, is there any way to do this without querying before?

I want to create a MERGE statement programatically.

Is there any switch doing this in the code?

		Entity entityFrom = entityRepo.findByID(nodeFrom);
		Entity entityTo = entityRepo.findByID(nodeTo);
		eERel.setNodeFrom(entityFrom);
		eERel.setNodeTo(entityTo);
		eERel.setType(type);
		eERel.setSubType(subType);
		eERel.setSource("MANUALLY CREATED");
		List<ConnectionFromEntityToEntity> entityToEntities = new ArrayList();
		entityToEntities.add(eERel);
		entityFrom.setEntities_out(entityToEntities);

		entityRepo.save(entityFrom);
type or paste code here

the Repository class looks like this:

@RelationshipEntity(type = "CONNECTION_TO")
public class ConnectionFromEntityToEntity {
	
	@Id @GeneratedValue private Long id;
	String type;
	String subType; 
	
	@StartNode
	Entity nodeFrom;
	
	@EndNode
	Entity nodeTo;
	
	private String source;

Thank you very much in advance.

Kindest regards,

Malte

0 REPLIES 0
Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online