Hi Tim,

it seems I misinterpreted the EntityManagerFactoryBuilder - thanks for pointing 
this out.

But I still don't see how to solve the situation with one persistence unit 
working on multiple databases with the same structure, neither in OSGi nor in 
Java EE.

In Java SE, I would simply call Persistence.createEntityManagerFactory(puName, 
props) multiple times, with the same persistence unit name, but different 
property sets, specifying different datasources.

E.g. think of a business intelligence application doing analysis on customer 
databases, where there is a separate database for each country. Each analysis 
request refers to given country, and the application has to select the 
appropriate database at run-time. New countries may be added at any time, so it 
would not work to hard-code n persistence units and/or EMFs up front.

Best regards,
Harald

Reply via email to