i didnt knew about romain's idea but a i think a bit of maven properties can help: https://github.com/rmpestano/cdi-crud/blob/master/src/test/resources/persistence.xml
in my case i change the properties via maven profile. maybe it helps. 2014-11-19 5:01 GMT-02:00 Romain Manni-Bucau [via TomEE & OpenEJB] < [email protected]>: > Hi > > The datasource is by spec indirect in EE so no issues here. Then with most > providers system properties are read as persistence unit properties. > Finally in TomEE you can set PERSISTENCEUNIT.<unit name>.<key>=<value> in > tomee properties including system properties. > Le 19 nov. 2014 05:36, "[hidden email] > <http://user/SendEmail.jtp?type=node&node=4672931&i=0>" <[hidden email] > <http://user/SendEmail.jtp?type=node&node=4672931&i=1>> a écrit : > > > The question is: "how can the persistence.xml, which is generally > included > > in the same JAR as the JPA domain objects and DAO related code (ie: > classes > > that use entity manager) be configured to handle different database > servers" > > > > There are two scenarios for this: > > 1. testing - currently thinking that Arquillian will handle this by > > deleting the persistence.xml and adding a testing specific one when the > WAR > > is built as part of the unit test - Other ideas / suggestions? > > 2. run-time - for example the WAR is provided to several customers. One > > customer runs Oracle and the other runs mysql. > > > > == > > Generally planning to use either H2 or HSQLDB (maybe in memory) for JPA > > based testing and another DB in production (MySQL, PostgreSQL, Oracle) > > > > Changing the datasource independently of the JAR or Code is quite easy > in > > a JEE container. However the persistence.xml is generally tailored to a > > specific DB (see below) which creates the issue. > > > > ex: > > <provider>... > > <property> various... probably can add for multiple DB's > > and those that do not apply will be ignored. > > hibernate.dialect > > org.hibernate.dialect > > > > > ------------------------------ > If you reply to this email, your message will be added to the discussion > below: > > http://tomee-openejb.979440.n4.nabble.com/Testing-Best-practices-JPA-persistence-xml-different-between-Arquillian-JUnit-test-and-deploy-in-Pron-tp4672930p4672931.html > To start a new topic under TomEE Users, email > [email protected] > To unsubscribe from TomEE Users, click here > <http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=979441&code=cm1wZXN0YW5vQGdtYWlsLmNvbXw5Nzk0NDF8MTE1OTM0ODgyNg==> > . > NAML > <http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > -- <http://www.advancedit.com.br/>Att, Rafael M. Pestano Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul Graduando em Ciência da Computação UFRGS http://conventionsframework.org <http://conventions.github.io/home/> http://rpestano.wordpress.com/ @realpestano -- View this message in context: http://tomee-openejb.979440.n4.nabble.com/Testing-Best-practices-JPA-persistence-xml-different-between-Arquillian-JUnit-test-and-deploy-in-Pron-tp4672930p4672939.html Sent from the TomEE Users mailing list archive at Nabble.com.
