Lets say I have the following structure:
@Entity
class Person extends AbstractPersistable<Long> {
String name
String surname
}
@Entity
class Task extends AbstractPersistable<Long> {
String description
@ManyToOne
Person person
}
If I follow proper HAL
guidelines I'm not supposed to expose entity id's. Since I don't have a bi-directional relationship I cant PUT
or PATCH
to http://localhost:8080/persons
.
Even if I did create the relation, I probably wouldn't want to first POST
the Task
to /tasks
and then PUT
to /persons
, (mobile clients are going to kill me). But even then I don't have the Task ID
even from the returned Entity so I can PUT
to the Person
entity. (I obviously can string parse but I don't think it's appropriate).
I probably wouldnt want to have a list of 1000 tasks in the Person
entity either. So not exporting the Task
entity is not really an option (and this means PATCH
will not work)
So how am I supposed to associate the Person
with the Task
if I cannot get his id? What is the correct approach?