title: How to create database schema to persist special class hierarchy
body: <p>I have class hierarchy shown on image below which needs to be persisted. But I can't think of solution for relationships marked with red color.</p>
  
  <p>Assignment-ExtensionValue relationship means that in ExtesionValue there should be composite PK defined as (owner_oid,id) from Assignment, but relationship Role-ExtensionValue means there should be only simple PK defined as (oid) from Role.</p>
  
  <p><strong>owner_oid</strong> is mapped to <strong>object.oid</strong> I can't create new PK key for ExtensionValue if it's not really neccessary, because I would lost it during processing objects in business logic. How should it be persisted and how to map it with Hibernate annotations?</p>
  
  <p><img src="https://i.stack.imgur.com/QsuoE.png" alt="class hierarchy/hibernate pojos"></p>
  
  <p>I'm trying to persist objects like this</p>
  
  <pre><code>&lt;role oid="123"&gt;
      &lt;assignment id="1"&gt;
          &lt;some-extension-value&gt;foo&lt;/some-extension-value&gt;    &lt;--- THIS
          &lt;other-value&gt;1&lt;/other-value&gt;                        &lt;--- THIS
      &lt;/assignmen&gt;
      &lt;assignment id="2"&gt;some stuff&lt;/assignment&gt;
      ...other elements...
  &lt;/role&gt;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>&lt;user oid="232"&gt;
      &lt;extension-value&gt;bar&lt;/extension-value&gt;                  &lt;--- THIS
      ..other elements...
  &lt;/user&gt;
  </code></pre>