SlideShare a Scribd company logo
InterConnect
2017
OpenJPA and EclipseLink
Usage Scenarios
Explained
Kevin Sutter, STSM
WebSphere Java EE and JPA Architect
Twitter: @kwsutter
LinkedIn: https://www.linkedin.com/in/kevinwsutter
Raymond Scott, SME WebSphere Migration
WebSphere Configuration Migration
Twitter: @rvscott128
2 3/21/17
Please note
IBM’s statements regarding its plans, directions, and intent
are subject to change or withdrawal without notice at IBM’s
sole discretion.
Information regarding potential future products is intended to
outline our general product direction and it should not be
relied on in making a purchasing decision.
The information mentioned regarding potential future
products is not a commitment, promise, or legal obligation to
deliver
any material, code or functionality. Information about
potential future products may not be incorporated into any
contract.
The development, release, and timing of any future features
or functionality described for our products remains at our
sole discretion.
Performance is based on measurements and projections
using standard IBM benchmarks in a
controlled environment. The actual throughput or
performance that any user will experience will vary
depending upon many factors, including considerations such
as the amount of multiprogramming in
the user’s job stream, the I/O configuration, the storage
configuration, and the workload processed. Therefore, no
assurance can be given that an individual user will achieve
results similar to those stated here.
Agenda
• JPA in WebSphere Application Server
• JPA Providers: OpenJPA and EclipseLink
• OpenJPA to EclipseLink Migration
• High level concepts
• OpenJPA to EclipseLink Investigation
• Specific differences
• WebSphere Migration and Toolkit
• Summary
• Q & A
3
JPA in WebSphere Application
Server
Kevin Sutter, Java EE
Architect
JPA in WebSphere Application Server
5
WebSphere Application Server
JPA 2.0
OpenJPA
JPA 2.1JPA 1.0
OpenJPA EclipseLink
• Apache OpenJPA
• Basis for WebSphere’s JPA solution for JPA 1.0 and JPA 2.0
• EclipseLink
• JPA Reference Implementation – “gospel”
• Basis for WebSphere Liberty’s JPA solution for JPA 2.1
JPA in WebSphere Application Server
• Moving forward…
• OpenJPA will continue to be supported in WebSphere for many,
many years
• At least until JPA 2.0 is ever deprecated…
• Both WebSphere traditional and Liberty
• Do I have to switch providers?
• Absolutely not!
• If you are happy with the current OpenJPA offering, there is
no need to move to EclipseLink
• If you want to use the JPA 2.1 features, you may need to
change…
• Many of the JPA 2.1 features have corresponding OpenJPA
proprietary solutions 6
JPA in WebSphere Application Server
7
WebSphere Application
Server
Java EE 6
Servlets 3.0
EJB 3.1
…
JPA 2.0
WebSphere Application
Server
Java EE 7
Servlets 3.1
EJB 3.2
…
JPA 2.0JPA 2.1
• Apache OpenJPA (ie. JPA 2.0) is compatible with other Java EE 7
features
• Allows for an easier, more gradual JPA migration
Key JPA 2.1 Features available in OpenJPA
• Schema Generation (JPA 2.1 Spec, Section 9.4)
• Generates DDL or interacts directly with database to define table schemas
based on JPA Entity definitions
• Similar functionality provided by OpenJPA’s schema mapper
• Entity Graphs (JPA 2.1 Spec, Section 3.7)
• Allows for specified fetching or processing of a graph of Entity objects
• Similar functionality provided by OpenJPA’s FetchPlan and FetchGroup
• Stored Procedure Queries (JPA 2.1 Spec, Section 3.10.17)
• Ability to invoke database stored procedures
• Similar functionality provided by OpenJPA’s Query invocation
8
Additional JPA 2.1 Features available in OpenJPA
• Basic Attribute Type Conversion (JPA 2.1 Spec, Section 3.8)
• Similar functionality support provided by OpenJPA’s Externalizer feature
• @Index and @ForeignKey annotations (JPA 2.1 Spec, Sections 11.1.19 and 11.1.23)
• Similar functionality provided by OpenJPA’s annotations
• Unwrap utility methods for EntityManager, Cache, etc (JPA 2.1 Spec Sections 3.1.1 and 7.10)
• Similar functionality provided by OpenJPA’s implementation --
EntityManagerImpl.unwrap() and OpenJPAPersistence.cast()
• Object construction when mapping results from native SQL (JPA 2.1 Spec, Section 3.10.16.2.2)
• Similar functionality provided by OpenJPA’s internal ResultShape object
9
Additional JPA 2.1 Features NOT available in OpenJPA
• Criteria API Updates (JPA 2.1 Spec, Sections 6.5.15 and 6.5.7)
• Bulk update/delete
• Support for TREAT, ON, and FUNCTION operators
• Unsynchronized Persistence Contexts (JPA 2.1 Spec, Section 7.6.1)
• Provides more control over when Persistence Contexts are synchronized
with a transaction. Useful for mobile applications.
• EntityListeners and CDI (JPA 2.1 Spec, Section 3.5.1)
• EntityListeners can now use CDI for injection of objects
• JPQL Updates for JPA 2.1 (JPA 2.1 Spec, Chapter 4)
• Several extensions to JPQL in support of the other features
• OpenJPA’s JPQL will stay at the JPA 2.0 level
10
Feature Comparison Chart
11
Key JPA 2.1 Features Available in current OpenJPA solution?
Schema Generation Yes, SynchronizeMappings
Entity Graphs Yes, FetchPlans and FetchGroups
Stored Procedures Yes, Query interface
Basic Attribute Type Conversion Yes, Externalizer (and Factory)
@Index and @ForeignKey annotations Yes, proprietary @Index and @ForeignKey annotations
Unwrap utility functions Yes, EntityManagerImpl.unwrap() and OpenJPAPersistence.cast()
Object construction when mapping results with native SQL Yes, ResultShape (internal OpenJPA implementation)
Criteria API updates No
Unsynchronized PersistenceContexts No
EntityListeners and CDI No
JPQL Updates in support of JPA 2.1 No
Bottom Line
• YOU DO NOT NEED TO MIGRATE
• Our Advice
• Continue using OpenJPA for your existing applications
• Use EclipseLink for your new applications
• But… If you want to use EclipseLink with existing applications,
the following slides will discuss what to look out for when
migrating existing applications
12
OpenJPA to EclipseLink
Migration
Cache
• DataCache
• OpenJPA: L2 cache disabled by default
• EclipseLink: L2 cache enabled by default.
• If you are migrating an application that isn't using the OpenJPA cache,
it is highly recommended to disable the L2 cache using:
<shared-cache-mode>NONE</shared-cache-mode>
• Query (Results) Cache
• If QueryCache is enabled,
• OpenJPA: All Named Queries and JPQL Statement Results are
cached
• EclipseLink: only Named Queries Results are cached
• More information on EclipseLink QueryCache here
14
Weaving/enhancement/transformation
• OpenJPA: Entities must be enhanced
• EclipseLink: Entities do not have to be enhanced
• Documented missing features (lazy loading, performance
gains, etc)
• WebSphere container automatically weaves/enhances Entities
for both OpenJPA and EclipseLink
• Applications packaged with entities pre-enhanced by OpenJPA
must be recompiled and repackaged
• Removes OpenJPA specific enhancement bytecode
15
Investigation Summary
Summary
• Detail in Backup charts
• Do I want to utilize my existing database tables?
• Modifications to the entities may be necessary
• Database tables previously created (by OpenJPA) may not
match EclipseLink’s generated tables
• OpenJPA may have been more lenient with spec violations than
Eclipselink is
• Recommendation
• Continue using OpenJPA for existing applications
• Migrate to EclipseLink only for new applications
17
WebSphere Migration & ToolKit
Ray Scott, Migration SME
Do you need to migrate JPA?
Best practice is to
• Use OpenJPA for your existing applications
• Use EclipseLink for your new applications
But…
If you need to migrate, we have tools to assist.
19
Traditional Application Server Migration
• V9.0 profile creation configures servers with JPA 2.1 – EclipseLink
• Migration reconfigures servers to use JPA 2.0 – OpenJPA
• Applications migrated to v9.0 as-is.
• EclipseLink was not shipped prior to V9.0
• Viewing and changing JPA configuration settings: (Knowledge Center)
• In the administrative console: Servers > Server Types > WebSphere application
servers > server_name > Container Services >
Default Java Persistence API settings
• In the wsadmin console:
• List JPA options: print AdminTask.listSupportedJPASpecifications()
• Display current setting: print AdminTask.showJPASpecLevel('[-node myNode01
-server server1]')
• Change JPA provider: print AdminTask.modifyJPASpecLevel('[-node myNode01
-server server1 -specLevel 2.1]')
20
Liberty Server Migration
No migration for Liberty.
Simply configure server.xml with desired JPA feature level.
21
Application Migration
Whether Traditional or Liberty …
if you change the JPA configuration …
you will need to migrate the applications.
The WebSphere Application Migration Toolkit and the
binaryScanner can help
22
An Overview of WebSphere Migration Tools
A set of tools help you:
- Migrate from third-party application servers to WebSphere Application Server
- Migrate between versions of WebSphere Application Server
- Migrate to WebSphere Application Server to the Cloud
23
Migration discovery Binaries analysis Source migration Config migration
On-line tool that helps you
•Estimate the effort required to
migrate your application to
WebSphere Application Server from
third-party application servers
•Select the IBM cloud platform suited
to host your application and estimate
migration to that platform
Command-line analysis of application
binaries that provides
• High level evaluation report
showing the Java EE
technologies your application
uses
• Detailed analysis for migration
between versions of
WebSphere traditional, Liberty,
and Liberty Core
• Cloud migration for instant
runtimes differences
• Java EE 7 differences
• Cloud connectivity analysis
Eclipse plugins that scans application
source to provide
• High level evaluation report
• A line-by-line analysis of code
changes required
• Detailed analysis for migrating
from third-party applications
servers
• Detailed analysis for migration
between versions of WebSphere
traditional, Liberty, and Liberty
Core
• Java EE 7 differences
• Cloud migration for instant
runtimes differences
• Cloud connectivity analysis
Eclipse plugin that helps migrate
server configuration
•From third-party application servers
to WebSphere Application Server
•Between versions of WebSphere
Application Server including
WebSphere traditional to Liberty.
How can the migration toolkit help?
• Scan for OpenJPA to EclipseLink differences
• The Eclipse-based, source scanning migration tool
• Contains 19 Java rules with 9 quick fixes
• Contains 5 XML rules with 2 quick fixes
• Focuses on annotated JPA applications
• Provides some configuration support
• The binary scanning tool
• Detects Entities enhanced for OpenJPA
• Contains 2 Java rules
• Contains 5 XML rules
24
Where can I get the migration tools?
• http://wasdev.net
25
• Eclipse Marketplace
How do I use the Eclipse migration tool?
Select Run > Analysis… to configure the JPA related rules.
•Choose the OpenJPA to EclipseLink JPA Migration rule set if you are only
interested in the JPA rules.
26
How do I use the Eclipse migration tool?
• Select Run > Analysis to configure JPA related rules.
• Choose the WebSphere
Application Server Version
Migration rule set if you want
to do more analysis.
• Select Java EE 7 as the
target Java EE version
• Select JPA
27
28
See the code to change
• After running Analysis, use the Software Analyzer Results view to
interpret the scan.
29
See the proposed fix before applying the change
When you need more help
30
• Each rule has help that you can view from the results or from the
configuration dialog.
31
What can I expect? -- Java rules
32
What can I expect? -- XML rules
Note: The rule Mapping files are not processed during OpenJPA to
EclipseLink migration is a reminder that most of the rules are Java
annotation rules. If define your Entities in mapping files rather than using
JPA annotations, you will need to make manual mapping file changes.
What if I don’t have source code?
The binary scanner detects
• Enhanced Java code – only in the binary scanner
• the XML issues
• org.apache.openjpa packages in use
33
How do I use the binary scanner?
• java -jar binaryAppScanner.jar --help
34
Resources
Other Tools: Integrity Checker
• EclipseLink provides a way to verify descriptor's metadata against database
metadata
• Setup the integrity checker using a session customizer (link)
• Catches missing tables or columns without having to persist
• Example: private getter methods
• setShouldCatchExceptions(true) - find all entities with missing columns
• Cons: doesn't catch everything or maybe anything…
• Failed to catch @ElementColumn resulting in a different column name
in the separate table, @GeneratedValue looking for a different table
• Doesn't compare column types
• Better than nothing, but it missed many common issues
36
Useful Links
• EclipseLink JPA provider for Liberty profile article
https://developer.ibm.com/wasdev/blog/2014/05/28/eclipselink-jpa-
provider-liberty-profile/
• EclipseLink Migration Wiki Page
https://wiki.eclipse.org/EclipseLink/Examples/JPA/Migration/OpenJPA
• V9 WebSphere Knowledge Center - JPA Instructions
https://www.ibm.com/support/knowledgecenter/SSAW57_9.0.0/com.ibm.w
ebsphere.nd.multiplatform.doc/ae/container_jpa_administering.html
37
Useful Links
• WebSphere Application Server Migration Toolkit
• wasdev.net download and links to the documentation
• https://developer.ibm.com/wasdev/downloads/#asset/tools-WebSphere_Application_Server_Migration_Toolkit
• Eclipse Marketplace
• https://marketplace.eclipse.org/content/ibm-websphere-application-server-migration-toolkit
• Migration Toolkit for Application Binaries
• wasdev.net download and links to the documentation
• https://developer.ibm.com/wasdev/downloads/#asset/tools-Migration_Toolkit_for_Application_Binaries
38
Sampling of Related Sessions…
• PEJ-5296: Java EE 7 Overview
– Monday, 10:30am-11:30am, Mandalay Bay North, South Pacific Ballroom A
• PEJ-2876: Configuring WebSphere Application Server for Enterprise Messaging Needs
– Monday, 12:00pm-1:00pm, Mandalay Bay North, Islander Ballroom G
• PEJ-2139: Technical Deep Dive into IBM WebSphere Liberty
– Monday, 3:00pm-4:00pm, Mandalay Bay North, South Pacific Ballroom A
• PEJ-1603: IBM WebSphere Liberty in the Wild
– Tuesday, 1:15pm-2:15pm, Mandalay Bay North, South Pacific Ballroom A
• PEJ-6480: Don’t Wait! Developing Responsive Applications with Java EE 7
– Tuesday, 1:15pm-2:15pm, Mandalay Bay North, Islander Ballroom G
• PEJ-1979: Hands-On with the IBM WebSphere Application Server Migration Toolkit (LAB)
– Tuesday, 01:15 PM - 02:15 PM, MGM Grand - Room 320
• PEJ-2151: Agile Development Using Java EE 7 with WebSphere Liberty Profile (LAB)
– Wednesday, 8:30am-9:30am, MGM Grand Room 306
• PEJ-1973: WAS Migration: Benefits, Planning, and Best Practices
– Wednesday, 12:00pm-1:00pm, Mandalay Bay North, South Pacific Ballroom A
• PEJ-1902: Migrate Java EE Applications to Cloud with Cloud Migration Toolkit
– Wednesday, 2:30pm-12:15pm, Mandalay Bay North, Islander Ballroom G
• PEJ-5303: OpenJPA and EclipseLink Usage Scenarios Explained
– Thursday, 11:30am-12:15pm, Mandalay Bay North, South Pacific Ballroom A
39 39
Questions?
41 3/21/17
Notices and disclaimers
Copyright © 2017 by International Business Machines Corporation
(IBM). No part of this document may be reproduced or transmitted in
any form without written permission from IBM.
U.S. Government Users Restricted Rights — use, duplication or
disclosure restricted by GSA ADP Schedule Contract with IBM.
Information in these presentations (including information relating to
products that have not yet been announced by IBM) has been
reviewed for accuracy as of the date of initial publication and could
include unintentional technical or typographical errors. IBM shall have
no responsibility to update this information. This document is
distributed “as is” without any warranty, either express or
implied. In no event shall IBM be liable for any damage arising
from the use of this information, including but not limited to, loss
of data, business interruption, loss of profit or loss of
opportunity. IBM products and services are warranted according to
the terms and conditions of the agreements under which they are
provided.
IBM products are manufactured from new parts or new and used parts.
In some cases, a product may not be new and may have been
previously installed. Regardless, our warranty terms apply.”
Any statements regarding IBM's future direction, intent or
product plans are subject to change or withdrawal without notice.
Performance data contained herein was generally obtained in a
controlled, isolated environments. Customer examples are presented
as illustrations of how those customers have used IBM products and
the results they may have achieved. Actual performance, cost, savings
or other results in other operating environments may vary.
References in this document to IBM products, programs, or services
does not imply that IBM intends to make such products, programs or
services available in all countries in which IBM operates or does
business.
Workshops, sessions and associated materials may have been
prepared by independent session speakers, and do not necessarily
reflect the
views of IBM. All materials and discussions are provided for
informational purposes only, and are neither intended to, nor shall
constitute legal or other guidance or advice to any individual participant
or their specific situation.
It is the customer’s responsibility to insure its own compliance
with legal requirements and to obtain advice of competent legal
counsel as to the identification and interpretation of any relevant laws
and regulatory requirements that may affect the customer’s business
and any actions
the customer may need to take to comply with such laws. IBM does
not provide legal advice or represent or warrant that its services or
products will ensure that the customer is in compliance with any law.
42 3/21/17
Notices and disclaimers
continued
Information concerning non-IBM products was obtained from the
suppliers of those products, their published announcements or other
publicly available sources. IBM has not tested those products in
connection with this publication and cannot confirm the accuracy of
performance, compatibility or any other claims related to non-IBM
products. Questions on the capabilities of non-IBM products should be
addressed to the suppliers of those products. IBM does not warrant the
quality of any third-party products, or the ability of any such third-party
products to interoperate with IBM’s products. IBM expressly
disclaims all warranties, expressed or implied, including but not
limited to, the implied warranties of merchantability and fitness
for a particular, purpose.
The provision of the information contained herein is not intended to,
and does not, grant any right or license under any IBM patents,
copyrights, trademarks or other intellectual property right.
IBM, the IBM logo, ibm.com, Aspera®, Bluemix, Blueworks Live, CICS,
Clearcase, Cognos®, DOORS®, Emptoris®, Enterprise Document
Management System™, FASP®, FileNet®, Global Business Services®,
Global Technology Services®, IBM ExperienceOne™, IBM
SmartCloud®, IBM Social Business®, Information on Demand, ILOG,
Maximo®, MQIntegrator®, MQSeries®, Netcool®, OMEGAMON,
OpenPower, PureAnalytics™, PureApplication®, pureCluster™,
PureCoverage®, PureData®, PureExperience®, PureFlex®,
pureQuery®, pureScale®, PureSystems®, QRadar®, Rational®,
Rhapsody®, Smarter Commerce®, SoDA, SPSS, Sterling Commerce®,
StoredIQ, Tealeaf®, Tivoli® Trusteer®, Unica®, urban{code}®, Watson,
WebSphere®, Worklight®, X-Force® and System z® Z/OS, are
trademarks of International Business Machines Corporation, registered
in many jurisdictions worldwide. Other product and service names
might be trademarks of IBM or other companies. A current list of IBM
trademarks is available on the Web at "Copyright and trademark
information" at: www.ibm.com/legal/copytrade.shtml.
InterConnect
2017
43 3/21/17
Backup
Differences in Column Types
• Mapping fields to columns
• Example: java.lang.String fields
• OpenJPA: VARCHAR(254)
• EclipseLink: VARCHAR(255)
• Mostly non-problematic
• Exception: java.util.Locale fields
• OpenJPA: VARCHAR(254)
• EclipseLink: BLOB(64000)
• Solution
• Use a type converter (introduced in JPA 2.1)
• BLOB (object) ↔ VARCHAR (database)
45
OpenJPA to EclipseLink
Investigation
Investigation
• Goal
• Find differences in behavior between OpenJPA and EclipseLink
• OpenJPA → EclipseLink migration issues
• Data
• Entities from OpenJPA's testing framework (>700 entities)
• Process
• Auto generate databases tables using both providers
• Use tables created by OpenJPA for verification
• Database: DB2
• Results
• Errors (fix EclipseLink)
• Table differences 47
No-arg Constructor
• JPA 2.1 Spec: an entity must have a no-arg constructor
• OpenJPA: if missing, generates a no-arg constructor.
• EclipseLink: throws an error only if the no-arg constructor is missing,
but other constructors exist.
• Solution: Add an empty no-arg constructor
48
Add no-arg
constructor
Getter/Setter accessor methods
• Annotated getter method with no corresponding setter
• OpenJPA: silently ignores the field
• EclipseLink: throws an error during entity validation
• Solution: remove annotation 49
Missing setVersion method
Private Accessor Methods
• JPA 2.1 Spec: property accessor methods must be public or
protected
• OpenJPA: ignores “private” fields
• EclipseLink: persists “private” fields
• Migrating issue: missing database column error
• Solution: Add @Transient to the method
• Forces EclipseLink to ignore the field
50
Add @Transient
Unannotated Collections
• Unannotated fields of type java.util.Collection or any of it’s
subinterfaces (List<E>, Queue<E>, Set<E>, etc)
• OpenJPA: ignores fields
• EclipseLink: persists fields
• Solution: Add @javax.persistence.Transient
51
Add @Transient
@javax.persistence.ElementCollection
• @ElementCollection generates a Separate table
• Two columns: id, value
• Different value column name
• OpenJPA: 'element’
• CREATE TABLE EntityA_LISTOFSTRINGS (ENTITYA_ID INTEGER,
element VARCHAR(254))
• EclipseLink: field name
• CREATE TABLE EntityA_LISTOFSTRINGS (EntityA_ID INTEGER,
LISTOFSTRINGS VARCHAR(255))
• Solution: Add @javax.persistence.Column
52
Add @Column
Behavior Mismatch: @GeneratedValue
• Generate values for primary keys
• Strategies: TABLE, SEQUENCE, IDENTITY, AUTO
• No Strategy or 'AUTO': JPA provider picks the strategy
• Good news: OpenJPA and EclipseLink default to 'TABLE' strategy
• Bad news: different table schemas are created
• Solution
• Change entity to explicitly use 'TABLE' strategy
• Map to existing OpenJPA table
53
Java Persistence Query Language (JPQL)
• @NamedQuery: specify named query in JPQL
• OpenJPA: ignores invalid unused JPQL statements
• EclipseLink: validates all JPQL statement by default
• Solutions
• Solution 1: fix JPQL statements
• Solution 2: set eclipselink's invalid JPQL tolerance property to
true
54
Unique Names
• Tables, NamedQuery, SQLResultSetMapping must have unique
names
• OpenJPA behavior is undefined
• Example: tables with same name are combined
• EclipseLink throws an error during entity validation
• Solution: review entities (manual process) 55

More Related Content

PDF
Enterprise Persistence in OSGi - Mike Keith, Oracle
PDF
NLOUG 2017- Oracle WebCenter Portal 12c Performance
PDF
NLOUG 2018 - Future of JSF and ADF
PPT
Servlet programming
PPT
Servlet programming
PPTX
Interface callable statement
PPTX
The Eclipse Transformer Project
Enterprise Persistence in OSGi - Mike Keith, Oracle
NLOUG 2017- Oracle WebCenter Portal 12c Performance
NLOUG 2018 - Future of JSF and ADF
Servlet programming
Servlet programming
Interface callable statement
The Eclipse Transformer Project

What's hot (20)

PDF
AAI 2236-Using the New Java Concurrency Utilities with IBM WebSphere
PDF
Java EE 8 Web Frameworks: A Look at JSF vs MVC
PPTX
Modular Java
PPTX
Angularj2.0
PDF
Java EE 7 Recipes for Concurrency - JavaOne 2014
PDF
Orcale Presentation
PPTX
Getting Started with Java EE 7
PDF
Contributors Guide to the Jakarta EE 10 Galaxy
PDF
8i r3 nfs
PPT
Developing modular Java applications
PPTX
Angular 2.0
PDF
Oracle History #5
PPTX
PDF
50 New Features of Java EE 7 in 50 minutes
PDF
Java 7 workshop
PDF
Java EE 8 Recipes
PDF
Avoiding Java EE Application Design Traps to Achieve Effective Use of Cloud C...
PDF
Sun Java EE 6 Overview
PPTX
Jdbc introduction
PDF
Java EE6 CodeCamp16 oct 2010
AAI 2236-Using the New Java Concurrency Utilities with IBM WebSphere
Java EE 8 Web Frameworks: A Look at JSF vs MVC
Modular Java
Angularj2.0
Java EE 7 Recipes for Concurrency - JavaOne 2014
Orcale Presentation
Getting Started with Java EE 7
Contributors Guide to the Jakarta EE 10 Galaxy
8i r3 nfs
Developing modular Java applications
Angular 2.0
Oracle History #5
50 New Features of Java EE 7 in 50 minutes
Java 7 workshop
Java EE 8 Recipes
Avoiding Java EE Application Design Traps to Achieve Effective Use of Cloud C...
Sun Java EE 6 Overview
Jdbc introduction
Java EE6 CodeCamp16 oct 2010
Ad

Similar to Haj 4308-open jpa, eclipselink, and the migration toolkit (20)

PDF
InterConnect 2016, OpenJPA and EclipseLink Usage Scenarios (PEJ-5303)
PDF
AAI-2235 Open JPA and EclipseLink Usage Scenarios Explained
PDF
AAI 2235-OpenJPA and EclipseLink Usage Scenarios Explained
PPT
JPA Performance Myths -- JavaOne 2013
PPT
ORM Concepts and JPA 2.0 Specifications
PDF
EclipseLink JPA
PDF
Java persistence api 2.1
PPT
Rollin onj Rubyv3
PDF
Websphere-corporate-training-in-mumbai
PDF
Websphere-corporate-training-in-mumbai
PDF
Migrating traditional Java EE Applications to mobile
PPT
EJB 3.2/JPA 2.1 Best Practices with Real-Life Examples - CON7535
PDF
Connect2014 Show104: Practical Java
PDF
3983 cics java real life projects
PPTX
ODTUG_NoPlsql_vs_SmartDB_Part1_and_2.pptx
PDF
Java EE 7 for WebLogic 12c Developers
PPTX
Web 2.0 Development with IBM DB2
PPT
Gentle into to DataGrid technology and customer use cases
PPTX
WebSphere App Server vs JBoss vs WebLogic vs Tomcat
PPT
J2EE Batch Processing
InterConnect 2016, OpenJPA and EclipseLink Usage Scenarios (PEJ-5303)
AAI-2235 Open JPA and EclipseLink Usage Scenarios Explained
AAI 2235-OpenJPA and EclipseLink Usage Scenarios Explained
JPA Performance Myths -- JavaOne 2013
ORM Concepts and JPA 2.0 Specifications
EclipseLink JPA
Java persistence api 2.1
Rollin onj Rubyv3
Websphere-corporate-training-in-mumbai
Websphere-corporate-training-in-mumbai
Migrating traditional Java EE Applications to mobile
EJB 3.2/JPA 2.1 Best Practices with Real-Life Examples - CON7535
Connect2014 Show104: Practical Java
3983 cics java real life projects
ODTUG_NoPlsql_vs_SmartDB_Part1_and_2.pptx
Java EE 7 for WebLogic 12c Developers
Web 2.0 Development with IBM DB2
Gentle into to DataGrid technology and customer use cases
WebSphere App Server vs JBoss vs WebLogic vs Tomcat
J2EE Batch Processing
Ad

