Suppose 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 the correct HAL recommendations, I should not expose entity identifiers. Since I do not have a bi-directional relationship, I cannot PUT or PATCH until http://localhost:8080/persons .
Even if I created the relationship, I probably would not want to first POST Task before /tasks , and then PUT before /persons (mobile clients are going to kill me). But even then, I donβt have a Task ID even from the returned Entity, so I can PUT to the Person object. (I obviously can do the parsing, but I don't think this is appropriate).
I probably would not want to have a list of 1000 tasks in a Person object. Therefore, not exporting the Task object is actually not an option (and this means that PATCH will not work)
So, how can I associate Person with Task if I cannot get its identifier? What is the right approach?
spring spring-data-rest spring-hateoas
Chrisgeo
source share