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/Development/JPA 2.0/glassfish"
< EclipseLink | Development | JPA 2.0
m (→Resources) |
m (→Running JPA 2.0 API on Glassfish V3 (JEE6 RI) and V2 (JEE5 RI)) |
||
Line 1: | Line 1: | ||
=Running JPA 2.0 API on Glassfish V3 (JEE6 RI) and V2 (JEE5 RI)= | =Running JPA 2.0 API on Glassfish V3 (JEE6 RI) and V2 (JEE5 RI)= | ||
+ | ===Test Conditions=== | ||
+ | *- verify JPA 2.0 interface call with implementation shipped in EclipseLink 1.2 = entityManager.getMetamodel() | ||
+ | *- verify JPA 2.0 interface call with implementation only in EclipseLink 2.0 = entityManager.getCriteriaBuilder() | ||
+ | *- verify use of JPA 2.0 XSD and properties like <shared-cache-mode>NONE</shared-cache-mode> in persistence.xml | ||
==Glassfish V3== | ==Glassfish V3== | ||
*EclipseLink 1.2 and 2.0+ fully implement the JPA 2.0 specification via enhancement # [http://bugs.eclipse.org/248291 248291] and are the RI for the [http://wiki.eclipse.org/EclipseLink/Examples/JPA/GlassFishV3_Web_Tutorial GlassFish V3] JEE6 server. | *EclipseLink 1.2 and 2.0+ fully implement the JPA 2.0 specification via enhancement # [http://bugs.eclipse.org/248291 248291] and are the RI for the [http://wiki.eclipse.org/EclipseLink/Examples/JPA/GlassFishV3_Web_Tutorial GlassFish V3] JEE6 server. | ||
Line 5: | Line 9: | ||
*Glassfish V2.1.1 ships with JPA 1.0 support - in order to use JPA 2.0 on this older server some overrides will be required. | *Glassfish V2.1.1 ships with JPA 1.0 support - in order to use JPA 2.0 on this older server some overrides will be required. | ||
*'''''Ideally,we want a way for end users to override the JPA 1.0 library shipped with Glassfish V2 2.1.1 without modifying the server and affecting other applications.''''' | *'''''Ideally,we want a way for end users to override the JPA 1.0 library shipped with Glassfish V2 2.1.1 without modifying the server and affecting other applications.''''' | ||
+ | |||
+ | ==Results Matrix== | ||
+ | *The following table summarizes the type of test, server modifications and results | ||
+ | {|{{BMTableStyle}} | ||
+ | |-{{BMTHStyle}} | ||
+ | ! UC# | ||
+ | ! Test Example-Description | ||
+ | ! Container-Managed vs Application-Managed | ||
+ | ! Injected-EMF vs Persistence bootstrap | ||
+ | ! Entities, PU in utility JAR | ||
+ | ! Entities, PU in EJB JAR | ||
+ | ! Entities, PU in WAR | ||
+ | ! EAR wls:prefer- application-packages mod? | ||
+ | ! Server modifications? | ||
+ | ! '''Ability to run persistence.xml 1.0 vs 2.0 tags''' | ||
+ | ! '''Weaving entities''' | ||
+ | ! '''Runs JPA2 Impl in EclipseLink 1.2''' | ||
+ | ! '''Runs JPA2 Impl in EclipseLink 2.0 only''' | ||
+ | |- bgcolor="#d0efff" | ||
+ | || 1 | ||
+ | |<font color="green">Application_Managed EAR(WAR only)</font> - working | ||
+ | ||application || Persistence bootstrap || || || PU in WAR | ||
+ | || Yes || none ||<font color="red">1.0</font> | ||
+ | ||<font color="green">no - off</font> | ||
+ | || Y || Y | ||
+ | |- | ||
+ | || 2 | ||
+ | |''<font color="blue">App-Managed case pending...</font> - unknown | ||
+ | ||application ||injected @PersistenceUnit EMF on Servlet ||PU in utility JAR || || | ||
+ | || ?Yes || none | ||
+ | || <font color="blue">?</font> || ??? | ||
+ | || ??? || ??? | ||
+ | |- bgcolor="#d0efff" | ||
+ | || 3 | ||
+ | |<font color="green">Container-Managed EAR(EJB,WAR)</font> - working | ||
+ | ||container ||injected @PersistenceContext EM on Stateless Session Bean '''(EM is proxied, em.getClass().toString = <font color="green">$Proxy84</font>)''' || || PU in EJB|| | ||
+ | || || domain.xml (both javax and eclipselink jar refs) | ||
+ | || <font color="red">1.0</font>||<font color="green">'''Weaved'''</font> | ||
+ | || Y || Y | ||
+ | |- | ||
+ | || 4 | ||
+ | |''<font color="blue">Container-Managed EAR(EJB,WAR) as PS2 with override in EAR descriptor</font> - pending | ||
+ | ||container ||injected @PersistenceContext EM on SSB || ||PU in EJB|| | ||
+ | ||'''Yes (javax.persistence.* only)'''|| none | ||
+ | ||<font color="blue">???2.0</font>||<font color="blue">???yes</font> | ||
+ | || ??? || ??? | ||
+ | |- | ||
+ | |} | ||
+ | |||
==Problem== | ==Problem== | ||
*This document details a solution for enabling JPA 2.0 API functionality for various enterprise application use cases involving application-managed EntityManagers. | *This document details a solution for enabling JPA 2.0 API functionality for various enterprise application use cases involving application-managed EntityManagers. |
Revision as of 12:51, 15 December 2009
Contents
Running JPA 2.0 API on Glassfish V3 (JEE6 RI) and V2 (JEE5 RI)
Test Conditions
- - verify JPA 2.0 interface call with implementation shipped in EclipseLink 1.2 = entityManager.getMetamodel()
- - verify JPA 2.0 interface call with implementation only in EclipseLink 2.0 = entityManager.getCriteriaBuilder()
- - verify use of JPA 2.0 XSD and properties like <shared-cache-mode>NONE</shared-cache-mode> in persistence.xml
Glassfish V3
- EclipseLink 1.2 and 2.0+ fully implement the JPA 2.0 specification via enhancement # 248291 and are the RI for the GlassFish V3 JEE6 server.
Glassfish V2
- Glassfish V2.1.1 ships with JPA 1.0 support - in order to use JPA 2.0 on this older server some overrides will be required.
- Ideally,we want a way for end users to override the JPA 1.0 library shipped with Glassfish V2 2.1.1 without modifying the server and affecting other applications.
Results Matrix
- The following table summarizes the type of test, server modifications and results
UC# | Test Example-Description | Container-Managed vs Application-Managed | Injected-EMF vs Persistence bootstrap | Entities, PU in utility JAR | Entities, PU in EJB JAR | Entities, PU in WAR | EAR wls:prefer- application-packages mod? | Server modifications? | Ability to run persistence.xml 1.0 vs 2.0 tags | Weaving entities | Runs JPA2 Impl in EclipseLink 1.2 | Runs JPA2 Impl in EclipseLink 2.0 only |
---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Application_Managed EAR(WAR only) - working | application | Persistence bootstrap | PU in WAR | Yes | none | 1.0 | no - off | Y | Y | ||
2 | App-Managed case pending... - unknown | application | injected @PersistenceUnit EMF on Servlet | PU in utility JAR | ?Yes | none | ? | ??? | ??? | ??? | ||
3 | Container-Managed EAR(EJB,WAR) - working | container | injected @PersistenceContext EM on Stateless Session Bean (EM is proxied, em.getClass().toString = $Proxy84) | PU in EJB | domain.xml (both javax and eclipselink jar refs) | 1.0 | Weaved | Y | Y | |||
4 | Container-Managed EAR(EJB,WAR) as PS2 with override in EAR descriptor - pending | container | injected @PersistenceContext EM on SSB | PU in EJB | Yes (javax.persistence.* only) | none | ???2.0 | ???yes | ??? | ??? |
Problem
- This document details a solution for enabling JPA 2.0 API functionality for various enterprise application use cases involving application-managed EntityManagers.
- The page is geared to both end users and internal eclipselink.jpa.test server test implementors.
- 1) End users of Glassfish V2 2.1.1
- This involves configuring the server for JPA 1.0 permanently or per-deployment
- Note: This procedure is for application managed deployments - container managed injection will still default to JPA 1.0 for servers that do not ship with 2.0 out of the box
- 2) EclipseLink JPA test users on Glassfish V2 2.1.1
- This involves temporarily configuring the server per-test-deployment
- 1) End users of Glassfish V2 2.1.1
Analysis
- EclipseLink 1.2 and 2.0+ fully implement the JPA 2.0 specification via enhancement # 248291 and are the RI for the GlassFish V3 JEE6 server. In order to use this functionality the 2.0 version of the JPA specification jar - javax.persistence.jar must be added higher in the Glassfish server classpath see enhancement # 296269.
Use Cases
- Use case partitioning criteria
- Application managed EM
- @PersistenceUnit EMF or static bootstrap Persistence.createEntityManagerFactory EMF
- Global scoped datasource
- UC 1 : JTA global scoped datasource
- UC 2 : non-JTA global scoped datasource
- UC 3 : RESOURCE_LOCAL jdbc connector
- Application scoped datasource
- UC 11 : JTA global scoped datasource
- UC 12 : non-JTA global scoped datasource
- UC 13: RESOURCE_LOCAL jdbc connector
- Global scoped datasource
- @PersistenceUnit EMF or static bootstrap Persistence.createEntityManagerFactory EMF
- Container managed EM
- @PersistenceUnit EMF and/or @PersistenceContext EM injection on session bean
- Global scoped datasource
- UC 21 : JTA global scoped datasource
- UC 22 : non-JTA global scoped datasource
- UC 23 : RESOURCE_LOCAL jdbc connector - invalid
- Application scoped datasource
- UC 31 : JTA global scoped datasource
- UC 32 : non-JTA global scoped datasource
- UC 33 : RESOURCE_LOCAL jdbc connector - invalid
- Global scoped datasource
- @PersistenceUnit EMF and/or @PersistenceContext EM injection on session bean
- Application managed EM
Design
Design Issue 1: JSR-317 JPA 2.0 EJB 3.1 Support
DI 1: Problem
- The libs currently shipped with Glassfish 2.1.1 are the following JPA 1.0 compatible versions - these must be overriden in order to run JPA 2.0 API.
- lib/javaee.jar (the javax.persistence package)
- lib/toplink-essentials.jar
- lib/toplink-essentials-agent.jar
- The toplink-essentials jars are no problem as long as we specify the eclipselink persistence provider in all persistence units.
DI 1: Alternative 1: Manual overwrite of eclipselink and javax.persistence libraries in server/lib
- this will not place the JPA 2.0 higher - deprecated
DI 1: Alternative 2: Reference higher in the server classpath via domain.xml
- Add classpath-prefix="${com.sun.aas.installRoot}/lib/eclipselink.jar;${com.sun.aas.installRoot}/lib/javax.persistence_2.0.0.v200911041116.jar"
..doc in progress...
- Workable solution but it has issues
- The server now runs a single version of the two libraries for all applications - this may not be compatible with older applications or other JPA providers running on the server.