Skip to main content

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.

Jump to: navigation, search

Difference between revisions of "EclipseLink/Examples/JPA"

m (Application Server Tutorials)
m (JPA-RS)
(46 intermediate revisions by 11 users not shown)
Line 3: Line 3:
 
__NOTOC__
 
__NOTOC__
  
The following examples are provided to assist developers with their adoption and usage of EclipseLink's JPA and native ORM functionality. See [[EclipseLink/UserGuide/Developing JPA Projects (ELUG)|Developing JPA Projects]] in the [[EclipseLink/UserGuide|EclipseLink User's Guide]] for details.
+
The following examples are provided to assist developers with their adoption and usage of EclipseLink's JPA and native ORM functionality. See the [http://www.eclipse.org/eclipselink/documentation/ EclipseLink Solutions Guide] and [http://www.eclipse.org/eclipselink/documentation/ Understanding EclipseLink (Concepts Guide)] for details.
  
 
Source code to several of these examples, and to other examples can be found in EclipseLink's SVN repository, [http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/ here], or accessed through [[EclipseLink/Source|SVN]], or [http://www.eclipse.org/eclipselink/downloads/index.php downloads].
 
Source code to several of these examples, and to other examples can be found in EclipseLink's SVN repository, [http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/ here], or accessed through [[EclipseLink/Source|SVN]], or [http://www.eclipse.org/eclipselink/downloads/index.php downloads].
Line 14: Line 14:
 
* [[EclipseLink/Examples/JPA/EMAPI | Using the EntityManager API]]
 
* [[EclipseLink/Examples/JPA/EMAPI | Using the EntityManager API]]
 
* [[EclipseLink/Examples/JPA/Locking | How to use locking]]
 
* [[EclipseLink/Examples/JPA/Locking | How to use locking]]
* [[EclipseLink/Examples/JPA/Caching | How to use caching]]
 
* [[EclipseLink/Examples/JPA/CacheCoordination| How to enable cache coordination]] : For caching in a cluster.
 
 
* [[EclipseLink/Examples/JPA/Auditing | How to use database auditing, proxy authentication and VPD]]
 
* [[EclipseLink/Examples/JPA/Auditing | How to use database auditing, proxy authentication and VPD]]
 
* [[EclipseLink/Examples/JPA/Partitioning | How to use load balancing, replication and data partitioning]]
 
* [[EclipseLink/Examples/JPA/Partitioning | How to use load balancing, replication and data partitioning]]
 +
* [[EclipseLink/Examples/JPA/Composite | How to access multiple databases from a single composite persistence unit]]
 +
* [[EclipseLink/Examples/JPA/Performance | How to optimize performance]]
 +
 +
=== JPA-RS ===
 +
 +
* [[EclipseLink/Examples/JPARS/Simple | Simple Student Example]]
 +
* [[EclipseLink/Examples/JPARS/HelloDynamic | Hello World - Dynamic]]
 +
* [[EclipseLink/Development/2.4.0/JPA-RS/Security | Securing JPA-RS in GlassFish]]
 +
 +
=== NoSQL ===
 +
* [[EclipseLink/Examples/JPA/NoSQL| How to access NoSQL databases such as MongoDB]]
 +
 +
=== Caching ===
 +
* [[EclipseLink/Examples/JPA/Caching | How to use caching]]
 +
* [[EclipseLink/Examples/JPA/CacheCoordination| How to enable cache coordination]] : for caching in a cluster.
 +
* [[EclipseLink/Examples/JPA/DCN| How to use database event driven cache invalidation using Oracle DCN/QCN]].
  
 
=== Diagnostics ===
 
=== Diagnostics ===
Line 29: Line 43:
 
* [[EclipseLink/Examples/JPA/Indexes | How to create indexes]]
 
* [[EclipseLink/Examples/JPA/Indexes | How to create indexes]]
 
* [[EclipseLink/Examples/JPA/DeleteCascade | How to use cascade on delete on the database]]
 
* [[EclipseLink/Examples/JPA/DeleteCascade | How to use cascade on delete on the database]]
 +
* [[EclipseLink/Examples/JPA/Multitenant | How to use a multitenant shared schema on the database]]
  
 
=== Mapping ===
 
=== Mapping ===
Line 41: Line 56:
 
* [[EclipseLink/Examples/JPA/History | How to enable history tracking]]
 
* [[EclipseLink/Examples/JPA/History | How to enable history tracking]]
 
* [[EclipseLink/Examples/JPA/CRUDStoredProcedures | How to use stored procedures for CRUD operations]]
 
* [[EclipseLink/Examples/JPA/CRUDStoredProcedures | How to use stored procedures for CRUD operations]]
 +
* [[EclipseLink/Examples/JPA/SoftDelete| How to archive records instead of deleting them (soft deletes)]]
 +
* [[EclipseLink/Examples/JPA/Extensibility| How to configure your persistence unit to be extensible at runtime]]
  
 
=== Querying ===
 
=== Querying ===
Line 49: Line 66:
 
* [[EclipseLink/Examples/JPA/AttributeGroup | How to use FetchGroups and LoadGroups on queries, and for copying and merging]]
 
* [[EclipseLink/Examples/JPA/AttributeGroup | How to use FetchGroups and LoadGroups on queries, and for copying and merging]]
 
* [[EclipseLink/Examples/JPA/StoredProcedures | How to execute a stored procedure]]
 
* [[EclipseLink/Examples/JPA/StoredProcedures | How to execute a stored procedure]]
 +
* [[EclipseLink/Examples/JPA/PLSQLStoredFunction | How to execute an Oracle PLSQL stored function]]
 +
