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 (JPA Web Application Tutorials)
 
(270 intermediate revisions by 16 users not shown)
Line 1: Line 1:
__NOTOC__
+
[[Category:EclipseLink/Example|JPA Examples]]
  
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/latest/solutions/toc.htm EclipseLink Solutions Guide] and [http://www.eclipse.org/eclipselink/documentation/latest/concepts/toc.htm Understanding EclipseLink (Concepts Guide)] for details.
  
__TOC__
+
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].
  
 
== EclipseLink JPA Examples/Tutorials ==
 
== EclipseLink JPA Examples/Tutorials ==
  
=== Basic ===
+
=== General ===
* [[EclipseLink/Examples/JPA/JPAConfigure | How to configure ]]
+
* [[EclipseLink/Examples/JPA/Configure | How to configure ]]
* [[EclipseLink/Examples/JPA/EMAPI | Using the EntityManager API]]
+
 
* [[EclipseLink/Examples/JPA/OutsideContainer | How to use outside of the container]]
 
* [[EclipseLink/Examples/JPA/OutsideContainer | How to use outside of the container]]
 +
* [[EclipseLink/Examples/JPA/EMAPI | Using the EntityManager API]]
 +
* [[EclipseLink/Examples/JPA/Locking | How to use locking]]
 +
* [[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/Composite | How to access multiple databases from a single composite persistence unit]]
 +
* [[EclipseLink/Examples/JPA/Performance | How to optimize performance]]
 +
 +
=== 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 16: Line 26:
 
* [[EclipseLink/Examples/JPA/CustomLogger | How to configure a third party custom logger]]
 
* [[EclipseLink/Examples/JPA/CustomLogger | How to configure a third party custom logger]]
 
* [[EclipseLink/Examples/JPA/IntegrityChecker | How to validate metadata against the database]]
 
* [[EclipseLink/Examples/JPA/IntegrityChecker | How to validate metadata against the database]]
 +
* [[EclipseLink/Examples/JPA/Monitoring | How to enable performance monitoring and metrics]]
 +
 +
=== Schema ===
 +
* [[EclipseLink/Examples/JPA/DDL | How to automatically create tables and generate DDL for a persistence unit]]
 +
* [[EclipseLink/Examples/JPA/Indexes | How to create indexes]]
 +
