title: EclipseLink - JPA and MOXy - different views on the same data model
body: <p>here is the challange...</p>
  
  <p>I have a complex distributed system based on the same model</p>
  
  <p>It looks like this:</p>
  
  <pre><code>A &lt;-(XML)-&gt; B &lt;-(JSON)-&gt; C
  </code></pre>
  
  <p>A, B and C are different Applications basicaly <strong>based on the same model</strong>, so I decided to maintain the model in a seperate Java (Maven) Project.</p>
  
  <ul>
  <li>Each application uses JPA for persistance</li>
  <li>Each application uses and persists <strong>only a subset of the entities attributes</strong></li>
  <li>The data exchange format ist based on the same model (XML or JSON with MOXy)</li>
  <li>There are two exchange formats which uses <strong>only a subset of the entities attributes</strong></li>
  </ul>
  
  <p>Here is a more technical example of an entity (pseudocode):</p>
  
  <pre><code>class Foo {
    a;
    ab;
    bc;
    c;
    ac;
    // ...
  }
  </code></pre>
  
  <p>where a is used by the Application A, ab is used by the Application A and the Application B, bc is used by the Application B and C, etc...</p>
  
  <p>The same requirement for the exchange format.</p>
  
  <p>Do you have any idea how to implement it?</p>
  
  <p>Best regards.</p>
  
  <p>Edit:
  The probably best solution for that problem is to autogenerate different classes out of a global model. Taken the Entity from the example above, this would looks like this:</p>
  
  <p>Application A:</p>
  
  <pre><code>class Foo {
    a;
    ab;
    ac;
    // ...
  }
  </code></pre>
  
  <p>Application B:</p>
  
  <pre><code>class Foo {
    ab;
    bc;
    // ...
  }
  </code></pre>