title: Persist collection of interface using Hibernate
body: <p>I want to persist my litte zoo with Hibernate:</p>
  
  <pre><code>@Entity
  @Table(name = "zoo") 
  public class Zoo {
      @OneToMany
      private Set&lt;Animal&gt; animals = new HashSet&lt;Animal&gt;();
  }
  
  // Just a marker interface
  public interface Animal {
  }
  
  @Entity
  @Table(name = "dog")
  public class Dog implements Animal {
      // ID and other properties
  }
  
  @Entity
  @Table(name = "cat")
  public class Cat implements Animal {
      // ID and other properties
  }
  </code></pre>
  
  <p>When I try to persist the zoo, Hibernate complains:</p>
  
  <pre><code>Use of @OneToMany or @ManyToMany targeting an unmapped class: blubb.Zoo.animals[blubb.Animal]
  </code></pre>
  
  <p>I know about the <code>targetEntity</code>-property of <code>@OneToMany</code> but that would mean, only Dogs OR Cats can live in my zoo.</p>
  
  <p>Is there any way to persist a collection of an interface, which has several implementations, with Hibernate?</p>