Community
Participate
Working Groups
Add support for using SessionBroker within EclipseLink JPA. This involves enhancements to the core runtime as well as support for configuration using either native XML or JPA (annotations + ORM.XML). For the JPA usage case it would be great to bootstrap by specifying multiple persistence units that should be used to create a single PU with a broker. Alternatively we could provide support for defining a broker PU that lists the PU's to be contained.
Updating priority due to revised bug categorization process. See the following page for details: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines#Priority_and_Target_Milestone If you feel the updated priority is incorrect, please send an email to eclipselink-users@eclipse.org.
I believe this should be changed to creating JPA (EMF/EM) broker scenario instead of trying to wire the existing SessionBroker under EMF. Changing the title to reflect this. Since each persistence unit contains its own data source connectivity info the EMF broker will need to sit above this level of configuration. Setting up a bootstrap API that takes multiple PU specifications is one option but it lacks the ability to be used in container managed mode. Additionally the configuration of mappings between entities in different PUs is challenging. PROPOSAL: EMF brokers are defined using a 'special' configuration based on standard persistence.xml persistence unit properties. EXAMPLE (persistence.xml): <?xml version="1.0" encoding="UTF-8"?> <persistence version="1.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_1_0.xsd"> <!-- Example of what a persistence.xml might look like configured as a broker. --> <!-- This PU represents an annotation based configuration. Since the PU's might be located in the same packaging unit the classes are listed so we don't accidentally get entities from pu-2. The exclude-unlisted-classes is set to true to avoid the default discovery --> <persistence-unit name="pu-1" transaction-type="JTA"> <jta-data-source>jdbc/PU1</jta-data-source> <class>model.Entity1</class> <class>model.Entity2</class> <exclude-unlisted-classes>true</exclude-unlisted-classes> </persistence-unit> <!-- This PU represents an orm.xml based configuration. Since the PU's might be located in the same packaging unit the classes are listed so we don't accidentally get entities from pu-1. The exclude-unlisted-classes is set to true to avoid the default discovery --> <persistence-unit name="pu-2" transaction-type="JTA"> <jta-data-source>jdbc/PU2</jta-data-source> <mapping-file>META-INF/pu-2-orm.xml</mapping-file> <exclude-unlisted-classes>true</exclude-unlisted-classes> </persistence-unit> <persistence-unit name="broker-pu" transaction-type="JTA"> <!-- This mapping file contains the additional mappings that augment what is in the individual PUs adding relationships across PU boundaries --> <mapping-file>META-INF/broker-orm.xml</mapping-file> <properties> <property name="eclipselink.broker.persistence-units" value="pu-1,pu-2" /> </properties> </persistence-unit> </persistence> Issues<?xml version="1.0" encoding="UTF-8"?> <persistence version="1.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_1_0.xsd"> <!-- Example of what a persistence.xml might look like configured as a broker. --> <!-- This PU represents an annotation based configuration. Since the PU's might be located in the same packaging unit the classes are listed so we don't accidentally get entities from pu-2. The exclude-unlisted-classes is set to true to avoid the default discovery --> <persistence-unit name="pu-1" transaction-type="JTA"> <jta-data-source>jdbc/PU1</jta-data-source> <class>model.Entity1</class> <class>model.Entity2</class> <exclude-unlisted-classes>true</exclude-unlisted-classes> </persistence-unit> <!-- This PU represents an orm.xml based configuration. Since the PU's might be located in the same packaging unit the classes are listed so we don't accidentally get entities from pu-1. The exclude-unlisted-classes is set to true to avoid the default discovery --> <persistence-unit name="pu-2" transaction-type="JTA"> <jta-data-source>jdbc/PU2</jta-data-source> <mapping-file>META-INF/pu-2-orm.xml</mapping-file> <exclude-unlisted-classes>true</exclude-unlisted-classes> </persistence-unit> <persistence-unit name="broker-pu" transaction-type="JTA"> <!-- This mapping file contains the additional mappings that augment what is in the individual PUs adding relationships across PU boundaries --> <mapping-file>META-INF/broker-orm.xml</mapping-file> <properties> <property name="eclipselink.broker.persistence-units" value="pu-1,pu-2" /> </properties> </persistence-unit> </persistence> Pros: - standard JPA config thus allowing container usage - relatively straight forward Cons: - need to ensure property is processed before orm xml in broker PU - critical config left to a property thus breaking in other JPA providers - multiple PUs in same persistence.xml not well supported by current JAP tooling solutions NEXT STEP: I would like to propose working on this as an incubator effort. I would like to have some other volunteer as contributors and testers before heading down that road.
Created attachment 166498 [details] EntityManager/Session Broker code and test compatible with JPA The code included is used in production for a year in a JTA transaction scenario. The test case use explicit transaction management. Broker implement JPA interface, so this version of broker code is for JPA 1.0. The layers are design so that most of the code can be reuse unchanged by other implementation of O-R framework like Hibernate. Please comment. We are looking to integrate improvement.
*** This bug has been marked as a duplicate of bug 328404 ***
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink