title: Bidirectional many-to-one with subclasses and generics
body: <p>I'm struggling a bit to implement a bi-directional many-to-one mapping between two class hierachies.</p>
  
  <p>I have the following:</p>
  
  <p>Superclass <code>Queue</code>, with subclasses <code>AQueue</code>, <code>BQueue</code>, <code>CQueue</code>.
  Superclass <code>Element</code>, with subclasses <code>AElement</code>, <code>BElement</code>, <code>CElement</code>.</p>
  
  <p><code>AQueue</code> has a list of <code>AElement</code>, <code>BQueue</code> has a list of <code>BElement</code>, and so on, <code>AElement</code> has a <code>AQueue</code> and so on.</p>
  
  <p>I have tried something like this:</p>
  
  <pre><code>@Entity
  @Inheritance(strategy InheritanceType.SINGLE_TABLE)
  public abstract class Queue&lt;T extends Element&gt; {
      @OneToMany(mappedBy="queue")
      private List&lt;T&gt; elements = new ArrayList&lt;&gt;();
      //...
  }
  
  @Entity
  @Inheritance(strategy = InheritanceType.JOINED)
  public abstract class Element&lt;T extends Element&gt; {
      @ManyToOne
      @JoinColumn("queue_id")
      private Queue&lt;T&gt; queue;
  }
  </code></pre>
  
  <p>only to have <code>Hibernate</code> complain about <code>mappedBy reference an unknown target entity property</code>.</p>
  
  <p>Is there a way to map such a relationship in the superclasses using generics, or do I have to opt for each of the subclass pairs maintaining one relationship each?    </p>