Community
Participate
Working Groups
Support SessionBroker in Eclipselink JPA as a first class citizen. SessionBroker should be easy for the user to configure using just custom Eclipselink jpa (annotations, xml, properties).
Created attachment 194115 [details] Suggested patch. Composite persistence unit is defined; Implemented using SessionBroker, therefore lots of changes in jpa core and tests to substitute ServerSession everywhere to DatabaseSessionImpl (from which both ServerSession and SessionBroker are derived); Lot of changes in queries to use getExecutionSession() instead of getSession() - that makes difference only in SessionBroker case; Refactored AbstractSession.getQuery method and overriding methods in derived classes; For testing copied most of jpa.advanced. and xml.jpa.advanced classes and diveded them between three member persistence units. Then attempted to copy jpa.advanced.EntityManagerJUnitTestSuite and make it use the new composite persistence unit. The same was done with jpa.xml.advanced.EntityMappingsAdvancedJUnitTestCase, which used (as the original test) with two persistence unit configurations: one with mapping files; another - extended - with mapping files and eclipselik-orm.xml. Many tests can run with composite persistence units, some not, some (not too many) may be adapted to run in the future. To run the tests in full glory the user should specify in their test.properties two additional sets of connection properties to be used by the two last member sessions (the first member session uses supplied connection parameters in TestingBrowser or original connection properties in test.properties: db.driver=oracle.jdbc.OracleDriver db.url=jdbc:oracle:thin:@ottvm030.ca.oracle.com:1521:TOPLINK db.user=ailitche db.pwd=password db.platform=org.eclipse.persistence.platform.database.OraclePlatform the new properties: db2.driver=com.ibm.db2.jcc.DB2Driver db2.url=jdbc:db2://ottvm046.ca.oracle.com:50000/TOPLINK2 db2.user=dev1 db2.pwd=password db2.platform=org.eclipse.persistence.platform.database.DB2Platform db3.driver=com.mysql.jdbc.Driver db3.url=jdbc:mysql://ottvm045.ca.oracle.com:3306/qa3 db3.user=qa3 db3.pwd=password db3.platform=org.eclipse.persistence.platform.database.MySQLPlatform If the user does not specify db2 and db3 properties there will be a boolean property, which allows all three member sessions to use the same connection parameters.
Created attachment 194194 [details] Slightly updated patch. Updated properties' names - now all of them prefixed with "eclipselink.composite-unit". Updated some tests.
Checked in the updated patch into trunk. If a bunch of new tests fail with connection exceptions, make sure to specify property single.db=true in your test.properties file or system properties. In that case all composite members will use the same default data base. Otherwise specify db2.* and db3.* properties. For details see eclipselink.jpa.test\test.properties and / or org.eclipse.persistence.testing.framework.junit.JUnitTestCaseHelper class. The new tests are: org.eclipse.persistence.testing.tests.jpa.composite.advanced.EntityManagerJUnitTestSuite and org.eclipse.persistence.testing.tests.jpa.xml.composite.advanced.EntityMappingsAdvancedJUnitTestCase The latter test could run with to different persistence units (using the same classes): "xml-composite-advanced" and "xml-extended-composite-advanced" (which uses eclipselink-orm.xml). By default "xml-composite-advanced" is used. Specify -Dorm.testing=eclipselink to use "xml-extended-composite-advanced". Note that because both pus use the same classes they should never both appear on the same classpass. "xml-composite-advanced" defined in eclipselink-xml-composite-advanced-model.jar and has members eclipselink-xml-composite-advanced-model-member_1.jar eclipselink-xml-composite-advanced-model-member_2.jar eclipselink-xml-composite-advanced-model-member_3.jar "xml-extended-composite-advanced" defined in eclipselink-xml-extended-composite-advanced-model.jar and has members eclipselink-xml-extended-composite-advanced-model-member_1.jar eclipselink-xml-extended-composite-advanced-model-member_2.jar eclipselink-xml-extended-composite-advanced-model-member_3.jar Usually the default one ("xml-composite-advanced") is run with all other tests in TestingBrowser (CMP3TestAllRunModel) or FullRegressionTestSuite and the extended one is run separately.
*** Bug 260258 has been marked as a duplicate of this bug. ***
Created attachment 194772 [details] Patch to fix composite persistence unit static weaving
Checked the patch into trunk. EntityManagerSetupImpl.predeploy method now used for static weaving, too. In this case StaticWeaveClassTransformer is set into emSetupImpl to indicate that predeploy will be used for static weaving, also passes logging parameters. Also fix to allow persistebce unit to read sessionBroker from sessions.xml. Note that such persistence unit is NOT a composite.
Created attachment 195129 [details] Correction to static weaving patch - Following Tom's review introduced a new class to be passed to EntityManagerSetupImpl (instead of StaticWeaveClassTransformer); - Corrected problem with static weaving in case sessions.xml is used.
Checked the patch into trunk.
Created attachment 195288 [details] Patch for composite member using sessions.xml A simple patch in EntityManagerSetupImpl class: composite persistence unit always uses its puName as session name. However SESSION_NAME specified in properties should be used to read correct session from sessions.xml.
Created attachment 195368 [details] Patch Eclipse jpa tests launch files. Test only patch: added to Eclipse jpa test launch files composite models' jars.
*** Bug 269213 has been marked as a duplicate of this bug. ***
Created attachment 195796 [details] Added support for connection properties for composite member persistence unit. In the same way as PersistenceUnitProperties.COMPOSITE_UNIT_PROPERTIES used to pass member-specific properties to createEMF method now is possible to pass connection properties (to be processed by members) to createEM method. Tests are in composite.advanced.EntityManagerJUnitTestSuite: testConnectionPolicy; testConnectionPolicySetProperty; testNonPooledConnection; testExclusiveIsolatedLeaksConnectionOnClear.
Created attachment 195882 [details] The previous patch - corrected After James' review corrected EntityManagerImpl class. Note that lots of formatting changes in composite.advanced.EntityManagerJUnitTestSuite were done to make as close as possible to the original class advanced.EntityManagerJUnitTestSuite Ideally all the tests found in the latter should be copied to the former (some adaptation may be required).
Checked the patch into trunk (revision: 9399).
Created attachment 195925 [details] Patch adds @CompositeMember annotation and xml support. A CompositeMember annotation is ignored unless is in composite member persistence unit. It may be used in conjunction with a ElementCollection and CollectionTable annotations. It should be used if target type is a primitive type and CollectionTable designates the table that belongs to composite member persistence unit other than the source composite member persistence unit. That allows the source and target to be mapped to different databases.
Checked the patch into trunk (rev. 9409). Reviewed by Guy.
Created attachment 196177 [details] Small assorted fixes Even in JPA case composite should not require jpa data source (members do); Clear JPAQueries on SessionBroker.initializeDescriptors after they copied processed; Some test fixes.
Created attachment 196251 [details] Patch for composite dead connection failover. The patch fixes composite reconnection on communication error code, adapts the relevant tests from advanced.EntityManagerJUnitTestSuite.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink