Closed NorDar closed 5 months ago
In the end my attempts at implementing everything with just userId's without breaking the db relations were futile.
There were a lot of race conditions when loading a plant from the database. It was not possible to generate the Id on the fly there.
I opted with a solution that is not according to the plan but looks like this:
POST to localhost:8080/plants that creates a plant with one owner and two caretakers:
{ "plantName": "initialPlant", "species": "initialSpecies", "careInstructions": "Only water at night.", "lastWateringDate": "1910-11-09T23:00:00.000+00:00", "nextWateringDate": "1910-11-12T23:00:00.000+00:00", "wateringInterval": 3, "owner": {"id": 1}, "caretakers": [{"id":2}, {"id":3}] }
The following PUT will update the Plant:
{ "plantName": "initialPlant", "species": "initialSpecies", "careInstructions": "Only water at night.", "lastWateringDate": "1910-11-09T23:00:00.000+00:00", "nextWateringDate": "1910-11-12T23:00:00.000+00:00", "wateringInterval": 3, "owner": {"id": 4}, "caretakers": [ {"id": 1} ] }
Additionally: 70c554b0f1407e1d2d345a89dec60edbf8166abe fixes a small bug recognised while experimenting with eager loading. Persisted Plants can not be deleted until also removed from the relation.
I am merging this so I can deploy it right now.
In the end my attempts at implementing everything with just userId's without breaking the db relations were futile.
There were a lot of race conditions when loading a plant from the database. It was not possible to generate the Id on the fly there.
I opted with a solution that is not according to the plan but looks like this:
POST to localhost:8080/plants that creates a plant with one owner and two caretakers:
The following PUT will update the Plant:
Additionally: 70c554b0f1407e1d2d345a89dec60edbf8166abe fixes a small bug recognised while experimenting with eager loading. Persisted Plants can not be deleted until also removed from the relation.