Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "EclipseLink/Examples/MySports/EMFperTenant"
< EclipseLink | Examples | MySports
(New page: The EclipseLink MySports Example implements a SaaS based solution where a single instance of the MySports application to handle requests for multiple leag...) |
(→persistence.xml) |
||
Line 4: | Line 4: | ||
=== persistence.xml === | === persistence.xml === | ||
+ | |||
<source lang="xml"> | <source lang="xml"> | ||
+ | <persistence version="2.0" 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_2_0.xsd"> | ||
+ | <persistence-unit name="mysports" transaction-type="RESOURCE_LOCAL"> | ||
+ | <provider>example.mysports.persistence.MySportsProvider</provider> | ||
+ | <non-jta-data-source>jdbc/MySports</non-jta-data-source> | ||
+ | <mapping-file>META-INF/local-eclipselink-orm.xml</mapping-file> | ||
+ | |||
+ | <class>example.mysports.model.User</class> | ||
+ | <class>example.mysports.model.Team</class> | ||
+ | <class>example.mysports.model.Player</class> | ||
+ | <class>example.mysports.model.Division</class> | ||
+ | <validation-mode>NONE</validation-mode> | ||
</source> | </source> |
Revision as of 13:55, 21 June 2012
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.
Provider
persistence.xml
<persistence version="2.0" 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_2_0.xsd"> <persistence-unit name="mysports" transaction-type="RESOURCE_LOCAL"> <provider>example.mysports.persistence.MySportsProvider</provider> <non-jta-data-source>jdbc/MySports</non-jta-data-source> <mapping-file>META-INF/local-eclipselink-orm.xml</mapping-file> <class>example.mysports.model.User</class> <class>example.mysports.model.Team</class> <class>example.mysports.model.Player</class> <class>example.mysports.model.Division</class> <validation-mode>NONE</validation-mode>