Is it possible with Eclipselink (or even better with standard JPA 2.x) to use JPQL or SQL to define a calculated collection mapping?
We have the following tables:
- story
- substory (foreign key to story)
- substory_x_company (foreign key to substory and company)
- company
Therefore I created three entities:
- Story (has many SubStories)
- SubStory (has many Companies)
- Company
So far so good, no problem. But now the requirement:
I should map a collection of all companies (ordered by name) in the entity Story and it would be good if this would be possible directly inside the entity (instead of using a separate DAO or even collect and sort all companies from the sub-stories). I'm asking this, because Story has 15 other relations, designed the same way as described above and I like to minimize boilerplate if possible.
Please don't criticize the table structure, as I cannot change it for the moment ;-)
Thanks a lot in advance for all your inputs!