Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [eclipselink-users] multiple PUs/db catalogs ?

Please post separate questions as separate posts.

Do you have a separate database for each customer, or all they all on the
same database, just in different schemas?

Essentially you need a separate persistence unit for each schema/database. 
They can all share the same classes and annotations/orm.xml, but each would
needs its own persistence.xml.  You can use a SessionCustomizer to set the
tableQualifier on the EclipseLink Session's DatabaseLogin, to set the
schema.  There should be a persistence unit property for the tableQualifier,
please log a bug for this.

If you need to create the persistence unit's dynamically, this is more
difficult.  Dynamic persistence units is not something JPA or EclipseLink
supports very well.  You could potentially create your own
EntityManagerFactory factory that handles dynamically creating an
EntityManagerFactory per customer.  You will need to manually create an
EclipseLink ServerSession using the same EclipseLink Project as your default
persistence unit and wrap it in an EclipseLink EntityManagerFactory.  If you
need this, you should also log an enhancement request for dynamic
persistence unit support.

Gustav Trede-2 wrote:
> Hello,
> How does people using j2ee/jpa/eclipselink handle the scenario where the 
> same logic db structure needs to exists in several instances?.
> ex:
> one DB catalog for each customer.
> message driven bean per customer , each mdb needs an entitymanager with 
> its specific catalog.
> regards
>   gustav

--- James Sutherland
 EclipseLink ,
Wiki: EclipseLink , TopLink 
Forums: TopLink , EclipseLink 
Book: Java Persistence 
View this message in context:
Sent from the EclipseLink - Users mailing list archive at

Back to the top