If you are using a data source then hibernate.connection.driver_class
should not be necessary.
The other ones are needed. Why do you want to externalize them?
Btw. in our tests we have properties for hibernate, eclipselink and
openjpa side by side. So we can switch the persistence provider without
changing the persistence.xml.
For a real project the typical case is to use an embedded DB for tests
and a bigger one for prod. There again it should not hurt to have both
configs in the same persistence.xml.
Christian
On 16.09.2015 12:24, Delaire, Jonathan wrote:
Hi Guys!
I’m currently working on a large refactoring of a project with the
goal of using the JPA Aries within an OSGi container for persistence
(rather than plain old J2EE stack).
Currently so far so good, I’m following the guidance of the tasklit
blueprint (it is managed jpa) example from your website and everything
works fine (I’m using felix 5, with the aries jpa 2.1 version and
hibernate 4.3+ as orm)
I’m trying to make the solution the most configurable as possible,
currently my persistence.xml look like this:
/<?xml version="1.0" encoding="UTF-8"?>/
//
/<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
<http://java.sun.com/xml/ns/persistence%20http:/java.sun.com/xml/ns/persistence/persistence_1_0.xsd>//"/
/version="1.0">/
/ <persistence-unit name="Audit" transaction-type="JTA"> /
/
<jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/audit)</jta-data-source>/
//
/ <properties>/
/<property name="hibernate.connection.driver_class"
value="org.apache.derby.jdbc.EmbeddedDriver"/>/
/<property name="hibernate.dialect"
value="org.hibernate.dialect.DerbyDialect"/>/
/<property name="hibernate.hbm2ddl.auto" value="create-drop"/>/
/ </properties>/
/ </persistence-unit>/
/</persistence>/
I have externalized the dataSource configuration using blueprint-cm
with configAdmin so for the dataSource it is working good.
But now I’m left with these properties in red, what do you think would
be the most elegant way of externalizing them ?
Note that my entityManager is injected like this:
/ /**/
/ * EntityManager, injected by blueprint jpa./
/ *//
/ @PersistenceContext(unitName = "Audit")/
/ private EntityManager entityManager;/
//
Thanks for your support!
Jonathan
Information in this e-mail and any attachments is confidential, and
may not be copied or used by anyone other than the addressee, nor
disclosed to any third party without our permission. There is no
intention to create any legally binding contract or other binding
commitment through the use of this electronic communication unless it
is issued in accordance with the Experian Limited standard terms and
conditions of purchase or other express written agreement between
Experian Limited and the recipient. Although Experian has taken
reasonable steps to ensure that this communication and any attachments
are free from computer viruses, you are advised to take your own steps
to ensure that they are actually virus free.
Experian Ltd is authorised and regulated by the Financial Conduct
Authority.
Companies Act information: Registered name: Experian Limited.
Registered office: The Sir John Peace Building, Experian Way, NG2
Business Park, Nottingham, NG80 1ZZ, United Kingdom. Place of
registration: England and Wales. Registered number: 653331.
--
Christian Schneider
http://www.liquid-reality.de
Open Source Architect
http://www.talend.com