More from Kevin Sutter (9)

PDF
DevNexus 2019: MicroProfile and Jakarta EE - What's Next?
PDF
Implementing Microservices with Jakarta EE and MicroProfile
PDF
Bmc 4286-micro profile-a programming model for microservices-based applications
PDF
Ham 4393-micro profile, java ee, and the application server
PDF
Haj 4328-java ee 7 overview
PDF
Haj 4344-java se 9 and the application server-1
PDF
Bas 5676-java ee 8 introduction
PDF
InterConnect 2016 Java EE 7 Overview (PEJ-5296)
PDF
AAI 1713-Introduction to Java EE 7
DevNexus 2019: MicroProfile and Jakarta EE - What's Next?
Implementing Microservices with Jakarta EE and MicroProfile
Bmc 4286-micro profile-a programming model for microservices-based applications
Ham 4393-micro profile, java ee, and the application server
Haj 4328-java ee 7 overview
Haj 4344-java se 9 and the application server-1
Bas 5676-java ee 8 introduction
InterConnect 2016 Java EE 7 Overview (PEJ-5296)
AAI 1713-Introduction to Java EE 7

Recently uploaded (20)

PDF
Understanding Forklifts - TECH EHS Solution
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PDF
Nekopoi APK 2025 free lastest update
PPTX
Reimagine Home Health with the Power of Agentic AI​
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
L1 - Introduction to python Backend.pptx
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
medical staffing services at VALiNTRY
PDF
Digital Strategies for Manufacturing Companies
PDF
top salesforce developer skills in 2025.pdf
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
System and Network Administration Chapter 2
PPTX
Operating system designcfffgfgggggggvggggggggg
Understanding Forklifts - TECH EHS Solution
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Odoo POS Development Services by CandidRoot Solutions
wealthsignaloriginal-com-DS-text-... (1).pdf
iTop VPN Free 5.6.0.5262 Crack latest version 2025
Nekopoi APK 2025 free lastest update
Reimagine Home Health with the Power of Agentic AI​
CHAPTER 2 - PM Management and IT Context
Navsoft: AI-Powered Business Solutions & Custom Software Development
Upgrade and Innovation Strategies for SAP ERP Customers
L1 - Introduction to python Backend.pptx
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Which alternative to Crystal Reports is best for small or large businesses.pdf
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
medical staffing services at VALiNTRY
Digital Strategies for Manufacturing Companies
top salesforce developer skills in 2025.pdf
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
System and Network Administration Chapter 2
Operating system designcfffgfgggggggvggggggggg

