Let's say that I have a class/table called Images
that, as it stands right now, is bound in a manner similar to this:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Domain.Image, Domain" table="Images">
<id name="id" column="ImageID" access="field" unsaved-value="0">
<generator class="identity" />
</id>
<!-- other properties -->
<property name="AssociatedObjectID" column="AssociatedObjectID" />
<property name="AssociatedObjectType" column="AssociatedObjectType" />
</class>
</hibernate-mapping>
Up until this point, this schema has worked, because a image was only associated with one object, so I could keep that reference without a discriminator.
However, now I wish to have a collection of these images on another entity called a PhotoShoot
. Each PhotoShoot
can have several images.
Is there a way to bind a collection such that I can have a List<Image>
within PhotoShoot
without extracting a base class and using the table-per-hierarchy inheritance pattern?
And if not, is table-per-hierarchy really the best way to go here? I hate to create subclasses, especially since there is nothing that needs to be abstracted from the Image
entity.