Mediaentity, which is used to catalog and organize all media items loaded in to my application.
Mediaentity contains all of the properties which are common to every media item uploaded in to my application. Let's say, however, that I need to have specific attributes that are available on only media for my
Bookentity ( e.g. whether the image is the cover photo, for example ). I can create a child class of
BookMediawhich extends my
Mediaentity. When loaded, all of the properties of
Mediawill be loaded along with the custom attributes which apply to my
joincolumn. The presence of this attribute on a child class signifies that it is a child entity of the parent and that the parent's properties should be loaded whenever the
BookMediaentity is loaded. In addition, the primary key of the entity is that of the parent.
joinColumn, which should be a foreign key to the parent identifier column:
Bookentity can use its extended media class to retrieve media items which are specific to its own purpose:
discriminatorValueattribute and will return that specific class when a retrieval is performed through the parent Entity. Let's take our
BookMediaclass, again, but this time defining it as a discriminated entity.
discriminatorColumnattribute to the
discriminatorValueproperty on the child class, the value of which is stored in the parent entity table:
BookMediaentity will be saved with a
mediatable. As such, the following query will result in only entities of
Mediatable contains a combination of non-book and book media, then the collection returned when querying all records will contain a mix of
BookMediaentities, however, will always return a collection of
BookMediaentities, because the
typecolumn value on the
mediamust be equal to