title: Hibernate mapping for different items in the same table
body: <p>I have the following three classes <code>[Promotion, Product and Image]</code>. <code>Promotion</code> has an <code>Image</code>. <code>Product</code> has list/collection of <code>Image's</code>.  In the future there may be new classes that also has <code>Image</code> or Collection of <code>Image's</code>.</p>
  <p>I would like to put all images in the same image table <code>(eg:: image_table)</code>. It means that the image of <code>Promotion</code> and the collection of images in <code>Product</code> are all going to go into the same table.</p>
  <p>I can't put for instance two <code>@OneToMany/@ManyToOne</code> annotations in <code>Image</code> class because then there will be two different foreign keys <code>(Promotion_FK and Product_FK)</code> in Image table <code>(eg:: image_table)</code>. In the future if there are more classes that has image then I have to add additional  <code>@OneToMany/@ManyToOne</code> annotations.</p>
  <ol>
  <li><p>Is there a way to map this feature in Hibernate?</p>
  </li>
  <li><p>If my design is not good, in the real world how do they store images that belongs to different classes in the same table?</p>
  </li>
  </ol>