Haj 4308-open jpa, eclipselink, and the migration toolkit

  • 1. InterConnect 2017 OpenJPA and EclipseLink Usage Scenarios Explained Kevin Sutter, STSM WebSphere Java EE and JPA Architect Twitter: @kwsutter LinkedIn: https://www.linkedin.com/in/kevinwsutter Raymond Scott, SME WebSphere Migration WebSphere Configuration Migration Twitter: @rvscott128
  • 2. 2 3/21/17 Please note IBM’s statements regarding its plans, directions, and intent are subject to change or withdrawal without notice at IBM’s sole discretion. Information regarding potential future products is intended to outline our general product direction and it should not be relied on in making a purchasing decision. The information mentioned regarding potential future products is not a commitment, promise, or legal obligation to deliver any material, code or functionality. Information about potential future products may not be incorporated into any contract. The development, release, and timing of any future features or functionality described for our products remains at our sole discretion. Performance is based on measurements and projections using standard IBM benchmarks in a controlled environment. The actual throughput or performance that any user will experience will vary depending upon many factors, including considerations such as the amount of multiprogramming in the user’s job stream, the I/O configuration, the storage configuration, and the workload processed. Therefore, no assurance can be given that an individual user will achieve results similar to those stated here.
  • 3. Agenda • JPA in WebSphere Application Server • JPA Providers: OpenJPA and EclipseLink • OpenJPA to EclipseLink Migration • High level concepts • OpenJPA to EclipseLink Investigation • Specific differences • WebSphere Migration and Toolkit • Summary • Q & A 3
  • 4. JPA in WebSphere Application Server Kevin Sutter, Java EE Architect
  • 5. JPA in WebSphere Application Server 5 WebSphere Application Server JPA 2.0 OpenJPA JPA 2.1JPA 1.0 OpenJPA EclipseLink • Apache OpenJPA • Basis for WebSphere’s JPA solution for JPA 1.0 and JPA 2.0 • EclipseLink • JPA Reference Implementation – “gospel” • Basis for WebSphere Liberty’s JPA solution for JPA 2.1
  • 6. JPA in WebSphere Application Server • Moving forward… • OpenJPA will continue to be supported in WebSphere for many, many years • At least until JPA 2.0 is ever deprecated… • Both WebSphere traditional and Liberty • Do I have to switch providers? • Absolutely not! • If you are happy with the current OpenJPA offering, there is no need to move to EclipseLink • If you want to use the JPA 2.1 features, you may need to change… • Many of the JPA 2.1 features have corresponding OpenJPA proprietary solutions 6
  • 7. JPA in WebSphere Application Server 7 WebSphere Application Server Java EE 6 Servlets 3.0 EJB 3.1 … JPA 2.0 WebSphere Application Server Java EE 7 Servlets 3.1 EJB 3.2 … JPA 2.0JPA 2.1 • Apache OpenJPA (ie. JPA 2.0) is compatible with other Java EE 7 features • Allows for an easier, more gradual JPA migration
  • 8. Key JPA 2.1 Features available in OpenJPA • Schema Generation (JPA 2.1 Spec, Section 9.4) • Generates DDL or interacts directly with database to define table schemas based on JPA Entity definitions • Similar functionality provided by OpenJPA’s schema mapper • Entity Graphs (JPA 2.1 Spec, Section 3.7) • Allows for specified fetching or processing of a graph of Entity objects • Similar functionality provided by OpenJPA’s FetchPlan and FetchGroup • Stored Procedure Queries (JPA 2.1 Spec, Section 3.10.17) • Ability to invoke database stored procedures • Similar functionality provided by OpenJPA’s Query invocation 8
  • 9. Additional JPA 2.1 Features available in OpenJPA • Basic Attribute Type Conversion (JPA 2.1 Spec, Section 3.8) • Similar functionality support provided by OpenJPA’s Externalizer feature • @Index and @ForeignKey annotations (JPA 2.1 Spec, Sections 11.1.19 and 11.1.23) • Similar functionality provided by OpenJPA’s annotations • Unwrap utility methods for EntityManager, Cache, etc (JPA 2.1 Spec Sections 3.1.1 and 7.10) • Similar functionality provided by OpenJPA’s implementation -- EntityManagerImpl.unwrap() and OpenJPAPersistence.cast() • Object construction when mapping results from native SQL (JPA 2.1 Spec, Section 3.10.16.2.2) • Similar functionality provided by OpenJPA’s internal ResultShape object 9
  • 10. Additional JPA 2.1 Features NOT available in OpenJPA • Criteria API Updates (JPA 2.1 Spec, Sections 6.5.15 and 6.5.7) • Bulk update/delete • Support for TREAT, ON, and FUNCTION operators • Unsynchronized Persistence Contexts (JPA 2.1 Spec, Section 7.6.1) • Provides more control over when Persistence Contexts are synchronized with a transaction. Useful for mobile applications. • EntityListeners and CDI (JPA 2.1 Spec, Section 3.5.1) • EntityListeners can now use CDI for injection of objects • JPQL Updates for JPA 2.1 (JPA 2.1 Spec, Chapter 4) • Several extensions to JPQL in support of the other features • OpenJPA’s JPQL will stay at the JPA 2.0 level 10
  • 11. Feature Comparison Chart 11 Key JPA 2.1 Features Available in current OpenJPA solution? Schema Generation Yes, SynchronizeMappings Entity Graphs Yes, FetchPlans and FetchGroups Stored Procedures Yes, Query interface Basic Attribute Type Conversion Yes, Externalizer (and Factory) @Index and @ForeignKey annotations Yes, proprietary @Index and @ForeignKey annotations Unwrap utility functions Yes, EntityManagerImpl.unwrap() and OpenJPAPersistence.cast() Object construction when mapping results with native SQL Yes, ResultShape (internal OpenJPA implementation) Criteria API updates No Unsynchronized PersistenceContexts No EntityListeners and CDI No JPQL Updates in support of JPA 2.1 No
  • 12. Bottom Line • YOU DO NOT NEED TO MIGRATE • Our Advice • Continue using OpenJPA for your existing applications • Use EclipseLink for your new applications • But… If you want to use EclipseLink with existing applications, the following slides will discuss what to look out for when migrating existing applications 12
  • 14. Cache • DataCache • OpenJPA: L2 cache disabled by default • EclipseLink: L2 cache enabled by default. • If you are migrating an application that isn't using the OpenJPA cache, it is highly recommended to disable the L2 cache using: <shared-cache-mode>NONE</shared-cache-mode> • Query (Results) Cache • If QueryCache is enabled, • OpenJPA: All Named Queries and JPQL Statement Results are cached • EclipseLink: only Named Queries Results are cached • More information on EclipseLink QueryCache here 14
  • 15. Weaving/enhancement/transformation • OpenJPA: Entities must be enhanced • EclipseLink: Entities do not have to be enhanced • Documented missing features (lazy loading, performance gains, etc) • WebSphere container automatically weaves/enhances Entities for both OpenJPA and EclipseLink • Applications packaged with entities pre-enhanced by OpenJPA must be recompiled and repackaged • Removes OpenJPA specific enhancement bytecode 15
  • 17. Summary • Detail in Backup charts • Do I want to utilize my existing database tables? • Modifications to the entities may be necessary • Database tables previously created (by OpenJPA) may not match EclipseLink’s generated tables • OpenJPA may have been more lenient with spec violations than Eclipselink is • Recommendation • Continue using OpenJPA for existing applications • Migrate to EclipseLink only for new applications 17
  • 18. WebSphere Migration & ToolKit Ray Scott, Migration SME
  • 19. Do you need to migrate JPA? Best practice is to • Use OpenJPA for your existing applications • Use EclipseLink for your new applications But… If you need to migrate, we have tools to assist. 19
  • 20. Traditional Application Server Migration • V9.0 profile creation configures servers with JPA 2.1 – EclipseLink • Migration reconfigures servers to use JPA 2.0 – OpenJPA • Applications migrated to v9.0 as-is. • EclipseLink was not shipped prior to V9.0 • Viewing and changing JPA configuration settings: (Knowledge Center) • In the administrative console: Servers > Server Types > WebSphere application servers > server_name > Container Services > Default Java Persistence API settings • In the wsadmin console: • List JPA options: print AdminTask.listSupportedJPASpecifications() • Display current setting: print AdminTask.showJPASpecLevel('[-node myNode01 -server server1]') • Change JPA provider: print AdminTask.modifyJPASpecLevel('[-node myNode01 -server server1 -specLevel 2.1]') 20
  • 21. Liberty Server Migration No migration for Liberty. Simply configure server.xml with desired JPA feature level. 21
  • 22. Application Migration Whether Traditional or Liberty … if you change the JPA configuration … you will need to migrate the applications. The WebSphere Application Migration Toolkit and the binaryScanner can help 22
  • 23. An Overview of WebSphere Migration Tools A set of tools help you: - Migrate from third-party application servers to WebSphere Application Server - Migrate between versions of WebSphere Application Server - Migrate to WebSphere Application Server to the Cloud 23 Migration discovery Binaries analysis Source migration Config migration On-line tool that helps you •Estimate the effort required to migrate your application to WebSphere Application Server from third-party application servers •Select the IBM cloud platform suited to host your application and estimate migration to that platform Command-line analysis of application binaries that provides • High level evaluation report showing the Java EE technologies your application uses • Detailed analysis for migration between versions of WebSphere traditional, Liberty, and Liberty Core • Cloud migration for instant runtimes differences • Java EE 7 differences • Cloud connectivity analysis Eclipse plugins that scans application source to provide • High level evaluation report • A line-by-line analysis of code changes required • Detailed analysis for migrating from third-party applications servers • Detailed analysis for migration between versions of WebSphere traditional, Liberty, and Liberty Core • Java EE 7 differences • Cloud migration for instant runtimes differences • Cloud connectivity analysis Eclipse plugin that helps migrate server configuration •From third-party application servers to WebSphere Application Server •Between versions of WebSphere Application Server including WebSphere traditional to Liberty.
  • 24. How can the migration toolkit help? • Scan for OpenJPA to EclipseLink differences • The Eclipse-based, source scanning migration tool • Contains 19 Java rules with 9 quick fixes • Contains 5 XML rules with 2 quick fixes • Focuses on annotated JPA applications • Provides some configuration support • The binary scanning tool • Detects Entities enhanced for OpenJPA • Contains 2 Java rules • Contains 5 XML rules 24
  • 25. Where can I get the migration tools? • http://wasdev.net 25 • Eclipse Marketplace
  • 26. How do I use the Eclipse migration tool? Select Run > Analysis… to configure the JPA related rules. •Choose the OpenJPA to EclipseLink JPA Migration rule set if you are only interested in the JPA rules. 26
  • 27. How do I use the Eclipse migration tool? • Select Run > Analysis to configure JPA related rules. • Choose the WebSphere Application Server Version Migration rule set if you want to do more analysis. • Select Java EE 7 as the target Java EE version • Select JPA 27
  • 28. 28 See the code to change • After running Analysis, use the Software Analyzer Results view to interpret the scan.
  • 29. 29 See the proposed fix before applying the change
  • 30. When you need more help 30 • Each rule has help that you can view from the results or from the configuration dialog.
  • 31. 31 What can I expect? -- Java rules
  • 32. 32 What can I expect? -- XML rules Note: The rule Mapping files are not processed during OpenJPA to EclipseLink migration is a reminder that most of the rules are Java annotation rules. If define your Entities in mapping files rather than using JPA annotations, you will need to make manual mapping file changes.
  • 33. What if I don’t have source code? The binary scanner detects • Enhanced Java code – only in the binary scanner • the XML issues • org.apache.openjpa packages in use 33
  • 34. How do I use the binary scanner? • java -jar binaryAppScanner.jar --help 34
  • 36. Other Tools: Integrity Checker • EclipseLink provides a way to verify descriptor's metadata against database metadata • Setup the integrity checker using a session customizer (link) • Catches missing tables or columns without having to persist • Example: private getter methods • setShouldCatchExceptions(true) - find all entities with missing columns • Cons: doesn't catch everything or maybe anything… • Failed to catch @ElementColumn resulting in a different column name in the separate table, @GeneratedValue looking for a different table • Doesn't compare column types • Better than nothing, but it missed many common issues 36
  • 37. Useful Links • EclipseLink JPA provider for Liberty profile article https://developer.ibm.com/wasdev/blog/2014/05/28/eclipselink-jpa- provider-liberty-profile/ • EclipseLink Migration Wiki Page https://wiki.eclipse.org/EclipseLink/Examples/JPA/Migration/OpenJPA • V9 WebSphere Knowledge Center - JPA Instructions https://www.ibm.com/support/knowledgecenter/SSAW57_9.0.0/com.ibm.w ebsphere.nd.multiplatform.doc/ae/container_jpa_administering.html 37
  • 38. Useful Links • WebSphere Application Server Migration Toolkit • wasdev.net download and links to the documentation • https://developer.ibm.com/wasdev/downloads/#asset/tools-WebSphere_Application_Server_Migration_Toolkit • Eclipse Marketplace • https://marketplace.eclipse.org/content/ibm-websphere-application-server-migration-toolkit • Migration Toolkit for Application Binaries • wasdev.net download and links to the documentation • https://developer.ibm.com/wasdev/downloads/#asset/tools-Migration_Toolkit_for_Application_Binaries 38
  • 39. Sampling of Related Sessions… • PEJ-5296: Java EE 7 Overview – Monday, 10:30am-11:30am, Mandalay Bay North, South Pacific Ballroom A • PEJ-2876: Configuring WebSphere Application Server for Enterprise Messaging Needs – Monday, 12:00pm-1:00pm, Mandalay Bay North, Islander Ballroom G • PEJ-2139: Technical Deep Dive into IBM WebSphere Liberty – Monday, 3:00pm-4:00pm, Mandalay Bay North, South Pacific Ballroom A • PEJ-1603: IBM WebSphere Liberty in the Wild – Tuesday, 1:15pm-2:15pm, Mandalay Bay North, South Pacific Ballroom A • PEJ-6480: Don’t Wait! Developing Responsive Applications with Java EE 7 – Tuesday, 1:15pm-2:15pm, Mandalay Bay North, Islander Ballroom G • PEJ-1979: Hands-On with the IBM WebSphere Application Server Migration Toolkit (LAB) – Tuesday, 01:15 PM - 02:15 PM, MGM Grand - Room 320 • PEJ-2151: Agile Development Using Java EE 7 with WebSphere Liberty Profile (LAB) – Wednesday, 8:30am-9:30am, MGM Grand Room 306 • PEJ-1973: WAS Migration: Benefits, Planning, and Best Practices – Wednesday, 12:00pm-1:00pm, Mandalay Bay North, South Pacific Ballroom A • PEJ-1902: Migrate Java EE Applications to Cloud with Cloud Migration Toolkit – Wednesday, 2:30pm-12:15pm, Mandalay Bay North, Islander Ballroom G • PEJ-5303: OpenJPA and EclipseLink Usage Scenarios Explained – Thursday, 11:30am-12:15pm, Mandalay Bay North, South Pacific Ballroom A 39 39
  • 41. 41 3/21/17 Notices and disclaimers Copyright © 2017 by International Business Machines Corporation (IBM). No part of this document may be reproduced or transmitted in any form without written permission from IBM. U.S. Government Users Restricted Rights — use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM. Information in these presentations (including information relating to products that have not yet been announced by IBM) has been reviewed for accuracy as of the date of initial publication and could include unintentional technical or typographical errors. IBM shall have no responsibility to update this information. This document is distributed “as is” without any warranty, either express or implied. In no event shall IBM be liable for any damage arising from the use of this information, including but not limited to, loss of data, business interruption, loss of profit or loss of opportunity. IBM products and services are warranted according to the terms and conditions of the agreements under which they are provided. IBM products are manufactured from new parts or new and used parts. In some cases, a product may not be new and may have been previously installed. Regardless, our warranty terms apply.” Any statements regarding IBM's future direction, intent or product plans are subject to change or withdrawal without notice. Performance data contained herein was generally obtained in a controlled, isolated environments. Customer examples are presented as illustrations of how those customers have used IBM products and the results they may have achieved. Actual performance, cost, savings or other results in other operating environments may vary. References in this document to IBM products, programs, or services does not imply that IBM intends to make such products, programs or services available in all countries in which IBM operates or does business. Workshops, sessions and associated materials may have been prepared by independent session speakers, and do not necessarily reflect the views of IBM. All materials and discussions are provided for informational purposes only, and are neither intended to, nor shall constitute legal or other guidance or advice to any individual participant or their specific situation. It is the customer’s responsibility to insure its own compliance with legal requirements and to obtain advice of competent legal counsel as to the identification and interpretation of any relevant laws and regulatory requirements that may affect the customer’s business and any actions the customer may need to take to comply with such laws. IBM does not provide legal advice or represent or warrant that its services or products will ensure that the customer is in compliance with any law.
  • 42. 42 3/21/17 Notices and disclaimers continued Information concerning non-IBM products was obtained from the suppliers of those products, their published announcements or other publicly available sources. IBM has not tested those products in connection with this publication and cannot confirm the accuracy of performance, compatibility or any other claims related to non-IBM products. Questions on the capabilities of non-IBM products should be addressed to the suppliers of those products. IBM does not warrant the quality of any third-party products, or the ability of any such third-party products to interoperate with IBM’s products. IBM expressly disclaims all warranties, expressed or implied, including but not limited to, the implied warranties of merchantability and fitness for a particular, purpose. The provision of the information contained herein is not intended to, and does not, grant any right or license under any IBM patents, copyrights, trademarks or other intellectual property right. IBM, the IBM logo, ibm.com, Aspera®, Bluemix, Blueworks Live, CICS, Clearcase, Cognos®, DOORS®, Emptoris®, Enterprise Document Management System™, FASP®, FileNet®, Global Business Services®, Global Technology Services®, IBM ExperienceOne™, IBM SmartCloud®, IBM Social Business®, Information on Demand, ILOG, Maximo®, MQIntegrator®, MQSeries®, Netcool®, OMEGAMON, OpenPower, PureAnalytics™, PureApplication®, pureCluster™, PureCoverage®, PureData®, PureExperience®, PureFlex®, pureQuery®, pureScale®, PureSystems®, QRadar®, Rational®, Rhapsody®, Smarter Commerce®, SoDA, SPSS, Sterling Commerce®, StoredIQ, Tealeaf®, Tivoli® Trusteer®, Unica®, urban{code}®, Watson, WebSphere®, Worklight®, X-Force® and System z® Z/OS, are trademarks of International Business Machines Corporation, registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at: www.ibm.com/legal/copytrade.shtml.
  • 45. Differences in Column Types • Mapping fields to columns • Example: java.lang.String fields • OpenJPA: VARCHAR(254) • EclipseLink: VARCHAR(255) • Mostly non-problematic • Exception: java.util.Locale fields • OpenJPA: VARCHAR(254) • EclipseLink: BLOB(64000) • Solution • Use a type converter (introduced in JPA 2.1) • BLOB (object) ↔ VARCHAR (database) 45
  • 47. Investigation • Goal • Find differences in behavior between OpenJPA and EclipseLink • OpenJPA → EclipseLink migration issues • Data • Entities from OpenJPA's testing framework (>700 entities) • Process • Auto generate databases tables using both providers • Use tables created by OpenJPA for verification • Database: DB2 • Results • Errors (fix EclipseLink) • Table differences 47
  • 48. No-arg Constructor • JPA 2.1 Spec: an entity must have a no-arg constructor • OpenJPA: if missing, generates a no-arg constructor. • EclipseLink: throws an error only if the no-arg constructor is missing, but other constructors exist. • Solution: Add an empty no-arg constructor 48 Add no-arg constructor
  • 49. Getter/Setter accessor methods • Annotated getter method with no corresponding setter • OpenJPA: silently ignores the field • EclipseLink: throws an error during entity validation • Solution: remove annotation 49 Missing setVersion method
  • 50. Private Accessor Methods • JPA 2.1 Spec: property accessor methods must be public or protected • OpenJPA: ignores “private” fields • EclipseLink: persists “private” fields • Migrating issue: missing database column error • Solution: Add @Transient to the method • Forces EclipseLink to ignore the field 50 Add @Transient
  • 51. Unannotated Collections • Unannotated fields of type java.util.Collection or any of it’s subinterfaces (List<E>, Queue<E>, Set<E>, etc) • OpenJPA: ignores fields • EclipseLink: persists fields • Solution: Add @javax.persistence.Transient 51 Add @Transient
  • 52. @javax.persistence.ElementCollection • @ElementCollection generates a Separate table • Two columns: id, value • Different value column name • OpenJPA: 'element’ • CREATE TABLE EntityA_LISTOFSTRINGS (ENTITYA_ID INTEGER, element VARCHAR(254)) • EclipseLink: field name • CREATE TABLE EntityA_LISTOFSTRINGS (EntityA_ID INTEGER, LISTOFSTRINGS VARCHAR(255)) • Solution: Add @javax.persistence.Column 52 Add @Column
  • 53. Behavior Mismatch: @GeneratedValue • Generate values for primary keys • Strategies: TABLE, SEQUENCE, IDENTITY, AUTO • No Strategy or 'AUTO': JPA provider picks the strategy • Good news: OpenJPA and EclipseLink default to 'TABLE' strategy • Bad news: different table schemas are created • Solution • Change entity to explicitly use 'TABLE' strategy • Map to existing OpenJPA table 53
  • 54. Java Persistence Query Language (JPQL) • @NamedQuery: specify named query in JPQL • OpenJPA: ignores invalid unused JPQL statements • EclipseLink: validates all JPQL statement by default • Solutions • Solution 1: fix JPQL statements • Solution 2: set eclipselink's invalid JPQL tolerance property to true 54
  • 55. Unique Names • Tables, NamedQuery, SQLResultSetMapping must have unique names • OpenJPA behavior is undefined • Example: tables with same name are combined • EclipseLink throws an error during entity validation • Solution: review entities (manual process) 55