I have a JPA entity Person and an entity Team. Both are joined by an entity PersonToTeam. This joining entity holds a many-to-one relation to
After running into the same issue I found a solution. Your code should be fine, except I return new PersonToTeamId()
instead of the DefaultIdConverter
if id
is null
in fromRequestId()
.
Assuming you are using JSON in your post request you have to wrap personId
and teamId
in an id
object:
{
"id": {
"personId": "foo",
"teamId": "bar"
},
...
}
And in cases where a part of the @EmbeddedId
is not a simple data type but a foreign key:
{
"id": {
"stringId": "foo",
"foreignKeyId": "http://localhost:8080/path/to/other/resource/1"
},
...
}