title: How to exclude or include a package from a JPA persistence unit
body: <p>In my application I have two distinct sets of entities, and for each of them I want to use a separate persistence unit.</p>
  
  <p>How can I make it so each persistence unit only handles part of the entities I have annotated with <code>@Entity</code>?</p>
  
  <p>I have them distributed in two distinct packages, so I was planning to do something like this in the two <code>orm.xml</code> i have:</p>
  
  <pre><code>&lt;entity-mappings&gt;
      &lt;persistence-unit-metadata&gt;
          &lt;persistence-unit-defaults&gt;
              &lt;schema&gt;first_schema&lt;/schema&gt;
          &lt;/persistence-unit-defaults&gt;
      &lt;/persistence-unit-metadata&gt;
  
      &lt;package&gt;example.package.first&lt;/package&gt;
  &lt;/entity-mappings&gt;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>&lt;entity-mappings&gt;
      &lt;persistence-unit-metadata&gt;
          &lt;persistence-unit-defaults&gt;
              &lt;schema&gt;second_schema&lt;/schema&gt;
          &lt;/persistence-unit-defaults&gt;
      &lt;/persistence-unit-metadata&gt;
  
      &lt;package&gt;example.package.second&lt;/package&gt;
  &lt;/entity-mappings&gt;
  </code></pre>
  
  <p>But it does not work</p>