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.
Difference between revisions of "EclipseLink/Examples/JPA"
(→Advanced) |
|||
(135 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | [[Category:EclipseLink | + | [[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 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 [ | + | |
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 9: | Line 7: | ||
== EclipseLink JPA Examples/Tutorials == | == EclipseLink JPA Examples/Tutorials == | ||
− | === | + | === General === |
* [[EclipseLink/Examples/JPA/Configure | How to configure ]] | * [[EclipseLink/Examples/JPA/Configure | How to configure ]] | ||
* [[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/EMAPI | Using the EntityManager API]] | ||
* [[EclipseLink/Examples/JPA/Locking | How to use locking]] | * [[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/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 20: | 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 === | ||
Line 30: | Line 43: | ||
* [[EclipseLink/Examples/JPA/Collectionordering | How to preserve collection ordering (JPA 1.0)]] | * [[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/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 === | ||
Line 35: | Line 52: | ||
* [[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/DatabaseQuery | How to execute a Query using an EclipseLink native DatabaseQuery]] | ||
− | * [[EclipseLink/Examples/JPA/ | + | * [[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 === | === 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 45: | 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 58: | 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]] | ||
− | |||
=== 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 ]] | ||
Line 70: | Line 115: | ||
== Tutorials == | == Tutorials == | ||
===Application Server Tutorials=== | ===Application Server Tutorials=== | ||
− | * [http://java.sun.com/javaee/overview/compatibility.jsp | + | *The following tutorials are for enterprise developers interested in container or application managed persistence using the JPA 1.0 or 2.0 API. |
− | * Step by step instructions by container for a quick-start | + | *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==== | ||
+ | * [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] | ||
+ | * 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> | ||
{|{{BMTableStyle}} | {|{{BMTableStyle}} | ||
Line 77: | Line 126: | ||
! Container | ! Container | ||
! Version | ! Version | ||
− | ! | + | ! Java EE Spec. |
! Source | ! 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.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 | ! Issues | ||
|- | |- | ||
− | |[[EclipseLink/Examples/JPA/WebLogic_Web_Tutorial|Oracle WebLogic Server]]|| [http://www.oracle.com/ | + | |[[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 | + | - 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 123: | Line 174: | ||
<!--|- | <!--|- | ||
|[[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" | |- bgcolor="#e0e0e0" | ||
− | ||[[EclipseLink/Examples/JPA/ | + | ||[[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''' | - '''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/ | + | - 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/ | + | ||[[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 | - 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/Jeus_Web_Tutorial|TMAX Jues]] || 6 || 5 || | ||
+ | || - [http://bugs.eclipse.org/331717 331717 - A wrapper around GlassFish server] | ||
+ | |} | ||
+ | |||
+ | ====Lightweight Application Servers==== | ||
+ | * [[EclipseLink/Examples/JPA/JSF_Tutorial|Tutorial: Build a Web Application (JSF) Using JPA on Tomcat]] | ||
+ | |||
+ | {|{{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. | + | |[[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 156: | Line 230: | ||
- 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 | ||
|} | |} | ||
− | ====EclipseLink JPA Examples Matrix by | + | <!--====Enterprise Frameworks==== |
− | *The following grid cross-references the above JPA | + | {|{{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 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"? | ||
{|{{BMTableStyle}} | {|{{BMTableStyle}} | ||
Line 171: | Line 268: | ||
! <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 193: | 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> | ||
− | |||
=== Querying === | === Querying === | ||
Line 206: | 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/ | + | * [[EclipseLink/Examples/JPA/Extensible | ExtensibleJPA Example]] : Example showing extensible Entity Types (EclipseLink 2.2) |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
=== Using EclipseLink JPA with SEAM === | === Using EclipseLink JPA with SEAM === | ||
Line 219: | Line 314: | ||
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. | + | * [[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 | + | * [[EclipseLink/Examples/JPA/IDE/NetBeans|SUN NetBeans 7.0 Beta 2]] |
− | * [[EclipseLink/Examples/JPA/IDE/JDeveloper|Oracle JDeveloper 11.1. | + | * [[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 | ||
* IBM Rational Application Developer 7.5 | * IBM Rational Application Developer 7.5 | ||
− | * [http://www.jetbrains.com/idea/ IntelliJ IDEA | + | * [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/ | + | *[[EclipseLink/Examples/JPA/EhCache|EhCache]]--> |
=== Integrating EclipseLink JPA with a Database Platform=== | === Integrating EclipseLink JPA with a Database Platform=== | ||
Line 242: | Line 336: | ||
* JavaDB | * JavaDB | ||
* [[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] | ||
+ | * [[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
- How to configure
- How to use outside of the container
- Using the EntityManager API
- How to use locking
- How to use database auditing, proxy authentication and VPD
- How to use load balancing, replication and data partitioning
- How to access multiple databases from a single composite persistence unit
- How to optimize performance
Caching
- How to use caching
- How to enable cache coordination : for caching in a cluster.
- How to use database event driven cache invalidation using Oracle DCN/QCN.
Diagnostics
- How to configure logging
- How to configure a third party custom logger
- How to validate metadata against the database
- How to enable performance monitoring and metrics
Schema
- How to automatically create tables and generate DDL for a persistence unit
- How to create indexes
- How to use cascade on delete on the database
- How to use a multitenant shared schema on 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
- How to enable history tracking
- How to use stored procedures for CRUD operations
- How to archive records instead of deleting them (soft deletes)
- How to configure your persistence unit to be extensible at runtime
Querying
- How to use pessimistic locking
- How to page query results
- How to execute a Query using an EclipseLink native DatabaseQuery
- How to optimize queries using batch and join fetching
- How to use FetchGroups and LoadGroups on queries, and for copying and merging
- How to execute a stored procedure
- How to execute an Oracle PLSQL stored function
- How to get the SQL for a Query
JPA 2.0
- Example JPA Employee Web model
- Example JPA 2.0 Employee model
- 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 Embeddable values using an ElementCollection mapping
- How to maintain order in a List relationship using an OrderColumn
- How to define dynamic queries using the JPA 2.0 Criteria API
JPA 2.1
- Bulk Update
- Stored Procedures
- JPQL function
- CDI Entity Listeners
- Treat
- Converters
- DDL generation
- Add Named Query
- Entity Graphs
- Unsynchronized Persistence Contexts
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 | Issues |
---|---|---|---|---|
Oracle WebLogic Server | 10.3.6.0 / 12c | 5 + (JPA 2.0, JSF 2, JAX-RS 1.1) |
- 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 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.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 | 7.2 | 5 | ||
JBoss | 6.0.0M1 | 6 | - 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 | 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 | ||||
OC4J | Servlet | |||||
Glassfish | Servlet | |||||
Sun AS | Servlet | |||||
JBoss | Servlet or JSF | |||||
IBM WebSphere 7 | Servlet | |||||
Geronimo | ||||||
Tomcat | Servlet |
Under Construction
Querying
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
- ExtensibleJPA Example : Example showing extensible Entity Types (EclipseLink 2.2)
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.
- Eclipse 3.6 Helios EE
- SpringSource Tool Suite 2.3.0
- SUN NetBeans 7.0 Beta 2
- Oracle JDeveloper 11.1.2
- WebLogic Workshop
- IBM WebSphere Studio
- IBM Rational Application Developer 7.5
- IntelliJ IDEA 10 (community and commercial)
- 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
- SAP MaxDB 7.7.07.16 for Windows (x86_64, 64 bit) 32-bit :wiki : forum
- JPA on Sybase
- JPA on postgeSQL 9.3 on WebLogic 12.1.2.1 (OSX 10.9 64 bit)
References
- Maven update site for eclipse http://download.eclipse.org/technology/m2e/releases