[FLOW3-general] Finding inherited objects in a repository

Peter Beernink p.beernink at drecomm.nl
Sun Feb 6 20:42:55 CET 2011


Hi all,

On a project I'm currently doing to get my FLOW3 knowledge up-to-date
again, I have come across an issue in the persistence layer which I'm
not sure how to tackle.

In my model I have the following three objects: 'Media', 'Movie',
'Book'.
Both Movie and Book extends the Media object.

I wish to be able to have a list of all books and movies in one
overview.
As they both extend Media, I was hoping it was possible to use a
MediaRepository for this.
Persisting the objects using the MediaRepository works without a
problem.

However, fetching the objects through this repository does not work.

As I would like to be able to add additional Media subtypes in the
future, I don't want to hard-code a query object in the repository.

An other way I thought of to solve this is to add a 'relatedObject'
property to the Media object and attach a Movie or Book object through
that.
But I don't like that solution that much either.

Any suggestions on an other solution which I overlooked?

Thanks in advance
Peter





More information about the FLOW3-general mailing list