* [[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 ===
 
* [[EclipseLink/Examples/JPA/EclipseLink-ORM.XML | How to use an EclipseLink ORM.XML Mapping file]]
 
* [[EclipseLink/Examples/JPA/EclipseLink-ORM.XML | How to use an EclipseLink ORM.XML Mapping file]]
 
* [[EclipseLink/Examples/JPA/PrimaryKey | How to configure primary key generation]]
 
* [[EclipseLink/Examples/JPA/PrimaryKey | How to configure primary key generation]]
** [[EclipseLink/Examples/JPA/CustomSequencing | How to use Custom Sequencing (I.e. UUID)]]
+
** [[EclipseLink/Examples/JPA/CustomSequencing | How to use Custom Sequencing (i.e. UUID)]]
 
* [[EclipseLink/Examples/JPA/Inheritance | How to define inheritance]]
 
* [[EclipseLink/Examples/JPA/Inheritance | How to define inheritance]]
 
* [[EclipseLink/Examples/JPA/EnumToCode | How to map an Enum type to coded values ]]
 
* [[EclipseLink/Examples/JPA/EnumToCode | How to map an Enum type to coded values ]]
 +
* [[EclipseLink/Examples/JPA/EnumListMapping | How to map a List of Enums ]]
 +
* [[EclipseLink/Examples/JPA/Collectionordering | How to preserve collection ordering (JPA 1.0)]]
 +
* [[EclipseLink/Examples/JPA/MappingSelectionCriteria | How to map relationships based on an expression instead of foreign keys]]
 +
* [[EclipseLink/Examples/JPA/History | How to enable history tracking]]
 +
* [[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 ===
 
* [[EclipseLink/Examples/JPA/PessimisticLocking | How to use pessimistic locking]]
 
* [[EclipseLink/Examples/JPA/PessimisticLocking | How to use pessimistic locking]]
 
* [[EclipseLink/Examples/JPA/Pagination | How to page query results]]
 
* [[EclipseLink/Examples/JPA/Pagination | How to page query results]]
 +
* [[EclipseLink/Examples/JPA/DatabaseQuery | How to execute a Query using an EclipseLink native DatabaseQuery]]
 +
* [[EclipseLink/Examples/JPA/QueryOptimization | How to optimize queries using batch and join fetching]]
 +
* [[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/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 ===
 +
* [[EclipseLink/Examples/JPA/Employee|Example JPA Employee Web model]]
 +
* [[EclipseLink/Examples/JPA/2.0/Employee|Example JPA 2.0 Employee model]]
 +
* [[EclipseLink/Examples/JPA/2.0/MapKeyColumns|How to use Map key columns to map complex Maps]]
 +
* [[EclipseLink/Examples/JPA/2.0/DerivedIdentifiers|How to use
 +
derived identifiers to map composite Ids through ManyToOne relationships]]
 +
* [[EclipseLink/Examples/JPA/2.0/ElementCollections|How to map collections of Basic or Embeddable values using an ElementCollection mapping]]
 +
* [[EclipseLink/Examples/JPA/2.0/OrderColumns|How to maintain order in a List relationship using an OrderColumn]]
 +
* [[EclipseLink/Examples/JPA/2.0/Criteria|How to define dynamic queries using the JPA 2.0 Criteria API]]
 +
 +
=== JPA 2.1 ===
 +
* [[EclipseLink/Release/2.5/JPA21#Bulk_Update|Bulk Update]]
 +
* [[EclipseLink/Release/2.5/JPA21#Stored_Procedures|Stored Procedures]]
 +
* [[EclipseLink/Release/2.5/JPA21#JPQL_function|JPQL function]]
 +
* [[EclipseLink/Release/2.5/JPA21#CDI_Entity_Listeners|CDI Entity Listeners]]
 +
* [[EclipseLink/Release/2.5/JPA21#Treat|Treat]]
 +
* [[EclipseLink/Release/2.5/JPA21#Converters|Converters]]
 +
* [[EclipseLink/Release/2.5/JPA21#DDL generation|DDL generation]]
 +
* [[EclipseLink/Release/2.5/JPA21#Add Named Query|Add Named Query]]
 +
* [[EclipseLink/Release/2.5/JPA21#Entity Graphs|Entity Graphs]]
 +
* [[EclipseLink/Release/2.5/JPA21#Unsynchronized Persistence Contexts|Unsynchronized Persistence Contexts]]
 +
 +
=== JPA-RS ===
 +
 +
* [[EclipseLink/Examples/JPARS/Simple | Simple Student Example]]
 +
* [[EclipseLink/Examples/JPARS/JavaScriptClient | JavaScript Web Client]]
 +
* [[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]]
 +
* [[EclipseLink/Examples/PolyglotPersistence | Polyglot Persistence (Relational and NoSQL)]]
  
 
=== Java SE Examples ===
 
=== Java SE Examples ===
Line 40: Line 103:
 
* [[EclipseLink/Examples/JPA/ORMJPAConfigure | How to configure ]]
 
* [[EclipseLink/Examples/JPA/ORMJPAConfigure | How to configure ]]
 
* [[EclipseLink/Examples/JPA/NativeMetadata | How to use native metadata]]
 
* [[EclipseLink/Examples/JPA/NativeMetadata | How to use native metadata]]
* [[EclipseLink/Examples/JPA/QueryOptimization | How to optimize queries using batch and join reading]]
 
  
 
=== Using Native EclipseLink ORM API ===
 
=== Using Native EclipseLink ORM API ===
 
* [[EclipseLink/Examples/JPA/ORMSessions | Sessions ]]
 
* [[EclipseLink/Examples/JPA/ORMSessions | Sessions ]]
 
* [[EclipseLink/Examples/JPA/ORMQueries | Queries ]]
 
* [[EclipseLink/Examples/JPA/ORMQueries | Queries ]]
 +
* [[EclipseLink/Examples/JPA/nonJDBCArgsToStoredProcedures | How to access stored procedures with PLSQL data-types]]
 
* [[EclipseLink/Examples/JPA/ORMTransactions | Transactions ]]
 
* [[EclipseLink/Examples/JPA/ORMTransactions | Transactions ]]
  
 +
=== Migration ===
 +
* [[EclipseLink/Examples/JPA/Migration | How to migrate to EclipseLink JPA from other persistence solutions]]
  
 
+
== Tutorials ==
== 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.
=== JPA Web Application Tutorials ===
+
*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====
*[[EclipseLink/Examples/JPA/JSF_Tutorial|Tutorial: Build a Web Application (JSF) Using JPA]]
+
* [http://java.sun.com/javaee/overview/compatibility.jsp Java EE 5 Compliant 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]
*Step by step Instructions by Container for a basic JEE JPA container-managed Application  
+
* 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>
 
{|{{BMTableStyle}}
 
{|{{BMTableStyle}}
 
|-{{BMTHStyle}}
 
|-{{BMTHStyle}}
 
! Container
 
! Container
 
! Version
 
! Version
! JEE Spec
+
! Java EE Spec.
! Example Src
+
! Source
[http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.common.ddlgen DDL Gen]
+
! Issues
+
|-
+
|[[EclipseLink/Examples/JPA/WebLogic_Web_Tutorial|Oracle WebLogic Server]]|| 10.0 / 10.3.3.1 || 5 ||
+
[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.common.ddlgen DDL-gen]
 +
[http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.entities JPA Entities JAR]
  
[http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.weblogic.enterpriseWeb WAR]
+
! Issues
+
|-
 +
|[[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]
 
||
 
||
 
[[EclipseLink/Examples/JPA/WLS_AppScoped_DataSource| - See application-scoped datasource workaround]].
 
[[EclipseLink/Examples/JPA/WLS_AppScoped_DataSource| - See application-scoped datasource workaround]].
  
- TODO 20081011: Verify weaving works in container and application managed EM modes (the current data model only uses @OneToMany 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 / 11.1.1 || 5 || - || -
+
|[[EclipseLink/Examples/JPA/OC4J_Web_Tutorial|Oracle OC4J]]|| 10.1.3.5 || 1.4 (with EJB 3.0) ||
 +
[http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.oc4j.enterpriseEAR EAR][http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.oc4j.enterpriseEJB EJB][http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.oc4j.enterpriseWeb WAR]
 +
|| - Updated for version 10.1.3.5
 +
|-
 +
|[[EclipseLink/Examples/JPA/GlassFishV3_Web_Tutorial|GlassFish]]|| V3 || 6 || - || - Use V3 [http://download.java.net/glassfish/v3/promoted 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
 
|- bgcolor="#d0efff"
 
|- bgcolor="#d0efff"
|[[EclipseLink/Examples/JPA/GlassFishV2_Web_Tutorial|GlassFish]]|| V2.1 || 5 || - || - Requires GlassFish V2.1 build 32
+
|[[EclipseLink/Examples/JPA/GlassFishV2_Web_Tutorial|GlassFish]]|| V2.1.1 || 5 || - || - Requires GlassFish V2.1 build 32
  
 
- Current Production Release
 
- Current Production Release
 +
 +
- [[EclipseLink/Examples/JPA/Migration/TopLinkEssentials#target-server|migrating from TopLink Essentials to EclipseLink]]
 
|-
 
|-
 
|- bgcolor="#d0efff"
 
|- bgcolor="#d0efff"
 
|SUN Application Server || 9.1 || 5 || - || - See [[EclipseLink/Examples/JPA/GlassFishV2_Web_Tutorial|GlassFish V2 which is included in Sun AS 9]]
 
|SUN Application Server || 9.1 || 5 || - || - See [[EclipseLink/Examples/JPA/GlassFishV2_Web_Tutorial|GlassFish V2 which is included in Sun AS 9]]
 
|-
 
|-
|[[EclipseLink/Examples/JPA/GlassFishV3_Web_Tutorial|GlassFish]]|| V3 || 6 || - || - Use V3 [http://download.java.net/glassfish/v3/promoted prelude] - not TP2
+
|[[EclipseLink/Development/ServerPlatform/NetweaverPlatform|SAP NetWeaver Application Server]]|| 7.2 || 5 ||
 
+
- Use the 1.0.9 snapshot plugin against a prelude server
+
 
|-
 
|-
|[[EclipseLink/Examples/JPA/JBoss_Web_Tutorial|JBoss]] || 4.2.2 || 5 || - || - Dynamic weaving is disabled due to ([http://jira.jboss.com/jira/browse/EJBTHREE-572 JIRA-572]) - upcoming 5.0CR2 release (Oct 2008) will be fully JEE5
+
|[[EclipseLink/Examples/JPA/JBoss_Web_Tutorial|JBoss]] || 6.0.0M1 || 6 ||  
 +
[http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEAR EAR][http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.jboss.EnterpriseEJB EJB][http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.jboss.EnterpriseWeb WAR]
 +
|| - [http://bugs.eclipse.org/250477 Updated] for JBoss 6.0.0M1
 +
 
 +
- Dynamic weaving is disabled due to ([http://jira.jboss.com/jira/browse/EJBTHREE-572 JIRA-572])  
  
 
- see  [[EclipseLink/Examples/JPA/Migration/JBoss | static weaving workaround using the JBoss JSFEJB3 example]]
 
- see  [[EclipseLink/Examples/JPA/Migration/JBoss | static weaving workaround using the JBoss JSFEJB3 example]]
|-
+
 
 +
<font color="red">TODO: >rework tutorial for [http://in.relation.to/Bloggers/IntroducingJBossAS600M1 JBoss 6.0.0 M1]
 +
</font>
 +
<!--|-
 
|[[EclipseLink/Examples/JPA/Migration/JBoss_Seam | JBoss Seam]] || - || 5 || - || - in response to [http://www.theserverside.com/news/thread.tss?m=c.reply&thread_id=50305#266212 request for EclipseLink JPA support in JBoss SEAM]
 
|[[EclipseLink/Examples/JPA/Migration/JBoss_Seam | JBoss Seam]] || - || 5 || - || - in response to [http://www.theserverside.com/news/thread.tss?m=c.reply&thread_id=50305#266212 request for EclipseLink JPA support in JBoss SEAM]
 +
-->
 +
|- bgcolor="#e0e0e0"
 +
||[[EclipseLink/Examples/JPA/WebSphere_Web_Tutorial|IBM WebSphere]] || '''<font color="green">7.0.0.5</font>''' || 5 ||[https://bugs.eclipse.org/bugs/attachment.cgi?id=165341 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 - [[EclipseLink/Examples/JPA/WebSphere_Web_Tutorial#Remote_Debugging_EclipseLink_in_WebSphere_7.0_from_Eclipse_3.4|you can attach the Eclipse IDE to a WebSphere 7 server in debug mode on port 7777]]
 
|-
 
|-
|[[EclipseLink/Examples/JPA/Spring_Web_Tutorial|Spring]] || 2.5.5 || 5 || - || - '''Under Construction''' TBD: use the Derby database platform
+
||[[EclipseLink/Examples/JPA/WebSphere_Web_Tutorial6|IBM WebSphere]] || 6.1.0.0 || 1.4/5 || - || - Supports JPA1/EJB3 with optional feature pack on Java SE 1.5
 +
 
 +
- The [http://bugs.eclipse.org/160220 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
 
|-
 
|-
||[[EclipseLink/Examples/JPA/WebSphere_Web_Tutorial|IBM WebSphere]] || 6.1.0.0 || 1.4/5 || - || - Supports JPA1/EJB3 with optional feature pack on Java SE 1.5
+
|[[EclipseLink/Examples/JPA/Jeus_Web_Tutorial|TMAX Jues]] || 6 || 5 ||  
 +
|| - [http://bugs.eclipse.org/331717 331717 - A wrapper around GlassFish server]
 +
|}
  
- The [http://bugs.eclipse.org/160220 WAS 6.1 Eclipse WTP Server plugin (ehr 160221)] is in progress - use manual or python deployment
+
====Lightweight Application Servers====
 +
* [[EclipseLink/Examples/JPA/JSF_Tutorial|Tutorial: Build a Web Application (JSF) Using JPA on Tomcat]]
  
|- bgcolor="#e0e0e0"
+
{|{{BMTableStyle}}
 +
|-{{BMTHStyle}}
 +
! Container
 +
! Version
 +
! Java EE Spec.
 +
! Source
 +
 
 +
[http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.common.ddlgen DDL-gen]
 +
[http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.entities JPA Entities JAR]
 +
 
 +
! Issues
 +
|-
 +
|<!--[[EclipseLink/Examples/JPA/Virgo_Web_Tutorial|Eclipse Virgo]]-->
 +
Eclipse Virgo
 +
(''was SpringSource dm'')
 +
|| 2.1 || 6 (WAR only) ||
 +
|| - Virgo is an OSGI enabled web container based on the recently [http://www.eclipse.org/virgo/ contributed VMWare Springsource dm server] and the [http://www.eclipse.org/gemini/web/download/release-notes/1.1.0.RELEASE.php Gemini OSGI web container] (which was aimed at Springsource OSGI users.
 +
|-
 +
||[[EclipseLink/Examples/JPA/SpringSource_tc_Web_Tutorial|SpringSource tc]] || 6.0.20 || 5 (WAR only) || - || - see [http://www.springsource.com/products/eclipse-downloads STS 2.3.0] as in '''T'''om'''C'''at server based
 +
<!--|-
 +
||[[EclipseLink/Examples/JPA/SpringSource_dm_Web_Tutorial|SpringSource dm]] || 1.0.2 || 5 || - || - see [http://www.springsource.com/products/eclipse-downloads STS 2.3.0]
 +
-->
 +
|-  
 
||[[EclipseLink/Examples/JPA/WebSphereCE_Web_Tutorial|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)
 
||[[EclipseLink/Examples/JPA/WebSphereCE_Web_Tutorial|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)
 
|- bgcolor="#e0e0e0"
 
|- bgcolor="#e0e0e0"
 
|Apache Geronimo || 2.0.2 || 5 || - || - see [[EclipseLink/Examples/JPA/WebSphereCE_Web_Tutorial|WebSphere CE]] which wraps Geronimo, Derby and OpenJPA
 
|Apache Geronimo || 2.0.2 || 5 || - || - see [[EclipseLink/Examples/JPA/WebSphereCE_Web_Tutorial|WebSphere CE]] which wraps Geronimo, Derby and OpenJPA
 +
|-
 +
|[[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) || - || - 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.
  
- SessionCustomizer is required for JTA.
+
- 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.
 
- Only static weaving (instrumentation) is available.
  
 
- 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
 +
|}
 +
 +
<!--====Enterprise Frameworks====
 +
{|{{BMTableStyle}}
 +
|-{{BMTHStyle}}
 +
! Framework
 +
! Version
 +
! JEE Spec.
 +
! Source
 +
 +
[http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.common.ddlgen DDL-gen]
 +
[http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.entities JPA Entities JAR]
 +
 +
! Issues
 +
|-
 +
|-
 +
|[[EclipseLink/Examples/JPA/JEE_Web_Tutorial|JEE]] || 3.1 || 6 || - || - Standard Java Enterprise Edition framework for EJB 3.1(SB, MDB, JPA 2.0), JMS, JTA (see [http://bugs.eclipse.org/240495 240495])
 +
|-
 +
|[[EclipseLink/Examples/JPA/Spring_Web_Tutorial|Spring]] || 3.0.5 || 5 || - || - An alternative or adjunct to a full EE container.  Spring DI is demonstrated without using all Spring has to offer as EE replacements.
 
|}
 
|}
 +
-->
  
====EclipseLink JPA Examples Matrix by Web Framework ====
+
====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 129: Line 268:
 
! <font color="blue">DB2 Ex</font>
 
! <font color="blue">DB2 Ex</font>
 
|-
 
|-
|'''WebLogic''' ||[[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 137: Line 279:
 
|'''Sun AS''' || || ||[[EclipseLink/Examples/JPA/GlassFishV2_Web_Tutorial|Servlet]]|| || ||
 
|'''Sun AS''' || || ||[[EclipseLink/Examples/JPA/GlassFishV2_Web_Tutorial|Servlet]]|| || ||
 
|-
 
|-
|'''JBoss''' ||[[EclipseLink/Examples/JPA/JBoss_Web_Tutorial|Servlet]]|| || || ||[[EclipseLink/Examples/JPA/Migration/JBoss|JSF]] ||
+
|'''JBoss''' || || || ||||[[EclipseLink/Examples/JPA/JBoss_Web_Tutorial|Servlet]] or [[EclipseLink/Examples/JPA/Migration/JBoss|JSF]] ||
 
|-
 
|-
|'''WebSphere''' || || || || || || [[EclipseLink/Examples/JPA/WebSphereCE_Web_Tutorial|Servlet]]
+
|'''IBM WebSphere 7''' || || ||[[EclipseLink/Examples/JPA/WebSphere7_Web_Tutorial|Servlet]] || || || 
 
|-
 
|-
 
|'''Geronimo''' || || || || || ||
 
|'''Geronimo''' || || || || || ||
Line 151: Line 293:
 
<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>
=== Mappings ===
 
* [[EclipseLink/Examples/JPA/Collectionordering | How to maintain collection ordering]]
 
  
 
=== Querying ===
 
=== Querying ===
 
* [[EclipseLink/Examples/JPA/Projections | How to optimize searching using data projections]]
 
* [[EclipseLink/Examples/JPA/Projections | How to optimize searching using data projections]]
* [[EclipseLink/Examples/JPA/GraphLoading | How to optimize graph loading]]
 
 
* [[EclipseLink/Examples/JPA/NativeAPI | How to access EclipseLink's native API through JPA]]
 
* [[EclipseLink/Examples/JPA/NativeAPI | How to access EclipseLink's native API through JPA]]
  
Line 166: Line 305:
  
 
=== 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 ===
+
=== Using EclipseLink JPA with SEAM ===
====JBoss Seam====
+
* [[EclipseLink/Examples/JPA/SEAM|Integrating EclipseLink with SEAM 2.x on WebLogic or OC4J]]
 
+
[[Category:JPA]]
+
  
 
=== Integrating EclipseLink JPA with an IDE ===
 
=== Integrating EclipseLink JPA with an IDE ===
 
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]]
+
* [[EclipseLink/Examples/JPA#JPA_Web_Application_Tutorials|Eclipse 3.6 Helios EE]]
* MyEclipse
+
* [[EclipseLink/Examples/JPA/IDE/SpringSourceToolSuite|SpringSource Tool Suite 2.3.0]]
 +
* [[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/MyEclipse|MyEclipse]]-->
 
* WebLogic Workshop
 
* WebLogic Workshop
 
* IBM WebSphere Studio
 
* IBM WebSphere Studio
 
* IBM Rational Application Developer 7.5
 
* IBM Rational Application Developer 7.5
* [[EclipseLink/Examples/JPA/IDE/JDeveloper|Oracle JDeveloper 11.1.1]]
+
* [http://www.jetbrains.com/idea/ IntelliJ IDEA 10] (community and commercial)
* IntelliJ IDEA
+
* SUN Java Studio (NetBeans)
+
 
* Borland JBuilder
 
* Borland JBuilder
 +
<!--=== Integrating EclipseLink JPA with Network Attached Memory===
 +
*[[EclipseLink/Examples/JPA/EhCache|EhCache]]-->
  
 
=== Integrating EclipseLink JPA with a Database Platform===
 
=== Integrating EclipseLink JPA with a Database Platform===
Line 191: Line 332:
 
* Oracle 11 on [[EclipseLink/Examples/JPA/Tomcat_Web_Tutorial|Tomcat 6]],  
 
* Oracle 11 on [[EclipseLink/Examples/JPA/Tomcat_Web_Tutorial|Tomcat 6]],  
 
* MySQL
 
* MySQL
* Derby on [[EclipseLink/Examples/JPA/GlassFishV2_Web_Tutorial|GlassFish V2 / Sun Application Server 9]]
+
* [[EclipseLink/Examples/JPA/Derby|Derby 10.5.3.0]] on [[EclipseLink/Examples/JPA/GlassFishV2_Web_Tutorial|GlassFish V2 / Sun Application Server 9]]
 
* DB2 Express C 9.5 on [[EclipseLink/Examples/JPA/WebSphereCE_Web_Tutorial|IBM WebSphere CE]]   
 
* DB2 Express C 9.5 on [[EclipseLink/Examples/JPA/WebSphereCE_Web_Tutorial|IBM WebSphere CE]]   
 
* JavaDB
 
* JavaDB
* 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]
 +
* [[EclipseLink/Examples/JPA/SyBase|JPA on Sybase]]
 +
* [[EclipseLink/Examples/JPA/WebLogic_Web_Tutorial#Install_postgreSQL_in_WebLogic_12.1.2|JPA on postgeSQL 9.3 on WebLogic 12.1.2.1 (OSX 10.9 64 bit)]]
 +
<!--=== 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.
 +
* [http://wiki.eclipse.org/EclipseLink/Building/64bit 64 bit JVM and operating systems]
 +
* [[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]

Latest revision as of 04:03, 6 May 2015


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

Caching

Diagnostics

Schema

Mapping

Querying

JPA 2.0

JPA 2.1

JPA-RS

NoSQL

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

Back to the top