Hmm, can you be a bit more specific about your "quick test"? How did you set
your datasource properties then?
Setting these two properties to "", I keep getting an exception regarding a
non-existent transaction manager.
Meanwhile, I've found a solution that works for me.
persistence.xml:
<persistence-unit name="mymodel">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<jta-data-source>jdbc/MyDataSource</jta-data-source>
<class>...</class>
</persistence-unit>
Test fixture set-up:
Map<String, Object> props = new HashMap<String, Object>();
props.put("javax.persistence.jdbc.driver", driver);
props.put("javax.persistence.jdbc.url", url);
props.put("javax.persistence.jdbc.user", user);
props.put("javax.persistence.jdbc.password", password);
// Properties for the alternate non-jta-data-source. We need to set
these
// to override the jta-data-source in persistence.xml
props.put("openjpa.Connection2DriverName", driver);
props.put("openjpa.Connection2URL", url);
props.put("openjpa.Connection2UserName", user);
props.put("openjpa.Connection2Password", password);
// create the schema
props.put("openjpa.jdbc.SynchronizeMappings",
"buildSchema(ForeignKeys=false)");
EntityManagerFactory emf =
Persistence.createEntityManagerFactory(persistenceUnit, props);
em = emf.createEntityManager();
The trick is you have to set both the Connection* and the Connection2*
properties. Don't ask me why, though...
Tested with OpenJPA 2.0.0.
Regards,
Harald
--
View this message in context:
http://openjpa.208410.n2.nabble.com/Override-jta-data-source-with-system-properties-tp4173119p5312588.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.