* [[EclipseLink/FAQ/JPA#How_to_get_the_SQL_for_a_Query.3F| How to get the SQL for a Query]]
  
 
=== JPA 2.0 ===
 
=== JPA 2.0 ===
Line 84: Line 103:
 
===Application Server Tutorials===
 
===Application Server Tutorials===
 
*The following tutorials are for enterprise developers interested in container or application managed persistence using the JPA 1.0 or 2.0 API.
 
*The following tutorials are for enterprise developers interested in container or application managed persistence using the JPA 1.0 or 2.0 API.
*See the [http://wiki.eclipse.org/EclipseLink/Examples/Distributed Distributed JPA Application] case study on how JPA works with JEE6 API elements - specifically as a shared memory application that does not use an L2 cache.
+
*See the [http://wiki.eclipse.org/EclipseLink/Examples/Distributed Distributed JPA Application] case study on how a '''Service/Workers''' parallel pattern based application uses JPA to deal with Optimistic lock exception scenarios using Java EE 6 API elements - specifically as a single persistence unit used by the distributed application as an alternative to using a shared L2 cache.
 
====Enterprise Application Servers====
 
====Enterprise Application Servers====
* [http://java.sun.com/javaee/overview/compatibility.jsp JEE5 Compliant Application Servers]
+
* [http://java.sun.com/javaee/overview/compatibility.jsp Java EE 5 Compliant Application Servers]
* Step by step instructions by container for a quick-start JEE [http://wiki.eclipse.org/Introduction_to_EclipseLink_Application_Development_%28ELUG%29#Considering_JPA_Entity_Architecture EclipseLink JPA container-managed Application] using a [http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.common.ddlgen single JPA Entity] on the major subset of [http://en.wikipedia.org/wiki/Matrix_of_Application_Servers all application servers]
+
* Step by step instructions by container for a quick-start Java EE [http://wiki.eclipse.org/Introduction_to_EclipseLink_Application_Development_%28ELUG%29#Considering_JPA_Entity_Architecture EclipseLink JPA container-managed Application] using a [http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.common.ddlgen single JPA Entity] on the major subset of [http://en.wikipedia.org/wiki/Matrix_of_Application_Servers all application servers]
 
* We use a standard container managed @PersistenceContext(..TransactionType dependency injected EntityManager) that is injected on a @Stateless session bean so that the container can provide a thread safe proxy wrapper around the @NotThreadSafe EntityManager and provide us with instrumented transaction management and change tracking.  The client servlet gets injected with the @EJB SSB by the web container and is completely separated from the JPA persistence concern.
 
* We use a standard container managed @PersistenceContext(..TransactionType dependency injected EntityManager) that is injected on a @Stateless session bean so that the container can provide a thread safe proxy wrapper around the @NotThreadSafe EntityManager and provide us with instrumented transaction management and change tracking.  The client servlet gets injected with the @EJB SSB by the web container and is completely separated from the JPA persistence concern.
 
* <font color="orange">These tutorials need to be finished and/or expanded - vote for EclipseLink bug# '''[http://bugs.eclipse.org/308477 308477]''' if you would like this work to be fast tracked.</font>
 
* <font color="orange">These tutorials need to be finished and/or expanded - vote for EclipseLink bug# '''[http://bugs.eclipse.org/308477 308477]''' if you would like this work to be fast tracked.</font>
Line 94: Line 113:
 
! Container
 
! Container
 
! Version
 
! Version
! JEE Spec.
+
! Java EE Spec.
 
! Source  
 
! Source  
  
Line 102: Line 121:
 
! Issues
 
! Issues
 
|-
 
|-
|[[EclipseLink/Examples/JPA/WebLogic_Web_Tutorial|Oracle WebLogic Server]]|| [http://www.oracle.com/technetwork/middleware/weblogic/downloads/index.html  10.3.4.0 / 11gR1] || 5 + (JPA 2.0, JSF 2, JAX-RS 1.1) ||
+
|[[EclipseLink/Examples/JPA/WebLogic_Web_Tutorial|Oracle WebLogic Server]]|| [http://www.oracle.com/technetwork/middleware/weblogic/downloads/index.html  10.3.6.0 / 12c] || 5 + (JPA 2.0, JSF 2, JAX-RS 1.1) ||
 
[http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEAR EAR][http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB EJB][http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.weblogic.enterpriseWeb WAR]
 
[http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEAR EAR][http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB EJB][http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.weblogic.enterpriseWeb WAR]
 
||
 
||
 
[[EclipseLink/Examples/JPA/WLS_AppScoped_DataSource| - See application-scoped datasource workaround]].
 
[[EclipseLink/Examples/JPA/WLS_AppScoped_DataSource| - See application-scoped datasource workaround]].
  
- TODO 20100115: Update for WebLogic 10.3.4 and JPA 2.0 - Verify weaving works in container and application managed EM modes (the current data model only uses @OneToOne and @ManyToMany)
+
- TODO 20100115: Update for WebLogic 10.3.6 and JPA 2.0 - Verify weaving works in container and application managed EM modes (the current data model only uses @OneToOne and @ManyToMany)
 +
 
 +
[http://www.oracle.com/technetwork/developer-tools/eclipse/overview/tutorials-101794.html Oracle WebLogic Tutorials]
 
|-
 
|-
 
|[[EclipseLink/Examples/JPA/OC4J_Web_Tutorial|Oracle OC4J]]|| 10.1.3.5 || 1.4 (with EJB 3.0) ||
 
|[[EclipseLink/Examples/JPA/OC4J_Web_Tutorial|Oracle OC4J]]|| 10.1.3.5 || 1.4 (with EJB 3.0) ||
Line 152: Line 173:
 
|-
 
|-
 
|[[EclipseLink/Examples/JPA/Jeus_Web_Tutorial|TMAX Jues]] || 6 || 5 ||  
 
|[[EclipseLink/Examples/JPA/Jeus_Web_Tutorial|TMAX Jues]] || 6 || 5 ||  
  || - [http://bugs.eclipse.org/331717 331717]  
+
  || - [http://bugs.eclipse.org/331717 331717 - A wrapper around GlassFish server]  
 
|}
 
|}
  
 
====Lightweight Application Servers====
 
====Lightweight Application Servers====
 +
* [[EclipseLink/Examples/JPA/JSF_Tutorial|Tutorial: Build a Web Application (JSF) Using JPA on Tomcat]]
 +
 
{|{{BMTableStyle}}
 
{|{{BMTableStyle}}
 
|-{{BMTHStyle}}
 
|-{{BMTHStyle}}
 
! Container
 
! Container
 
! Version
 
! Version
! JEE Spec.
+
! Java EE Spec.
 
! Source  
 
! Source  
  
Line 185: Line 208:
 
|[[EclipseLink/Examples/JPA/Jetty_Web_Tutorial|Jetty]] || 7 || ? || - || - [http://www.eclipse.org/jetty/ Jetty] is a web-only container ([http://download.eclipse.org/jetty/stable-7/xref/ source]) ([http://download.eclipse.org/jetty/stable-7/dist/ binary]) that can be targetted the same way we target Tomcat (''NoServerPlatform'')
 
|[[EclipseLink/Examples/JPA/Jetty_Web_Tutorial|Jetty]] || 7 || ? || - || - [http://www.eclipse.org/jetty/ Jetty] is a web-only container ([http://download.eclipse.org/jetty/stable-7/xref/ source]) ([http://download.eclipse.org/jetty/stable-7/dist/ binary]) that can be targetted the same way we target Tomcat (''NoServerPlatform'')
 
|-
 
|-
|[[EclipseLink/Examples/JPA/Tomcat_Web_Tutorial|Apache Tomcat]] || 6.0.18 || 5 (w/o EJB) || [https://bugs.eclipse.org/250476 250476] || - 2.5 Servlet container will support application managed JPA entities using RESOURCE_LOCAL or JTA transactions.
+
|[[EclipseLink/Examples/JPA/Tomcat_Web_Tutorial|Apache Tomcat]] || 6.0.29 || 5 (w/o EJB) || [https://bugs.eclipse.org/250476 250476] || - 2.5 Servlet container will support application managed JPA entities using RESOURCE_LOCAL or JTA transactions.
  
 
- JTA datasource (without JTATransactionController) available when running as Tomcat service
 
- JTA datasource (without JTATransactionController) available when running as Tomcat service
Line 194: Line 217:
  
 
- No @EJB or @PersistenceContext injection is available.
 
- No @EJB or @PersistenceContext injection is available.
 +
 +
- [http://netbeans.org/community/releases/70/ Apache Tomcat 7.0.6 is bundled with NetBeans 7.0]
 +
- 20110524: added JSF 2.0 configuration on Tomcat section
 
|}
 
|}
  
Line 217: Line 243:
  
 
====EclipseLink JPA Examples Matrix by Container ====
 
====EclipseLink JPA Examples Matrix by Container ====
*The following grid cross-references the above JPA JEE Tutorials by Application server, Database and type of presentation framework - to answer the question "How to run EclipseLink JPA on an application server against a particular database"?
+
*The following grid cross-references the above JPA Java EE Tutorials by Application server, Database and type of presentation framework - to answer the question "How to run EclipseLink JPA on an application server against a particular database"?
  
 
{|{{BMTableStyle}}
 
{|{{BMTableStyle}}
Line 229: Line 255:
 
! <font color="blue">DB2 Ex</font>
 
! <font color="blue">DB2 Ex</font>
 
|-
 
|-
|'''WebLogic''' ||[[EclipseLink/Examples/JPA/WebLogic_Web_Tutorial|Servlet]]|| ||[[EclipseLink/Examples/JPA/WebLogic_Web_Tutorial|Servlet]] || || ||  
+
|'''WebLogic''' ||[[EclipseLink/Examples/JPA/WebLogic_Web_Tutorial|Servlet]]|| ||[[EclipseLink/Examples/JPA/WebLogic_Web_Tutorial|Servlet]]
 +
 
 +
[[EclipseLink/Examples/Distributed|JSF 2.0]]
 +
|| || ||  
 
|-
 
|-
 
|'''OC4J''' ||[[EclipseLink/Examples/JPA/OC4J_Web_Tutorial|Servlet]]|| || || || ||
 
|'''OC4J''' ||[[EclipseLink/Examples/JPA/OC4J_Web_Tutorial|Servlet]]|| || || || ||
Line 251: Line 280:
 
<table border="0" cellpadding="5" align="center"><tr><td width="20">[[image:Catnicon.gif]]</td><td>This section contains Examples and tutorials that are not yet complete.</td></tr></table>
 
<table border="0" cellpadding="5" align="center"><tr><td width="20">[[image:Catnicon.gif]]</td><td>This section contains Examples and tutorials that are not yet complete.</td></tr></table>
 
</div>
 
</div>
 
  
 
=== Querying ===
 
=== Querying ===
Line 265: Line 293:
 
=== Advanced ===
 
=== Advanced ===
 
* [[EclipseLink/Examples/JPA/Dynamic | Dynamic JPA Example]] : Example extension for JPA without Java classes and XML
 
* [[EclipseLink/Examples/JPA/Dynamic | Dynamic JPA Example]] : Example extension for JPA without Java classes and XML
 
+
* [[EclipseLink/Examples/JPA/Extensible | ExtensibleJPA Example]] : Example showing extensible Entity Types (EclipseLink 2.2)
=== Application Server specific ===
+
* [[EclipseLink/Examples/JPA/JSF_Tutorial|Tutorial: Build a Web Application (JSF) Using JPA on Tomcat - deprecated]]
+
  
 
=== Using EclipseLink JPA with SEAM ===
 
=== Using EclipseLink JPA with SEAM ===
Line 275: Line 301:
 
The following tutorials describe details on running EclipseLink JPA on a specific Java IDE.
 
The following tutorials describe details on running EclipseLink JPA on a specific Java IDE.
  
* [[EclipseLink/Examples/JPA#JPA_Web_Application_Tutorials|Eclipse 3.6]]
+
* [[EclipseLink/Examples/JPA#JPA_Web_Application_Tutorials|Eclipse 3.6 Helios EE]]
 
* [[EclipseLink/Examples/JPA/IDE/SpringSourceToolSuite|SpringSource Tool Suite 2.3.0]]
 
* [[EclipseLink/Examples/JPA/IDE/SpringSourceToolSuite|SpringSource Tool Suite 2.3.0]]
* [[EclipseLink/Examples/JPA/IDE/NetBeans|SUN NetBeans 6.8 M1]]
+
* [[EclipseLink/Examples/JPA/IDE/NetBeans|SUN NetBeans 7.0 Beta 2]]
 
* [[EclipseLink/Examples/JPA/IDE/JDeveloper|Oracle JDeveloper 11.1.2]]
 
* [[EclipseLink/Examples/JPA/IDE/JDeveloper|Oracle JDeveloper 11.1.2]]
* [[EclipseLink/Examples/JPA/IDE/MyEclipse|MyEclipse]]
+
<!--* [[EclipseLink/Examples/JPA/IDE/MyEclipse|MyEclipse]]-->
 
* WebLogic Workshop
 
* WebLogic Workshop
 
* IBM WebSphere Studio
 
* IBM WebSphere Studio
Line 285: Line 311:
 
* [http://www.jetbrains.com/idea/ IntelliJ IDEA 10] (community and commercial)
 
* [http://www.jetbrains.com/idea/ IntelliJ IDEA 10] (community and commercial)
 
* Borland JBuilder
 
* Borland JBuilder
 
 
<!--=== Integrating EclipseLink JPA with Network Attached Memory===
 
<!--=== Integrating EclipseLink JPA with Network Attached Memory===
 
*[[EclipseLink/Examples/JPA/EhCache|EhCache]]-->
 
*[[EclipseLink/Examples/JPA/EhCache|EhCache]]-->
Line 299: Line 324:
 
* [[EclipseLink/Examples/JPA/JBoss_Web_Tutorial|HSQL]] on [[EclipseLink/Examples/JPA/Migration/JBoss|JBoss]]
 
* [[EclipseLink/Examples/JPA/JBoss_Web_Tutorial|HSQL]] on [[EclipseLink/Examples/JPA/Migration/JBoss|JBoss]]
 
* [https://www.sdn.sap.com/downloads/maxdb/7_7/maxdb-all-win-64bit-x86_64-7_7_07_16.exe SAP MaxDB 7.7.07.16 for Windows (x86_64, 64 bit)] [http://www.sdn.sap.com/irj/sdn/softwaredownload?download=https://www.sdn.sap.com/downloads/maxdb/7_7/maxdb-all-win-32bit-i386-7_7_07_16.exe 32-bit] :[http://wiki.sdn.sap.com/wiki/display/MaxDB/SAP%20MaxDB wiki] : [http://forums.sdn.sap.com/forum.jspa?forumID=90 forum]
 
* [https://www.sdn.sap.com/downloads/maxdb/7_7/maxdb-all-win-64bit-x86_64-7_7_07_16.exe SAP MaxDB 7.7.07.16 for Windows (x86_64, 64 bit)] [http://www.sdn.sap.com/irj/sdn/softwaredownload?download=https://www.sdn.sap.com/downloads/maxdb/7_7/maxdb-all-win-32bit-i386-7_7_07_16.exe 32-bit] :[http://wiki.sdn.sap.com/wiki/display/MaxDB/SAP%20MaxDB wiki] : [http://forums.sdn.sap.com/forum.jspa?forumID=90 forum]
 
+
* [[EclipseLink/Examples/JPA/SyBase|JPA on Sybase]]
 
<!--=== Integrating EclipseLink JPA with a [http://www.oracle.com/us/corporate/software-hardware-complete-069519.html Hardware] Platform ===
 
<!--=== Integrating EclipseLink JPA with a [http://www.oracle.com/us/corporate/software-hardware-complete-069519.html Hardware] Platform ===
 
This section describes options for '''''architecture aware''''' development where details of the underlying hardware may be significant enough to reach the persistence layer.
 
This section describes options for '''''architecture aware''''' development where details of the underlying hardware may be significant enough to reach the persistence layer.
Line 305: Line 330:
 
* [[EclipseLink/Examples/J2ME|Java 2 Micro Edition page]]: [http://www.oracle.com/technetwork/java/javame/overview/index.html J2ME] virtual machines such as the '''[http://na.blackberry.com/eng/developers/javaappdev/ RIM]''' smartphone or the '''[http://java.sun.com/products/cldc/wp/ SUN K VM]''' running the Connected Limited Device Configuration (CLDC) API ([http://java.sun.com/products/cldc/index.jsp JSR 139]) version 1.1, the Mobile Information Device Profile (MIDP) version 2.0, the Mobile Sensor API ([http://jcp.org/en/jsr/detail?id=256 JSR 256]), the Contactless Communication API ([http://jcp.org/en/jsr/detail?id=257 JSR 257]) or J2ME Web Services API ([http://jcp.org/en/jsr/detail?id=172 JSR 172]) API.
 
* [[EclipseLink/Examples/J2ME|Java 2 Micro Edition page]]: [http://www.oracle.com/technetwork/java/javame/overview/index.html J2ME] virtual machines such as the '''[http://na.blackberry.com/eng/developers/javaappdev/ RIM]''' smartphone or the '''[http://java.sun.com/products/cldc/wp/ SUN K VM]''' running the Connected Limited Device Configuration (CLDC) API ([http://java.sun.com/products/cldc/index.jsp JSR 139]) version 1.1, the Mobile Information Device Profile (MIDP) version 2.0, the Mobile Sensor API ([http://jcp.org/en/jsr/detail?id=256 JSR 256]), the Contactless Communication API ([http://jcp.org/en/jsr/detail?id=257 JSR 257]) or J2ME Web Services API ([http://jcp.org/en/jsr/detail?id=172 JSR 172]) API.
 
-->
 
-->
 +
 +
==References==
 +
* Maven update site for eclipse [http://download.eclipse.org/technology/m2e/releases http://download.eclipse.org/technology/m2e/releases]

Revision as of 13:05, 7 March 2013



The following examples are provided to assist developers with their adoption and usage of EclipseLink's JPA and native ORM functionality. See the EclipseLink Solutions Guide and Understanding EclipseLink (Concepts Guide) for details.

Source code to several of these examples, and to other examples can be found in EclipseLink's SVN repository, here, or accessed through SVN, or downloads.

EclipseLink JPA Examples/Tutorials

General

JPA-RS

NoSQL

Caching

Diagnostics

Schema

Mapping

Querying

JPA 2.0

Java SE Examples

Rich Client Platform (RCP)

Spring JPA

Using Native ORM through JPA

Using Native EclipseLink ORM API

Migration

Tutorials

Application Server Tutorials

  • The following tutorials are for enterprise developers interested in container or application managed persistence using the JPA 1.0 or 2.0 API.
  • See the Distributed JPA Application case study on how a Service/Workers parallel pattern based application uses JPA to deal with Optimistic lock exception scenarios using Java EE 6 API elements - specifically as a single persistence unit used by the distributed application as an alternative to using a shared L2 cache.

Enterprise Application Servers

  • Java EE 5 Compliant Application Servers
  • Step by step instructions by container for a quick-start Java EE EclipseLink JPA container-managed Application using a single JPA Entity on the major subset of all application servers
  • We use a standard container managed @PersistenceContext(..TransactionType dependency injected EntityManager) that is injected on a @Stateless session bean so that the container can provide a thread safe proxy wrapper around the @NotThreadSafe EntityManager and provide us with instrumented transaction management and change tracking. The client servlet gets injected with the @EJB SSB by the web container and is completely separated from the JPA persistence concern.
  • These tutorials need to be finished and/or expanded - vote for EclipseLink bug# 308477 if you would like this work to be fast tracked.
Container Version Java EE Spec. Source

DDL-gen JPA Entities JAR

Issues
Oracle WebLogic Server 10.3.6.0 / 12c 5 + (JPA 2.0, JSF 2, JAX-RS 1.1)

EAREJBWAR

- See application-scoped datasource workaround.

- TODO 20100115: Update for WebLogic 10.3.6 and JPA 2.0 - Verify weaving works in container and application managed EM modes (the current data model only uses @OneToOne and @ManyToMany)

Oracle WebLogic Tutorials

Oracle OC4J 10.1.3.5 1.4 (with EJB 3.0)

EAREJBWAR

- Updated for version 10.1.3.5
GlassFish V3 6 - - Use V3 prelude - not TP2

- Use the 1.0.9+ snapshot plugin (with fixed library references) against a prelude server - currently at b73 which runs EclipseLink 2.0 with JPA 2.0 support out of the box

GlassFish V2.1.1 5 - - Requires GlassFish V2.1 build 32

- Current Production Release

- migrating from TopLink Essentials to EclipseLink

SUN Application Server 9.1 5 - - See GlassFish V2 which is included in Sun AS 9
SAP NetWeaver Application Server 7.2 5
JBoss 6.0.0M1 6

EAREJBWAR

- Updated for JBoss 6.0.0M1

- Dynamic weaving is disabled due to (JIRA-572)

- see static weaving workaround using the JBoss JSFEJB3 example

TODO: >rework tutorial for JBoss 6.0.0 M1

IBM WebSphere 7.0.0.5 5 309201 CM EAR

- Updated for Container Managed and Application Managed scenarios as of 20100419

- There is no WAS 7.0 Eclipse WTP Server plugin yet - you can attach the Eclipse IDE to a WebSphere 7 server in debug mode on port 7777

IBM WebSphere 6.1.0.0 1.4/5 - - Supports JPA1/EJB3 with optional feature pack on Java SE 1.5

- The WAS 6.1 Eclipse WTP Server plugin (ehr 160221) should be in the next release of Ganymede 3.4 in Dec08 - or use manual or python deployment

TMAX Jues 6 5 - 331717 - A wrapper around GlassFish server

Lightweight Application Servers

Container Version Java EE Spec. Source

DDL-gen JPA Entities JAR

Issues

Eclipse Virgo (was SpringSource dm)

2.1 6 (WAR only) - Virgo is an OSGI enabled web container based on the recently contributed VMWare Springsource dm server and the Gemini OSGI web container (which was aimed at Springsource OSGI users.
SpringSource tc 6.0.20 5 (WAR only) - - see STS 2.3.0 as in TomCat server based
IBM WebSphere CE 2.1.0.1 5 - - WebSphere CE 2.1 is only certified on Java SE 1.5 (SUN JRE 1.6 runtime support is available)
Apache Geronimo 2.0.2 5 - - see WebSphere CE which wraps Geronimo, Derby and OpenJPA
Jetty 7  ? - - Jetty is a web-only container (source) (binary) that can be targetted the same way we target Tomcat (NoServerPlatform)
Apache Tomcat 6.0.29 5 (w/o EJB) 250476 - 2.5 Servlet container will support application managed JPA entities using RESOURCE_LOCAL or JTA transactions.

- JTA datasource (without JTATransactionController) available when running as Tomcat service

- SessionCustomizer is required for non-JTA and JTA datasource access.

- Only static weaving (instrumentation) is available.

- No @EJB or @PersistenceContext injection is available.

- Apache Tomcat 7.0.6 is bundled with NetBeans 7.0 - 20110524: added JSF 2.0 configuration on Tomcat section


EclipseLink JPA Examples Matrix by Container

  • The following grid cross-references the above JPA Java EE Tutorials by Application server, Database and type of presentation framework - to answer the question "How to run EclipseLink JPA on an application server against a particular database"?
Database --> Oracle MySQL Derby JavaDB HSQL DB2 Ex
WebLogic Servlet Servlet

JSF 2.0

OC4J Servlet
Glassfish Servlet
Sun AS Servlet
JBoss Servlet or JSF
IBM WebSphere 7 Servlet
Geronimo
Tomcat Servlet

Under Construction

Catnicon.gifThis section contains Examples and tutorials that are not yet complete.

Querying

Java SE Examples

Database Platform Extensions

  • Oracle: Spatial, VPD/OLS, TIMESTAMP, XDB

Advanced

Using EclipseLink JPA with SEAM

Integrating EclipseLink JPA with an IDE

The following tutorials describe details on running EclipseLink JPA on a specific Java IDE.

Integrating EclipseLink JPA with a Database Platform

The following tutorials describe details on running EclipseLink JPA on a specific database platform.

References

Copyright © Eclipse Foundation, Inc. All Rights Reserved.