0
The following is intended to outline our general product direction. It is    intended for information purposes only, and m...
2   Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
The Evolution of Java PersistenceShaun Smithshaun.smith@oracle.com 3 @shaunMsmith     Copyright © 2011, Oracle and/or its ...
Software Evolution    • Computing architecture is constantly evolving:      Mainframe, client/server, web/thin client, mob...
Evolutionary Pressures on Persistence    • Shared Services & Consolidation          – Multitenancy    • Mobile Clients    ...
EclipseLink Project    • Open Source Eclipse Project          – Founded with contribution of Oracle TopLink to Eclipse    ...
MULTITENANCY7   Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Multitenancy    Wikipedia http://en.wikipedia.org/wiki/Multitenancy    • Multitenancy refers to a principle in software ar...
Application Development and the Cloud    • Past          – Single Tenant or non-Tenant Applications          – Dedicated a...
Multitenant Topologies                                                                                          Applicatio...
Multitenant Topologies                                                                                          Applicatio...
In the beginning…     • Application dedicated for single tenant     • All rows available to all queries          @Entity  ...
Multitenant: SINGLE_TABLE     • Simple configuration: Annotation or XML     • Flexible tenant identifier support     • Ecl...
Multitenant: TENANT_PER_TABLE     • Simple configuration: Annotation or XML     • EclipseLink queries table based on tenta...
DEMO-MULTITENANCY15   Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
DOMAIN MODEL EXTENSIONS16   Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Domain Model Extensions     • Storage and querying of extended properties           –      Application developer enables e...
Flex Extensions@VirtualAccessMethodspublic class Player{…@Transientprivate Map<String, Object> attributes;public <T> T get...
Virtual Access Mappings<entity class="example.mysports.model.Player">      <attributes>                <basic name="penalt...
DEMO DOMAIN MODEL EXTENSIONS20   Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
JPA-RS21   Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Project Avatar     Complete Solution for Dynamic Rich ClientsHTML 5 browser                                               ...
JPA-RS: Building Block of Project Avatar     • Exposes JPA mapped entities over REST via JAX-RS     • Provides REST operat...
JPA/JAX-RS: Current Programming Model                                                                                     ...
JAX-RS with JPA Example – GET Invoice     public class InvoiceService {...         public Invoice read(int id) {          ...
JAX-RS with JPA Example – GET Invoice     @Stateless     public class InvoiceService {...         public Invoice read(int ...
JAX-RS with JPA Example – GET Invoice     @Path("/invoice")     @Stateless     public class InvoiceService {...         pu...
JAX-RS with JPA Example – GET Invoice     @Path("/invoice")     @Stateless     public class InvoiceService {...         @G...
JAX-RS with JPA Example – GET Invoice     @Path("/invoice")     @Stateless     public class InvoiceService {...         @G...
JPA-RS: Thin Server Architecture                                                                                   GET htt...
JPA-RS: Building Block of Project Avatar     • Persistence Unit Operations           – /<root-uri>/<pu-name>/entity       ...
Client with Server Development                                                                                            ...
MySports – Java EE     Clients                                                                                            ...
MySports – JPA-RS Enabled     Clients                                                                                     ...
JAX-RS DEMO35   Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
NOSQL PERSISTENCE41   Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
NoSQL Databases     • NoSQL (i.e., non-relational) database are increasingly       popular     • No standards     • Differ...
EclipseLink NoSQL     • Support JPA access to NoSQL databases           – Leverage non-relational database support for JCA...
Example MongoDB Mapped Entity44   Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
MongoDB Query Examples     JPQL Queries:         Select o from Order o where o.totalCost > 1000         Select o from Orde...
Polyglot Persistence     • Relationships can span databases—and technologies!                                             ...
NOSQL DEMO47   Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Summary     • Java is evolving—and EclipseLink is evolving too!           –      Tenant Isolation/Multitenancy           –...
Q&A                              Provide Feedback, Get Involved!                              User forums and lists at htt...
50   Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
Upcoming SlideShare
Loading in...5
×

The Evolution of Java Persistence in EclipseLink: Shaun Smith

1,197

Published on

Data access today isn’t just about reading and writing from relational databases anymore. It’s also about mapping your objects to XML and to JSON for use in RESTful web services. It’s about being able to persist your objects in NoSQL databases and being able to cache them in data grids so you can scale out your application to hundreds of servers. The EclipseLink project is well known as an object-relational mapping framework and as the JPA 2.0 reference implementation in Java EE 6, but it is evolving to provide a comprehensive set of data services for Java developers building enterprise and cloud applications in Java EE, Java SE, and in OSGi. In this session we’ll dive into these new services and see how to build modern enterprise Java applications leveraging EclipseLink both in the back end for data persistence and on the front end to build RESTful services that support HTML5 clients.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,197
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
36
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "The Evolution of Java Persistence in EclipseLink: Shaun Smith"

  1. 1. The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.1 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  2. 2. 2 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  3. 3. The Evolution of Java PersistenceShaun Smithshaun.smith@oracle.com 3 @shaunMsmith Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  4. 4. Software Evolution • Computing architecture is constantly evolving: Mainframe, client/server, web/thin client, mobile/apps, ... • Current technologies with increasing adoption include: – Cloud computing – HTML 5 – NoSQL databases • Java EE 7 is evolving to address many of these new requirements4 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  5. 5. Evolutionary Pressures on Persistence • Shared Services & Consolidation – Multitenancy • Mobile Clients – JPA-RS • Scaling/Elastic Capacity – Data Partitioning – NoSQL/Big Data/Fast Data – Grid Caching5 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  6. 6. EclipseLink Project • Open Source Eclipse Project – Founded with contribution of Oracle TopLink to Eclipse Foundation • Object-Relational: Java Persistence API (JPA) – JPA 1.0 part of EJB 3.0 standard (JSR 220) – JPA 2.0 standardized in JSR 317 – EclipseLink is JPA 2.0 & 2.1 Reference Implementation • Object-XML: Java Architecture for XML Binding (JAXB) – JAXB 2.2 Certified Implementation6 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  7. 7. MULTITENANCY7 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  8. 8. Multitenancy Wikipedia http://en.wikipedia.org/wiki/Multitenancy • Multitenancy refers to a principle in software architecture where a single instance of the software runs on a server, serving multiple client organizations (tenants). • Multitenancy is contrasted with a multi-instance architecture where separate software instances (or hardware systems) are set up for different client organizations.8 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  9. 9. Application Development and the Cloud • Past – Single Tenant or non-Tenant Applications – Dedicated application instance and database • Today..Tomorrow – Support multiple tenants – Support extensibility (custom fields per tenant) – Support various deployment architectures • Dedicated or shared application instances • Dedicated or shared databases9 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  10. 10. Multitenant Topologies Application Dedicated Shared T1 T2 T3 T1 T2 T3 DedicatedDatabase 1 2 3 1 2 3 T1 T2 T3 T1 T2 T3 Shared 1 1 2 2 3 3 Note: Single application deployed to support various MT architectures10 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  11. 11. Multitenant Topologies Application Dedicated Shared T1 T2 T3 T1 T2 T3 DedicatedDatabase 1 2 3 1 2 3 T1 T2 T3 T1 T2 T3 Shared 1 1 2 2 3 3 Note: Single application deployed to support various MT architectures11 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  12. 12. In the beginning… • Application dedicated for single tenant • All rows available to all queries @Entity public class Player { PLAYER ID VERSION F_NAME L_NAME LEAGUE 1 1 John Doe HTHL 2 3 Jane Doe OSL12 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  13. 13. Multitenant: SINGLE_TABLE • Simple configuration: Annotation or XML • Flexible tenant identifier support • EclipseLink augments generated SQL @Entity @Multitenant(SINGLE_TABLE) @TenantDiscriminatorColumn(name=“league-id”, columnName=“LEAGUE”) public class Player { PLAYER ID VERSION F_NAME L_NAME LEAGUE 1 1 John Doe HTHL 2 3 Jane Doe OSL13 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  14. 14. Multitenant: TENANT_PER_TABLE • Simple configuration: Annotation or XML • EclipseLink queries table based on tentant identifier @Entity @Multitenant(TABLE_PER_TENANT) public class Player { HTHL.PLAYER ID VERSION F_NAME L_NAME 1 1 John Doe OSL.PLAYER ID VERSION F_NAME L_NAME 2 3 Jane Doe14 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  15. 15. DEMO-MULTITENANCY15 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  16. 16. DOMAIN MODEL EXTENSIONS16 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  17. 17. Domain Model Extensions • Storage and querying of extended properties – Application developer enables extensions in entity – Schema created with extension columns/table(s) – Application Admin stores extension definitions – Application instances made aware of extension definitions – Application users make use of extensions Employee id extensions * name firstName value lastName Map<String, Object>17 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  18. 18. Flex Extensions@VirtualAccessMethodspublic class Player{…@Transientprivate Map<String, Object> attributes;public <T> T get(String attributeName) { return (T) this.attributes.get(attributeName);}public Object set(String attributeName, Object value) { return this.attributes.put(attributeName, value);}PLAYERID F_NAME L_NAME FLEX_1 FLEX_21 John Doe ‘R’ ’22’2 Jane Smith ‘NONE’ 18 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  19. 19. Virtual Access Mappings<entity class="example.mysports.model.Player"> <attributes> <basic name="penaltyMinutes" access="VIRTUAL" attribute-type="java.lang.Integer"> <column name="flex_1"/> </basic> <basic name="position" access="VIRTUAL" attribute-type="java.lang.String"> <column name="flex_2"/> </basic> </attributes></entity> 19 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  20. 20. DEMO DOMAIN MODEL EXTENSIONS20 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  21. 21. JPA-RS21 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  22. 22. Project Avatar Complete Solution for Dynamic Rich ClientsHTML 5 browser JSON overHTML & Java WebSocket/hybrid application Server Send Events Java application Java EE Cloud22 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  23. 23. JPA-RS: Building Block of Project Avatar • Exposes JPA mapped entities over REST via JAX-RS • Provides REST operations for persistence unit REST JPA GET, HEAD Find, Named Query, Meta-model PUT, POST Persist, Merge DELETE Remove • Content-Type and Accept-based content negotiation – XML or JSON • Client – HTML5 with JavaScript (primary focus) – JavaFX23 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  24. 24. JPA/JAX-RS: Current Programming Model GET http://…/order/4 JAX-RS Customer Product Order Shop Persistence Unit JPA24 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  25. 25. JAX-RS with JPA Example – GET Invoice public class InvoiceService {... public Invoice read(int id) { return null; } ...25 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  26. 26. JAX-RS with JPA Example – GET Invoice @Stateless public class InvoiceService {... public Invoice read(int id) { return entityManager.find(Invoice.class, id); } ...26 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  27. 27. JAX-RS with JPA Example – GET Invoice @Path("/invoice") @Stateless public class InvoiceService {... public Invoice read(int id) { return entityManager.find(Invoice.class, id); } http://[machine]:[port]/[web-context]/invoice/... ...27 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  28. 28. JAX-RS with JPA Example – GET Invoice @Path("/invoice") @Stateless public class InvoiceService {... @GET @Path("{id}") public Invoice read(@PathParam("id") int id) { return entityManager.find(Invoice.class, id); } GET http://[machine]:[port]/[web-context]/invoice/4 ...28 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  29. 29. JAX-RS with JPA Example – GET Invoice @Path("/invoice") @Stateless public class InvoiceService {... @GET @Path("{id}") @Produces({"application/xml", "application/json"}) public Invoice read(@PathParam("id") int id) { return entityManager.find(Invoice.class, id); } Accept: application/json ... GET http://[machine]:[port]/[web-context]/invoice/429 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  30. 30. JPA-RS: Thin Server Architecture GET http://…/<pu-name>/<entity>/4 JPA-RS Shop PU … PU JPA30 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  31. 31. JPA-RS: Building Block of Project Avatar • Persistence Unit Operations – /<root-uri>/<pu-name>/entity – /<root-uri>/<pu-name>/query – /<root-uri>/<pu-name>/metadata • Supports invocation of @NamedQueries via HTTP • Server-caching – EclipseLink clustered cache • Dynamic Persistence also supported – Entities defined via metadata – no Java classes required – Enables persistence for HTML5/JavaScript apps31 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  32. 32. Client with Server Development Client HTML5 JavaScript Native devClientDeveloper Server Data devServer Java EE JPA-RSDeveloper config32 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  33. 33. MySports – Java EE Clients Data Server MySports HTTP/S JSF EJB JPA JDBC ORACLE CONFIDENTIA33 Copyright © 2011, Oracle and/or its affiliates. All rights reserved. L - INTERNAL ONLY
  34. 34. MySports – JPA-RS Enabled Clients Data Server MySports JSF HTTP/S EJB JPA JDBC JPA- RS ORACLE CONFIDENTIA34 Copyright © 2011, Oracle and/or its affiliates. All rights reserved. L - INTERNAL ONLY
  35. 35. JAX-RS DEMO35 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  36. 36. NOSQL PERSISTENCE41 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  37. 37. NoSQL Databases • NoSQL (i.e., non-relational) database are increasingly popular • No standards • Differing APIs and feature sets • Some offer query language/API—some not42 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  38. 38. EclipseLink NoSQL • Support JPA access to NoSQL databases – Leverage non-relational database support for JCA (and JDBC when available) • Define annotations and XML to identify NoSQL stored entities (e.g., @NoSQL) • Support JPQL subset for each – Key principal: leverage what’s available • Initial support for MongoDB and Oracle NoSQL. • Support mixing relational and non-relational data in single composite persistence unit (“polyglot persistence”)43 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  39. 39. Example MongoDB Mapped Entity44 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  40. 40. MongoDB Query Examples JPQL Queries: Select o from Order o where o.totalCost > 1000 Select o from Order o where o.description like Pinball%‘ Select o from Order o join o.orderLines l where l.cost > :cost Native Queries: query = em.createNativeQuery("db.ORDER.findOne({"_id":"" + oid + ""})", Order.class); Order order = (Order)query.getSingleResult();45 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  41. 41. Polyglot Persistence • Relationships can span databases—and technologies! Order Discount46 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  42. 42. NOSQL DEMO47 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  43. 43. Summary • Java is evolving—and EclipseLink is evolving too! – Tenant Isolation/Multitenancy – JSON Binding – JPA-RS – NoSQL – Polyglot Persistence • EclipseLink is the center of innovation in Java persistence48 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  44. 44. Q&A Provide Feedback, Get Involved! User forums and lists at http://eclipse.org/eclipselink49 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  45. 45. 50 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×