title: JPA, EclipseLink, PostgreSQL and schemas
body: <p>I want to develop a Java EE application with JPA (EclipseLink implementation) and PostgreSQL as database.</p>
  
  <p>I chose to have one database and multiples schemas instead of having multiples databases and one schema per database.</p>
  
  <p>So, in my persistence.xml I have something like that :</p>
  
  <pre><code>&lt;persistence-unit name="00" transaction-type="JTA"&gt;
  
      &lt;provider&gt;org.eclipse.persistence.jpa.PersistenceProvider&lt;/provider&gt;
      &lt;jta-data-source&gt;todo&lt;/jta-data-source&gt;
  
      &lt;class&gt;...&lt;/class&gt;
      &lt;class&gt;...&lt;/class&gt;
  
      &lt;properties&gt;
          &lt;property name="javax.persistence.target-database" value="PostgreSQL" /&gt;
          &lt;property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" /&gt;
          &lt;property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/testdb;create=true" /&gt;
          &lt;property name="javax.persistence.jdbc.user" value="user" /&gt;
          &lt;property name="javax.persistence.jdbc.password" value="userpwd" /&gt;
      &lt;/properties&gt;
  
  &lt;/persistence-unit&gt;
  
  &lt;persistence-unit name="01" transaction-type="JTA"&gt;
  
      &lt;provider&gt;org.eclipse.persistence.jpa.PersistenceProvider&lt;/provider&gt;
      &lt;jta-data-source&gt;todo&lt;/jta-data-source&gt;
  
      &lt;class&gt;...&lt;/class&gt;
      &lt;class&gt;...&lt;/class&gt;
  
      &lt;properties&gt;
          &lt;property name="javax.persistence.target-database" value="PostgreSQL" /&gt;
          &lt;property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" /&gt;
          &lt;property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/testdb;create=true" /&gt;
          &lt;property name="javax.persistence.jdbc.user" value="user" /&gt;
          &lt;property name="javax.persistence.jdbc.password" value="userpwd" /&gt;
      &lt;/properties&gt;
  
  &lt;/persistence-unit&gt;
  </code></pre>
  
  <p>I can easily reference persistence unit :</p>
  
  <pre><code>EntityManagerFactory emf = Persistence.createEntityManagerFactory("01");
  EntityManager em = emf.createEntityManager();
  </code></pre>
  
  <p>but how can I store information about schemas in persistence.xml ? I want to access schema <code>00</code> or <code>01</code> in <code>testdb</code> database.</p>
  
  <p>I probably could change schema via native SQL directly but is there a way to bind schema to persistence unit ?</p>
  
  <p>Thank you</p>