title: JPA Java mapping relations
body: <p>In Java, I have a superclass Element and 4 subclasses, lets call them ElementA, ElementB, ElementC, ElementD.</p>
  
  <p>Tables in my DB:  </p>
  
  <pre><code>Element(ElementID, title, description, targetGroup) : Primary key elementID  
  ElementA(ElementID,...) : Foreign key elementID   
  ElementB(ElementID,...) : Foreign key elementID   
  ElementC(ElementID,...) : Foreign key elementID  
  ElemendD(ElementID,...) : Foreign key elementID
  </code></pre>
  
  <p>I also have: LearningProgram and LearningProgramElement:</p>
  
  <pre><code>LearningProgram(programcode, ....) : Primary key programcode  
  LearningProgramElement(programcode, ElementID, dateFrom, dateUntil, ...) : Foreign key programcode, Foreign key elementID  
  </code></pre>
  
  <p>LearningProgramElement links an Element to a LearningProgram and also has some attributes of this relation:<br>
  An element can be in different LearningPrograms but will have different dateForm and dateUntil in each LearningProgram.</p>
  
  <p>Now in my Java I have in a LearningProgram object 4 lists:   </p>
  
  <pre><code>List&lt;LearningProgramElement&gt; elementA = new ArrayList&lt;&gt;();  
  List&lt;LearningProgramElement&gt; elementB = new ArrayList&lt;&gt;();  
  List&lt;LearningProgramElement&gt; elementC = new ArrayList&lt;&gt;();  
  List&lt;LearningProgramElement&gt; elementD = new ArrayList&lt;&gt;();
  </code></pre>
  
  <p>A LearningProgram object looks like this:</p>
  
  <pre><code>private String programcode;
  private int elementid;
  ...
  private Element element;
  </code></pre>
  
  <p>I now get 4 times the same list, containing ALL LearningProgramElement's.<br>
  How can I make my jpa annotations that in list elementA there are only LearningProgramElement's who have an Element of subclass ElementA, and so on?</p>