title: JPA Child Class Referenced By Multiple Different Parent Classes
body: <p>I met the following ORM problem:</p>
  
  <p>I am having two classes A and B who both are having a Set of class C:</p>
  
  <pre><code>class A {
    @Id
    @GeneratedValue
    private long id;
  
    @OneToMany
    private Set&lt;C&gt; cSet;
  }
  
  class B {
    @Id
    @GeneratedValue
    private long id;
  
    @OneToMany
    private Set&lt;C&gt; cSet;
  }
  
  class C {
    @Id
    @GeneratedValue
    private long id;
  }
  </code></pre>
  
  <p>One idea I had was using a MappedSuperclass for C and having two extended classes that are each referenced in either A or B. But from an object oriented point  of view this is not the nicest approach although I could use the superclass type in order to work with them.</p>
  
  <p>Is there any nicer way to realize this model?</p>
  
  <p>Thanks,
  Benjamin</p>