title: Modeling single child/multiple parent tables
body: <p>I'm struggling to model the relationship between multiple tables (parents) that share a single table (child).</p>
  
  <p>Given the following parent 1 table (the other parent tables 2,3 and so on are similar):</p>
  
  <pre><code>@Entity
  @Table (name="parent1")
  public class ParentEntity1 {
  
      @Id 
      @Column(name="id")
      @GeneratedValue(strategy=GenerationType.IDENTITY)
      private Integer id;
  
      // relationship with child table
  
      @OneToMany(mappedBy = "parentId", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
      private Set&lt;ChildEntity&gt; children;
  
  
      // other columns of parent 1
  
  
  }
  </code></pre>
  
  <p>and the following child table:</p>
  
  <pre><code>@Entity
  @Table (name="children")
  public class ChildEntity {
  
      @Id 
      @Column(name="id")
      @GeneratedValue(strategy=GenerationType.IDENTITY)
      private Integer id;
  
      // points to the parent type; 1, 2, and so on
      @Column(name="parent_type")
      private Integer parentType;
  
      @Column(name="parent_id")
      private Integer parentId;
  
      // some other data that belongs to ChildEntity
  
  }
  </code></pre>
  
  <p>How do I persist one parent object and multiple children while creating the relationship? Note that the parent type is a column in the child table, and that both parent and child ids are auto-generated.</p>