Hi,
You should be able to do this by specifying the property when creating
your EMFs. You can do this with the
OpenJPAPersistence.createEntityManagerFactory(String, Map) signature.
Note that doing this will mean that you've got a separate EMF for
every schema.
-Patrick
On Apr 11, 2008, at 8:26 AM, Scherer, Annette wrote:
Hallo,
I use OpenJPA to connect to DB2
I want to dynamically change openjpa.jdbc.Schema Property
I tried doing it like this:
emf = Persistence.createEntityManagerFactory("TestDB")
Properties properties = new Properties();
properties.put("openjpa.jdbc.Schema", "Test");
EntityManager em = emf.createEntityManager(properties);
I got this Exception:
<openjpa-1.0.2-r420667:627158 nonfatal user error>
org.apache.openjpa.persistence.ArgumentException: Missing getter for
property "Jdbc.Schema" in type "class
org.apache.openjpa.persistence.EntityManagerImpl".
Configuring Schema in persistence.xml works fine. Hier is my
persistence.xml:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="DomaenenDB">
<provider>
org.apache.openjpa.persistence.PersistenceProviderImpl
</provider>
<jta-data-source>java:comp/env/jdbc/domaenendb</jta-data-source>
<properties>
<property name="openjpa.TransactionMode"
value="managed"/>
<property name="openjpa.ConnectionFactoryMode"
value="managed"/>
<property name="openjpa.jdbc.DBDictionary"
value="db2"/>
<property name="openjpa.jdbc.Schema"
value="Test"/>
</properties>
</persistence-unit>
Can you help?
Greetings
Annette Scherer
Abteilung Informatik
--
Patrick Linskey
202 669 5907