The cypher query to perform the above task would be as follows:
MATCH (a:Buyer), (b:Seller) MERGE (a) -[:BUY {quantity: 150}]-> (b);
I want the equivalent Neo4jRepository function or some equivalent code that can serve the same above purpose. Please post the answer if you know some solution.
[Updates]
I have posted an answer below. But I am also expecting some other kind of solutions to this purpose. Please feel free to post alternative solutions as answers.
One Possible Way
If we have two Nodes/Entities as
BuyerandStockas POJO classes in SpringBoot Code, and if we are trying to add a relationship called [:HAS] between two such nodes then we can do the following.So we can do this to create the desired relationship.
Here
buyerRepois the object of a Repository that implementsNeo4jRepository<Buyer, Long>