I have an entity Venue with its Events:
Event { ID, Name, DateTime }
Venue { ID, Name, @OneToMany List<Event> events}
What I would like to achieve is to be able to call these functions in view (with OpenEntityManagerInView):
customVenue.getId(); // no problem
customVenue.getName(); // no problem
customVenue.getEvents(); // no problem
customVenue.getCurrentEvents(); // hm?
customVenue.getPastEvents(); // hm?
There might be thousands of events in the database, so iterating over the “events” to get the current ones might not be a good idead.
Is this a correct approach? Is this feasible? How can I split events in current and past and to have them ordered?
Thanks!
Of course it’s possible. But not using a method of customVenue (unless the entity has a reference to the entity manager, which is a bad idea).
Execute a query: