OGM: MappingException: Relationship entity cannot have a missing start or end node

I have 2 entities, Player(p) and Team(t) and I am trying to create the following rich relationship while adding a new Player with an existing team:

(p)-[PLAYS_FOR{"Batsman"}]->(t)

However when I try to do this, I get an exception stating:
MappingException: Relationship entity com.ipfl.data.domains.PLRole@669056a1 cannot have a missing start or end node.

Below are the classes:

@NodeEntity
public class Player extends Person {

	@Property
	private String nationality;
	
	@Relationship(type="PLAYS_FOR")
	private PLRole plrole;
}

@JsonIgnoreProperties("player")
@RelationshipEntity(type = "PLAYS_FOR")
public class PLRole {
	

@Id @GeneratedValue
Long id;

@Property(name="PLRole")
private Set<String> plroles;

@StartNode
private Player player;

@EndNode
private PLTeam plteam;
}

@NodeEntity
public class PLTeam {
	
	@Id @GeneratedValue
	Long id;
	
	@Property
	private String name;
}

Below is the JSON i am sending to my application via REST:
curl -d '{"name":"Player1","nationality":"Country1","plrole":{"plroles":["Batsman","Captain"],"plteam":{"id":41,"name":"Team1"}}' -H"Content-Type: application/json" -X POST http://localhost:8080/player/create

How can this error be fixed? WHat would I be doing wrong?

If you're trying to put a label on your relationship, then this is what you need to do:

(p)-[:PLAYS_FOR {position: "Batsman"}]->(t)

Unfortunately in Neo4j, you cannot dynamically assign the relationship with a variable, so ensure you're placing labels like that. In addition do you have a representation of the query you're trying to run in Cypher? Like:

MATCH (p:Player {id: "PlayerID"})-[r:PLAYS_FOR]->(t:Team {id: "TeamID"})
SET r.postion = "Batsman"
RETURN p

Something of that nature? It'll help to understand what you're doing because your error is explicitly stating that you're failing to provide a start or end node to your process.

Thank you Michael for the response!

I haven't written an explicit Cypher for this.

I was hoping OGM to handle it, like it does when creating simple relationship. My expectation was while creating Player(which is the start node), pass the PLRole (Which is the Rich Relationship) details and OGM will be able to map it. However this seems to be an incorrect approach.

No worries, yeah it looks like you'll need to create a function to call an internal Cypher query to make that update. Hopefully, you're on the right path now and welcome to the community!

Thank you Michael! Yes, I am able to persist rich relationship now, though I am not sure its the most ideal way to do it. (GIT Link: https://github.com/rnairg/ipfl/tree/master/src/main)