Jump to: navigation, search


< EclipseLink‎ | Examples‎ | MySports
Revision as of 14:06, 21 June 2012 by Douglas.clarke.oracle.com (Talk | contribs) (Configuration: persistence.xml)

The EclipseLink MySports Example implements a SaaS based solution where a single instance of the MySports application to handle requests for multiple leagues (tenants). Each league has its own custom look and feel as well as custom extension attributes for entities. Having different extension attributes requires different mappings for each tenant and thus you must have a separate EntityManagerFactory (EMF). To implement the EMF per tenant in a common application the EclipseLink persistence framework needs to be extended with a custom JPA persistence provider.


While EclipseLink 2.4.0 does not offer explicit support for EntityManagerFactory (EMF) per tenant it is possible to construct an extended JPA provider that handles this usage scenario.

Configuration: persistence.xml

Here is what the template persistence unit is defined as. It is this persistence unit that is used and customized to create the tenant specific persistence unit.

<persistence version="2.0" 
             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">

	<persistence-unit name="mysports" transaction-type="RESOURCE_LOCAL">
                <!-- ... -->



In order to use

JPS-RS Usage

Since the MySports application also exposes its persistence unit(s) over REST using JPA-RS the tenant specific persistence units must be exposed as well.