I took a look at the EntityManagerFactoryBuilderService. As I understand there is one instance of that class for each persistence unit. So again I would have to provide that instance redundant data base credentials like:
ServiceReference[] refs =
context.getServiceReferences(
EntityManagerFactoryBuilder.class.getName(),
"(osgi.unit.name=Accounting)");
if (refs != null) {
EntityManagerFactoryBuilder emfBuilder =
(EntityManagerFactoryBuilder) context.getService(refs[0]);
if (emfBuilder != null) {
Map<String,Object> props = new HashMap<String,Object>();
props.put("javax.persistence.jdbc.user", username1);
props.put("javax.persistence.jdbc.password", password1);
props.put("javax.persistence.jdbc.url", url1);
EntityManagerFactory accountingEMF =
emfBuilder.createEntityManagerFactory(props);
The same code I would need to write for all other persistence units e.g. customers, orders. This is exactly what I would like to avoid. Any other hints?
Eugen Am 28.11.2011 um 20:43 schrieb Tom Ware: Take a look at the EntityManagerFactoryBuilder Service. Some docs on this page: http://wiki.eclipse.org/Gemini/JPA/Documentation/JPAServicesOn 28/11/2011 1:39 PM, Eugen Reiswich wrote: Hi Tom,
thanks for the jump start. After reading the documents there is one question I
was not able to answer yet. In my outlined scenario I would like to put
everything related to JPA in corresponding DAO bundles. As far as I understood
my bundles will contain the following JPA related files:
**.service.customer.dao*
- customer-mapping.xml
- persistence.xml
**.service.account.dao*
- account-mapping.xml
- persistence.xml
Both persistence.xml files contain duplicate database credentials. How can I
provide those only once?
Eugen
Am 24.11.2011 um 18:58 schrieb Tom Ware:
The best place to get started is the Gemini project. It includes the reference
implementation for a number of Java EE technologies in OSGi.
http://www.eclipse.org/gemini/
The base of the JPA part of the project is here:
http://www.eclipse.org/gemini/jpa/
Documentation is on the wiki:
http://wiki.eclipse.org/Gemini/JPA/Documentation
-Tom
On 24/11/2011 12:20 PM, Eugen Reiswich wrote:
Hi folks,
I googled now for two days to find an appropriate OSGi + EclipseLink example,
but only found very basic ones.
I've got an OSGi application with the following architecture:
*Bundles:*
*.ui.customer
*.ui.account
*.domain.customer // business objects like Customer.java, Address.java etc.
*.domain.account // business objects like Account.java
*.service.customer // customer logic
*.service.account
*.service.customer.dao // persistence logic
*.service.account.dao
Using this architecture I would like to:
- use ORM.XML files in my *.dao-bundles rather that annotations in my business
objects. This should keep my business objects and domain bundles free of any
technology.
- I would like to provide one DB-Connection credentials. I understand that a
persistence.xml contains both: the persistence unit and DB-connection
information. In my example I would need two persistence.xml files for customer
and account bundles providing DB-connection information twice. Right?
*My questions are:*
1. assuming the above requirements/architecture what's the best way to make this
work with EclipseLink + JPA 2.0?
2. where do I have to put the persistence.xml file(s)?
3. How can I tell EclipseLink that my DAO-bundles provide ORM mapping files?
Regards,
Eugen
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
________________________
Dipl. Wi-Inf. Eugen Reiswich
Universität Hamburg (UHH)
Fakultät für Mathematik, Informatik
und Naturwissenschaften (MIN-Fakultät)
Department Informatik
Zentrum für Architektur
und Gestaltung von IT-Systemen (AGIS)
Vogt-Koelln-Str. 30
22527 Hamburg
Tel: 040 / 42883 - 2307
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________ eclipselink-users mailing list eclipselink-users@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/eclipselink-users
________________________ Dipl. Wi-Inf. Eugen Reiswich
Universität Hamburg (UHH)
Fakultät für Mathematik, Informatik
und Naturwissenschaften (MIN-Fakultät) Department Informatik
Zentrum für Architektur
und Gestaltung von IT-Systemen (AGIS) Vogt-Koelln-Str. 30
22527 Hamburg Tel: 040 / 42883 - 2307
|