title: Can I set the schema before creating the EntityManager?
body: <p>I need to use multiply persistence units with different properties (in my case MySQL and Oracle database). In persistence.xml I define two different "persistence-unit"s and list only the entity classes there.</p>
  
  <p>Properties could be set in persitence.xml with</p>
  
  <p><code>&lt;properties&gt;
        &lt;property name="..." value="..." /&gt;
  ...</code></p>
  
  <p>Im doing it in a java class before creating the EntityManager, because I must use different properties (which I read before):</p>
  
  <pre><code>        EntityManagerFactory factory;
          ...
          HashMap&lt;String, String&gt; dbProperties = new HashMap&lt;String, String&gt;();
          dbProperties.put("javax.persistence.jdbc.driver", driver);
          dbProperties.put("javax.persistence.jdbc.url", url);
          dbProperties.put("javax.persistence.jdbc.user", user);
          dbProperties.put("javax.persistence.jdbc.password", password);
          dbProperties.put("eclipselink.ddl-generation", "none");
          dbProperties.put("eclipselink.ddl-generation.output-mode", "database");
  
          factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME, dbProperties);
          EntityManager em = factory.createEntityManager();
          ...
  </code></pre>
  
  <p>For Oracle I need to set schema dynamicly (if possible) and not hardcoded in @Table annotation in each Entity class.</p>
  
  <p>For now I am using a constant (means it is not dynamicly)</p>
  
  <pre><code>@Table(name="MYTABLE", schema = Constants.ORACLE_SCHEMA)
  </code></pre>
  
  <p>I want to use</p>
  
  <pre><code>@Table(name="MYTABLE")
  </code></pre>
  
  <p>And set the schema as property</p>
  
  <pre><code>dbProperties.put(...)
  </code></pre>
  
  <p>Is there such a property?</p>
  
  <p>On my search I found a syntax which could help</p>
  
  <pre><code>ALTER SESSION SET CURRENT_SCHEMA=MYSCHEMA
  </code></pre>
  
  <p>But I don't know how to combine it with EntityManager.</p>
  
  <p>I have allready asked about all available properties <a href="https://stackoverflow.com/questions/34178886/is-it-possible-to-find-all-available-entitymanager-properties">here</a>, but could not find anything yet.</p>
  
  <p>Thank you in advance.</p>