Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
EclipseLink/Examples/JPA
The following examples are provided to assist developers with their adoption and usage of EclipseLink's JPA and native ORM functionality. See Developing JPA Projects in the 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, here, or accessed through SVN, or downloads.
EclipseLink JPA Examples/Tutorials
Basic
- How to configure
- How to use outside of the container
- Using the EntityManager API
- How to use locking
- How to use caching
Diagnostics
- How to configure logging
- How to configure a third party custom logger
- How to validate metadata against the database
Mapping
- How to use an EclipseLink ORM.XML Mapping file
- How to configure primary key generation
- How to define inheritance
- How to map an Enum type to coded values
- How to map a List of Enums
- How to preserve collection ordering (JPA 1.0)
- How to map relationships based on an expression instead of foreign keys
Querying
- How to use pessimistic locking
- How to page query results
- How to execute a Query using an EclipseLink native DatabaseQuery
- How to extend EclipseLink for Nested FetchGroups
JPA 2.0
- How to use Map key columns to map complex Maps
- How to use derived identifiers to map composite Ids through ManyToOne relationships
- How to map collections of Basic or Emeddable values using an ElementCollection mapping
- How to maintain order in a List relationship using an OrderColumn
Java SE Examples
Rich Client Platform (RCP)
Spring JPA
Using Native ORM through JPA
Using Native EclipseLink ORM API
Migration
Tutorials
- JEE5 Compliant Application Servers
- Tutorial: Build a Web Application (JSF) Using JPA
- Step by step instructions by container for a quick-start JEE EclipseLink JPA container-managed Application using a single JPA Entity on the major subset of all application servers
Container | Version | JEE Spec | Source | Issues |
---|---|---|---|---|
Oracle WebLogic Server | 10.3.2.0 / 11gR1 | 6 |
- See application-scoped datasource workaround. - TODO 20091126: Update for WebLogic 10.3.2.0 - TODO 20081011: Verify weaving works in container and application managed EM modes (the current data model only uses @OneToOne and @ManyToMany) | |
Oracle OC4J | 10.1.3.5 | 1.4 (with EJB 3.0) | - 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 | 5 | - | - Requires GlassFish V2.1 build 32
- Current Production Release |
SUN Application Server | 9.1 | 5 | - | - See GlassFish V2 which is included in Sun AS 9 |
SAP NetWeaver Application Server | - | 5 | ||
JBoss | 4.2.2 5.0.1 | 5 | - | - Dynamic weaving is disabled due to (JIRA-572) - The latest 5.0.1 release (Oct 2008) does not support a temporary ClassLoader
- see static weaving workaround using the JBoss JSFEJB3 example |
Spring | 2.5.5 | 5 | - | - Under Construction TBD: use the Derby database platform |
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 - example incomplete |
IBM WebSphere | 7.0.0.1 | 5 | - | - 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 7781
- In progress as of 20090115 |
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 |
Apache Tomcat | 6.0.18 | 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. |
EclipseLink JPA Examples Matrix by Web Framework
- 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"?
Database --> | Oracle | MySQL | Derby | JavaDB | HSQL | DB2 Ex |
---|---|---|---|---|---|---|
WebLogic | Servlet | |||||
OC4J | Servlet | |||||
Glassfish | Servlet | |||||
Sun AS | Servlet | |||||
JBoss | Servlet | JSF | ||||
WebSphere | Servlet | |||||
Geronimo | ||||||
Tomcat | Servlet |
Under Construction
Querying
- How to optimize searching using data projections
- How to optimize graph loading
- How to access EclipseLink's native API through JPA
Java SE Examples
- GeoNames Example (under development bug 227113)
Database Platform Extensions
- Oracle: Spatial, VPD/OLS, TIMESTAMP, XDB
Advanced
- Dynamic JPA Example: Example extension for JPA without Java classes and XML
Application Server specific
Integrating EclipseLink JPA with an IDE
The following tutorials describe details on running EclipseLink JPA on a specific Java IDE.
- Eclipse 3.5
- SUN NetBeans 6.8 M1
- Oracle JDeveloper 11.1.1.1.0
- MyEclipse
- WebLogic Workshop
- IBM WebSphere Studio
- IBM Rational Application Developer 7.5
- IntelliJ IDEA 8
- Borland JBuilder
Integrating EclipseLink JPA with a Database Platform
The following tutorials describe details on running EclipseLink JPA on a specific database platform.
- Oracle 11 on Tomcat 6,
- MySQL
- Derby 10.5.3.0 on GlassFish V2 / Sun Application Server 9
- DB2 Express C 9.5 on IBM WebSphere CE
- JavaDB
- HSQL on JBoss