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 (Enterprise Application Servers)
 
(26 intermediate revisions by 9 users not shown)
Line 1: Line 1:
 
[[Category:EclipseLink/Example|JPA Examples]]
 
[[Category:EclipseLink/Example|JPA Examples]]
  
__NOTOC__
+
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.
 
+
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.
+
  
 
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 12:
 
* [[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/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 57: Line 59:
  
 
=== JPA 2.0 ===
 
=== 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/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/MapKeyColumns|How to use Map key columns to map complex Maps]]
Line 64: Line 67:
 
* [[EclipseLink/Examples/JPA/2.0/OrderColumns|How to maintain order in a List relationship using an OrderColumn]]
 
* [[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]]
 
* [[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 90: Line 116:
 
===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 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.
+
*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 Java EE 5 Compliant Application Servers]
 
* [http://java.sun.com/javaee/overview/compatibility.jsp Java EE 5 Compliant Application Servers]
Line 108: Line 134:
 
! Issues
 
! Issues
 
|-
 
|-
|[[EclipseLink/Examples/JPA/WebLogic_Web_Tutorial|Oracle WebLogic Server]]|| [http://www.oracle.com/technetwork/middleware/weblogic/downloads/index.html  10.3.5.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]
 
[http://www.oracle.com/technetwork/developer-tools/eclipse/overview/tutorials-101794.html Oracle WebLogic Tutorials]
Line 312: Line 338:
 
* [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]]
 
* [[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 ===
 
<!--=== 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 317: Line 344:
 
* [[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]

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