Getting From IDs to the Real Objects a Query Needs
Why the ORM's own query methods are shaped around real relationships, not raw IDs, and the chain of lookups that turns a list of seat IDs into the ShowSeat objects worth checking.
ShowSeat holds a Seat object as its relationship, not a bare seat ID. That single fact decides how the actual lookup has to be written.
A Query Method Is Shaped by the Relationship, Not the ID
An ORM generates its query methods around the real relationships a class actually declares. Since ShowSeat holds a Seat object, the method for finding show-seats has to accept Seat objects too, not seat IDs, because there's no relationship to an ID for the ORM to build a method around in the first place.
That means the seat IDs arriving in the original request aren't enough on their own to run this query. They have to become real Seat objects first, through a separate lookup, before that second query can even be written.
The Chain: Seat IDs, Then Seats, Then ShowSeats
The full path looks like this, one step handing its result to the next:
- Start with the seat IDs the client actually sent.
- Look those IDs up to get the real
Seatobjects they refer to. - Use those
Seatobjects to look up the correspondingShowSeatrows, the ones that actually carry a status worth checking.
Every one of the earlier posts about IDs versus objects meets in this one chain. A client sends an ID because it's all a client should ever be trusted with. A repository query needs the real object because that's what the relationship it's built around actually declares. Both rules were correct all along, they just describe two different points in the same request's journey.
Keep reading