SlideShare a Scribd company logo
1 of 49
1   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
The Evolution of Java
Persistence

Shaun Smith
@shaunMsmith



2   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
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.




3   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Java Persistence: The Problem Space
                                   Customer                                                <customer id=―…‖>
                                                                                              <name>…</name>
                           id: int                                         JAXB               …
                           name: String                                                    </contact-info>
                           creditRating: int                                               </customer>
                                              Java
                                                                                                   XML
                                               JPA
                                                                           DBWS



                            CUST
                                                                                  JPA: Java Persistence API
                      ID NAME C_RATING                                            JAXB: Java Architecture for XML Binding
                                  Relational

4   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Java Persistence
           Standards: JPA 2.0, JAXB 2.2,                                   Tomorrow
            SDO 2.1.1
                                                                               JPA 2.1
           Recent
                    – JSON Binding
                                                                               JSON-B
                    – Dynamic JPA                                              Java Standard for
                    – Tenant Isolation                                         NoSQL Persistence?
                    – RESTful JPA
                    – NoSQL




5   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
EclipseLink Project

               Java SE                                                     Java EE          OSGi


                                 JPA                                       MOXy      DBWS




                                Databases                           XML Data         Legacy Systems


6   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JSON Binding




7   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JSON Binding / EclipseLink ―JSON-B‖

           Provides Java/JSON binding similar to EclipseLink JAXB‘s Java/XML
            binding.
           Marshall Java domain model to and from JSON
           Currently no Java standard—EclipseLink interprets JAXB XML
            bindings for JSON
           Content-type selectable by setting property on
            Marshaller/Unmarshaller




8   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
EclipseLink JSON-B Goals

           Offer the same flexibility as object-to-XML mappings
           Support both XML and JSON with one set of mappings
           No additional compile time dependencies over the JAXB APIs
           Be easy to use with JAX-RS (i.e., MessageBodyReader and
               MessageBodyWriter)




9   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
XML and JSON from JAXB Mappings


                                                                            XML




                      JAXB mapped Java
                                                                            JSON




10   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Challenges – Mapping JPA Entities to XML

<?xml version="1.0" ?>
<employee>
  <first>Mark</first>
  <last>Twain</last>
  <id>1</id>                                              JAXB              JPA
</employee>


                      • Bidirectional/Cyclical Relationships
                      • Composite Keys/Embedded Key Classes
                      • Byte Code Weaving




11   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Bidirectional Relationship
                      @Entity
                      public class Project{
                         ...
                         @OneToMany(mappedBy=“project")
                         private List<Employee> members;
                      }
                      @Entity
                      public class Employee{
                         ...
                         @ManyToOne
                         private Project project;
                      }




12   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Bidirectional Relationships in JAXB

            JAXB specification does not support bidirectional relationships. One
                side must be marked @XmlTransient.
            But that loses the relationship!

                                                                                 <?xml version="1.0" ?>
                                                                                 <employee>
                                                                                   <first>Mark</first>
                                              members                              <last>Twain</last>
                                                                                   <id>1</id>                                  X
                                                                                 </employee>                  Employee             Project
Employee                                                     Project

            project                                                                                                  project
                                                                            Marshall             Unmarshall

13   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
EclipseLink XmlInverseReference
                      @Entity
                      public class Project{
                        ...
                        @OneToMany(mappedBy=“project")
                        private List<Employee> members;
                      }
                      @Entity
                      public class Employee{
                        ...
                        @ManyToOne
                        @XmlInverseReference(mappedBy=“members")
                        private Project project;
                      }
14   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
EclipseLink XmlInverseReference

            EclipseLink restores relationships on unmarshall!

                                                       members                                                                 members


      Employee                                                       Project       <?xml version="1.0" ?>
                                                                                                              Employee              Project
                                                                                   <employee>
                                                                                     <first>Mark</first>
                                                                                     <last>Twain</last>
                     project                                                         <id>1</id>                      project
                                                                                   </employee>
                                                                        Marshall                        Unmarshall




15   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Demo
                                                                                JAXB/JPA Fidelity
                                                                                JSON Binding




16   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Dynamic JPA




17   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Dynamic JPA
         Post development flexibility

            JPA entities without .java or .class
                     – Entity definitions defined through eclipselink-orm.xml
                     – VIRTUAL entities and attribute access
                     – Entity classes created on the fly (ASM)
            Extensible entity types
                     – Define additional attributes to static entities
                     – Values stored in Map
                     – Full query and metamodel support




18   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Dynamic Entity
<entity class="model.Address" access="VIRTUAL">
   <attributes>
      <id name="addressId" attribute-type="int">
          <column name="ADDRESS_ID" />
      </id>
      <basic name="city" attribute-type="String” />
      <basic name="country" attribute-type="String” />
      <basic name="pCode" attribute-type="String” >
          <column name="P_CODE" />
      </basic>




19   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Extensible Entity Types

            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>
20   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Extensions Configuration
@VirtualAccessMethods
public class Player{
…
@Transient
private 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);
}

PLAYER
ID                               F_NAME                               L_NAME   FLEX_1   FLEX_2
1                                John                                 Doe      ‗R‘      ‘22‘
2                                Jane                                 Smith    ‗NONE‘


21   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
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>


22   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
RESTful JPA: JPA-RS




23   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
REST and JAX-RS

                   REST – REpresentational State Transfer
                    –         Addressable resources (URI per resource)
                    –         Small set of well-defined
                    –         Representation-oriented
                    –         Communicate statelessly
            JAX-RS (JSR 331 & in progress 339): Java API for RESTful Services
                     – Java EE framework for implementing RESTful services
                     – Provides annotations to bind combination of URI and HTTP operation to
                             Java methods.


24   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JAX-RS with JPA Example – GET Invoice


           public class InvoiceService {...




            public Invoice read(int id) {
               return null;
            }
           ...

25   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JAX-RS with JPA Example – GET Invoice

           @Stateless
           public class InvoiceService {...




            public Invoice read(int id) {
               return entityManager.find(Invoice.class, id);
            }
           ...

26   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JAX-RS with JPA Example – GET Invoice
           @Path("/invoice")
           @Stateless
           public class InvoiceService {...




            public Invoice read(int id) {
               return entityManager.find(Invoice.class, id);
            }
           ...

27   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
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);
            }
           ...

28   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
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);
            }
           ...

29   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
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);
            }
           ...        GET http://[machine]:[port]/[web-context]/invoice/4

30   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JAX-RS with JPA—High Level Architecture
     Client                                                                 Java EE Server          RDBMS




                                           HTTP/S                                            JDBC




        Offline db

31   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JAX-RS with JPA Example
                                                                                 JAX-RS

                                                            Invoice Bean        Contract Bean      Payment Bean
                                                                                                                  Accounting
                                                                                                                  Application
                                                                            Accounting Persistence Unit




                                                                                    JPA




32   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JAX-RS with JPA                                                                  GET http://.../invoice/4
                       GET http://.../invoice/4
                       mapped to bean                                            JAX-RS

                                                            Invoice Bean        Contract Bean      Payment Bean
                                                                                                                  Accounting
                                                                                                                  Application
                                   Bean                                     Accounting Persistence Unit

                                   uses JPA




                                                                                    JPA




33   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
GET http://.../jpa-rs/Accounting/Invoice/...
         JPA-RS
                                                                              JAX-RS http://.../jpa-rs/Accounting/Invoice/...
                                                                               JAX-RS
                                                                              mapped to JPA-RS service
                                                                               JPA-RS
                                                                             JPA-RS maps URI http://.../jpa-
                                                                              rs/Accounting/Invoice/...
                                  Accounting PU                               to Accounting PU and Invoice entityPU
                                                                            Contracting PU          Human Resources

                                                                                                ...



                                                                                  JPA




34   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JPA-RS Features

            Access relational data through REST with JSON or XML
            Provides REST operations for entities in persistence unit (GET, PUT,
             POST, DELETE)
            Supports invocation of named queries via HTTP
            Server Caching—EclipseLink clustered cache
            Dynamic Persistence also supported
                     – Entities defined via metadata—no Java classes required
                     – Enables persistence services for HTML 5/JavaScript applications




35   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Demo EclipseLink JPA-RS




36   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
NoSQL Java Persistence




37   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
NoSQL Databases

            NoSQL database are increasingly popular
            No common definition (document, graph, columnar)
                     – Differing feature sets
                     – Some offer query language/API—some not
            No standards
            Every database offers a unique API
                     – Cost in terms of learning
                     – Zero portability across databases



38   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
EclipseLink NoSQL

            Support JPA-style 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‖)
39   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Applicability of JPA to NoSQL

            Core JPA concepts apply to NoSQL:
                     – Persistent
                             Entities, Embeddables, ElementCollection, OneToOne, OneToMany, Many
                             ToOne, Version, etc.
            Some concepts apply with some databases:
                     – JPQL, NamedNativeQuery
            Pure relational concepts don‘t apply:
                     – CollectionTable, Column, SecondaryTable, SequenceGenerator, TableGen
                             erator, etc.


40   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Querying NoSQL with JPA

            Two kinds of queries
                     – JQPL—portable query language defined by the spec
                     – Native query—lets you leverage database specific features
                     – Dynamic or static @NamedQuery
            JPQL translated to underlying database query framework.




41   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Example MongoDB Mapped Entity




42   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
MongoDB Query Examples

            JPQL
                  Select o from Order o
                    where o.totalCost > 1000
                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();
43   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Demo EclipseLink NoSQL




44   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
―…we are gearing up for a shift to polyglot persistence - where any
          decent sized enterprise will have a variety of different data storage
          technologies for different kinds of data…we'll be first asking how
          we want to manipulate the data and only then figuring out what
          technology is the best bet for it..‖

            Martin Fowler
            ThoughtWorks




45   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Demo Polyglot Persistence




46   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Releases & Roadmap
                                 2010                                           2011                  2012                2013
                        EclipseLink 2.1                                     EclipseLink 2.3       EclipseLink 2.4      EclipseLink 2.5
                             Helios                                              Indigo                Juno                Kepler
                        • Query Extensions
                          • TREAT AS                                        • Tenant Isolation    • JSON Binding       • JPA 2.1
                          • FUNC                                              • SINGLE_TABLE      • JPA-RS             • …
                        • Batch IN and                                      • Extensible          • Tenant Isolation
                          EXISTS
                        • Attribute Group
                                                                            • External              • Tenant per
                          • Load                                              Metadata                Table/Schema
                          • Fetch                                           • Multiple DBs        • ALTER Schema
                          • Copy                                            • Data Partitioning
                          • Merge                                                                 • NoSQL
                        • eclispelink-
                          oxm.xml
                        • Dynamic MOXy




47   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Summary

            Java is evolving—and EclipseLink is evolving too!
                     – JSON Binding
                     – JAXB/JPA Fidelity
                     – Dynamic JPA
                     – JPA-RS
                     – NoSQL
                     – Polyglot Persistence
            EclipseLink is the center of innovation in Java persistence



48   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
49   Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

More Related Content

What's hot

Developer and Fusion Middleware 2 _ Scott Robertson _ SOA, portals and entepr...
Developer and Fusion Middleware 2 _ Scott Robertson _ SOA, portals and entepr...Developer and Fusion Middleware 2 _ Scott Robertson _ SOA, portals and entepr...
Developer and Fusion Middleware 2 _ Scott Robertson _ SOA, portals and entepr...InSync2011
 
Dao pattern
Dao patternDao pattern
Dao patternciriako
 
Spring 3 - An Introduction
Spring 3 - An IntroductionSpring 3 - An Introduction
Spring 3 - An IntroductionThorsten Kamann
 
Learning To Run - XPages for Lotus Notes Client Developers
Learning To Run - XPages for Lotus Notes Client DevelopersLearning To Run - XPages for Lotus Notes Client Developers
Learning To Run - XPages for Lotus Notes Client DevelopersKathy Brown
 
Adopt-a-JSR session (JSON-B/P)
Adopt-a-JSR session (JSON-B/P)Adopt-a-JSR session (JSON-B/P)
Adopt-a-JSR session (JSON-B/P)Dmitry Kornilov
 
Spring 3 - Der dritte Frühling
Spring 3 - Der dritte FrühlingSpring 3 - Der dritte Frühling
Spring 3 - Der dritte FrühlingThorsten Kamann
 
Java serverpages
Java serverpagesJava serverpages
Java serverpagesAmit Kumar
 
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFacesJavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFacesMert Çalışkan
 
Boston Computing Review - Java Server Pages
Boston Computing Review - Java Server PagesBoston Computing Review - Java Server Pages
Boston Computing Review - Java Server PagesJohn Brunswick
 
2008.07.17 발표
2008.07.17 발표2008.07.17 발표
2008.07.17 발표Sunjoo Park
 
Presenter manual RIA technology (specially for summer interns)
Presenter manual RIA technology (specially for summer interns)Presenter manual RIA technology (specially for summer interns)
Presenter manual RIA technology (specially for summer interns)XPERT INFOTECH
 

What's hot (19)

Developer and Fusion Middleware 2 _ Scott Robertson _ SOA, portals and entepr...
Developer and Fusion Middleware 2 _ Scott Robertson _ SOA, portals and entepr...Developer and Fusion Middleware 2 _ Scott Robertson _ SOA, portals and entepr...
Developer and Fusion Middleware 2 _ Scott Robertson _ SOA, portals and entepr...
 
Dao pattern
Dao patternDao pattern
Dao pattern
 
Spring 3 - An Introduction
Spring 3 - An IntroductionSpring 3 - An Introduction
Spring 3 - An Introduction
 
JSP Technology I
JSP Technology IJSP Technology I
JSP Technology I
 
JSP Technology II
JSP Technology IIJSP Technology II
JSP Technology II
 
Hibernate Advance Interview Questions
Hibernate Advance Interview QuestionsHibernate Advance Interview Questions
Hibernate Advance Interview Questions
 
Learning To Run - XPages for Lotus Notes Client Developers
Learning To Run - XPages for Lotus Notes Client DevelopersLearning To Run - XPages for Lotus Notes Client Developers
Learning To Run - XPages for Lotus Notes Client Developers
 
Adopt-a-JSR session (JSON-B/P)
Adopt-a-JSR session (JSON-B/P)Adopt-a-JSR session (JSON-B/P)
Adopt-a-JSR session (JSON-B/P)
 
4. plsql 1
4. plsql 14. plsql 1
4. plsql 1
 
Spatial approximate string search Doc
Spatial approximate string search DocSpatial approximate string search Doc
Spatial approximate string search Doc
 
Card12
Card12Card12
Card12
 
Spring 3 - Der dritte Frühling
Spring 3 - Der dritte FrühlingSpring 3 - Der dritte Frühling
Spring 3 - Der dritte Frühling
 
Jsp lecture
Jsp lectureJsp lecture
Jsp lecture
 
Java serverpages
Java serverpagesJava serverpages
Java serverpages
 
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFacesJavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
 
WEB TECHNOLOGIES JSP
WEB TECHNOLOGIES  JSPWEB TECHNOLOGIES  JSP
WEB TECHNOLOGIES JSP
 
Boston Computing Review - Java Server Pages
Boston Computing Review - Java Server PagesBoston Computing Review - Java Server Pages
Boston Computing Review - Java Server Pages
 
2008.07.17 발표
2008.07.17 발표2008.07.17 발표
2008.07.17 발표
 
Presenter manual RIA technology (specially for summer interns)
Presenter manual RIA technology (specially for summer interns)Presenter manual RIA technology (specially for summer interns)
Presenter manual RIA technology (specially for summer interns)
 

Similar to The Evolution of Java Persistence

Have You Seen Java EE Lately?
Have You Seen Java EE Lately?Have You Seen Java EE Lately?
Have You Seen Java EE Lately?Reza Rahman
 
The Java EE 7 Platform: Productivity++ & Embracing HTML5
The Java EE 7 Platform: Productivity++ & Embracing HTML5The Java EE 7 Platform: Productivity++ & Embracing HTML5
The Java EE 7 Platform: Productivity++ & Embracing HTML5Arun Gupta
 
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUGThe Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUGArun Gupta
 
GIDS 2012: Java Message Service 2.0
GIDS 2012: Java Message Service 2.0GIDS 2012: Java Message Service 2.0
GIDS 2012: Java Message Service 2.0Arun Gupta
 
GlassFish REST Administration Backend at JavaOne India 2012
GlassFish REST Administration Backend at JavaOne India 2012GlassFish REST Administration Backend at JavaOne India 2012
GlassFish REST Administration Backend at JavaOne India 2012Arun Gupta
 
GlassFish REST Administration Backend
GlassFish REST Administration BackendGlassFish REST Administration Backend
GlassFish REST Administration BackendArun Gupta
 
Spark IT 2011 - Java EE 6 Workshop
Spark IT 2011 - Java EE 6 WorkshopSpark IT 2011 - Java EE 6 Workshop
Spark IT 2011 - Java EE 6 WorkshopArun Gupta
 
Best Practices for Interoperable XML Databinding with JAXB
Best Practices for Interoperable XML Databinding with JAXBBest Practices for Interoperable XML Databinding with JAXB
Best Practices for Interoperable XML Databinding with JAXBMartin Grebac
 
Java EE7 in action
Java EE7 in actionJava EE7 in action
Java EE7 in actionAnkara JUG
 
Jfokus 2012: PaaSing a Java EE Application
Jfokus 2012: PaaSing a Java EE ApplicationJfokus 2012: PaaSing a Java EE Application
Jfokus 2012: PaaSing a Java EE ApplicationArun Gupta
 
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7Max Andersen
 
Powering the Next Generation Services with Java Platform - Spark IT 2010
Powering the Next Generation Services with Java Platform - Spark IT 2010Powering the Next Generation Services with Java Platform - Spark IT 2010
Powering the Next Generation Services with Java Platform - Spark IT 2010Arun Gupta
 
Ebs 12.2 con9021_pdf_9021_0001
Ebs 12.2 con9021_pdf_9021_0001Ebs 12.2 con9021_pdf_9021_0001
Ebs 12.2 con9021_pdf_9021_0001jucaab
 
PaaSing a Java EE 6 Application at Geecon 2012
PaaSing a Java EE 6 Application at Geecon 2012PaaSing a Java EE 6 Application at Geecon 2012
PaaSing a Java EE 6 Application at Geecon 2012Arun Gupta
 
GIDS 2012: PaaSing a Java EE Application
GIDS 2012: PaaSing a Java EE ApplicationGIDS 2012: PaaSing a Java EE Application
GIDS 2012: PaaSing a Java EE ApplicationArun Gupta
 
OSGi Persistence With EclipseLink
OSGi Persistence With EclipseLinkOSGi Persistence With EclipseLink
OSGi Persistence With EclipseLinkShaun Smith
 

Similar to The Evolution of Java Persistence (20)

Have You Seen Java EE Lately?
Have You Seen Java EE Lately?Have You Seen Java EE Lately?
Have You Seen Java EE Lately?
 
Java SE 8
Java SE 8Java SE 8
Java SE 8
 
The Java EE 7 Platform: Productivity++ & Embracing HTML5
The Java EE 7 Platform: Productivity++ & Embracing HTML5The Java EE 7 Platform: Productivity++ & Embracing HTML5
The Java EE 7 Platform: Productivity++ & Embracing HTML5
 
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUGThe Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
 
GIDS 2012: Java Message Service 2.0
GIDS 2012: Java Message Service 2.0GIDS 2012: Java Message Service 2.0
GIDS 2012: Java Message Service 2.0
 
GlassFish REST Administration Backend at JavaOne India 2012
GlassFish REST Administration Backend at JavaOne India 2012GlassFish REST Administration Backend at JavaOne India 2012
GlassFish REST Administration Backend at JavaOne India 2012
 
GlassFish REST Administration Backend
GlassFish REST Administration BackendGlassFish REST Administration Backend
GlassFish REST Administration Backend
 
Karaf ee-apachecon eu-2012
Karaf ee-apachecon eu-2012Karaf ee-apachecon eu-2012
Karaf ee-apachecon eu-2012
 
Spark IT 2011 - Java EE 6 Workshop
Spark IT 2011 - Java EE 6 WorkshopSpark IT 2011 - Java EE 6 Workshop
Spark IT 2011 - Java EE 6 Workshop
 
Best Practices for Interoperable XML Databinding with JAXB
Best Practices for Interoperable XML Databinding with JAXBBest Practices for Interoperable XML Databinding with JAXB
Best Practices for Interoperable XML Databinding with JAXB
 
Java EE7 in action
Java EE7 in actionJava EE7 in action
Java EE7 in action
 
Jfokus 2012: PaaSing a Java EE Application
Jfokus 2012: PaaSing a Java EE ApplicationJfokus 2012: PaaSing a Java EE Application
Jfokus 2012: PaaSing a Java EE Application
 
Intershop bo
Intershop boIntershop bo
Intershop bo
 
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
 
Powering the Next Generation Services with Java Platform - Spark IT 2010
Powering the Next Generation Services with Java Platform - Spark IT 2010Powering the Next Generation Services with Java Platform - Spark IT 2010
Powering the Next Generation Services with Java Platform - Spark IT 2010
 
Ebs 12.2 con9021_pdf_9021_0001
Ebs 12.2 con9021_pdf_9021_0001Ebs 12.2 con9021_pdf_9021_0001
Ebs 12.2 con9021_pdf_9021_0001
 
PaaSing a Java EE 6 Application at Geecon 2012
PaaSing a Java EE 6 Application at Geecon 2012PaaSing a Java EE 6 Application at Geecon 2012
PaaSing a Java EE 6 Application at Geecon 2012
 
GIDS 2012: PaaSing a Java EE Application
GIDS 2012: PaaSing a Java EE ApplicationGIDS 2012: PaaSing a Java EE Application
GIDS 2012: PaaSing a Java EE Application
 
OSGi Persistence With EclipseLink
OSGi Persistence With EclipseLinkOSGi Persistence With EclipseLink
OSGi Persistence With EclipseLink
 
Java ee7 1hour
Java ee7 1hourJava ee7 1hour
Java ee7 1hour
 

More from Shaun Smith

Serverless Java: JJUG CCC 2019
Serverless Java: JJUG CCC 2019Serverless Java: JJUG CCC 2019
Serverless Java: JJUG CCC 2019Shaun Smith
 
Functions and DevOps
Functions and DevOpsFunctions and DevOps
Functions and DevOpsShaun Smith
 
Democratizing Serverless
Democratizing ServerlessDemocratizing Serverless
Democratizing ServerlessShaun Smith
 
Polyglot! A Lightweight Cloud Platform for Java SE, Node, and More
Polyglot! A Lightweight Cloud Platform for Java SE, Node, and MorePolyglot! A Lightweight Cloud Platform for Java SE, Node, and More
Polyglot! A Lightweight Cloud Platform for Java SE, Node, and MoreShaun Smith
 
Lightweight Java in the Cloud
Lightweight Java in the CloudLightweight Java in the Cloud
Lightweight Java in the CloudShaun Smith
 
EclipseLink: Beyond Relational and NoSQL to Polyglot and HTML5
EclipseLink: Beyond Relational and NoSQL to Polyglot and HTML5EclipseLink: Beyond Relational and NoSQL to Polyglot and HTML5
EclipseLink: Beyond Relational and NoSQL to Polyglot and HTML5Shaun Smith
 
EclipseCon 2011-Gemini Naming
EclipseCon 2011-Gemini NamingEclipseCon 2011-Gemini Naming
EclipseCon 2011-Gemini NamingShaun Smith
 
EclipseCon 2011-Gemini Intro
EclipseCon 2011-Gemini IntroEclipseCon 2011-Gemini Intro
EclipseCon 2011-Gemini IntroShaun Smith
 
EclipseCon 2011-Gemini JPA
EclipseCon 2011-Gemini JPAEclipseCon 2011-Gemini JPA
EclipseCon 2011-Gemini JPAShaun Smith
 
RESTful Data Access Services with Java EE
RESTful Data Access Services with Java EERESTful Data Access Services with Java EE
RESTful Data Access Services with Java EEShaun Smith
 
RESTful services with JAXB and JPA
RESTful services with JAXB and JPARESTful services with JAXB and JPA
RESTful services with JAXB and JPAShaun Smith
 

More from Shaun Smith (11)

Serverless Java: JJUG CCC 2019
Serverless Java: JJUG CCC 2019Serverless Java: JJUG CCC 2019
Serverless Java: JJUG CCC 2019
 
Functions and DevOps
Functions and DevOpsFunctions and DevOps
Functions and DevOps
 
Democratizing Serverless
Democratizing ServerlessDemocratizing Serverless
Democratizing Serverless
 
Polyglot! A Lightweight Cloud Platform for Java SE, Node, and More
Polyglot! A Lightweight Cloud Platform for Java SE, Node, and MorePolyglot! A Lightweight Cloud Platform for Java SE, Node, and More
Polyglot! A Lightweight Cloud Platform for Java SE, Node, and More
 
Lightweight Java in the Cloud
Lightweight Java in the CloudLightweight Java in the Cloud
Lightweight Java in the Cloud
 
EclipseLink: Beyond Relational and NoSQL to Polyglot and HTML5
EclipseLink: Beyond Relational and NoSQL to Polyglot and HTML5EclipseLink: Beyond Relational and NoSQL to Polyglot and HTML5
EclipseLink: Beyond Relational and NoSQL to Polyglot and HTML5
 
EclipseCon 2011-Gemini Naming
EclipseCon 2011-Gemini NamingEclipseCon 2011-Gemini Naming
EclipseCon 2011-Gemini Naming
 
EclipseCon 2011-Gemini Intro
EclipseCon 2011-Gemini IntroEclipseCon 2011-Gemini Intro
EclipseCon 2011-Gemini Intro
 
EclipseCon 2011-Gemini JPA
EclipseCon 2011-Gemini JPAEclipseCon 2011-Gemini JPA
EclipseCon 2011-Gemini JPA
 
RESTful Data Access Services with Java EE
RESTful Data Access Services with Java EERESTful Data Access Services with Java EE
RESTful Data Access Services with Java EE
 
RESTful services with JAXB and JPA
RESTful services with JAXB and JPARESTful services with JAXB and JPA
RESTful services with JAXB and JPA
 

Recently uploaded

Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 

Recently uploaded (20)

Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 

The Evolution of Java Persistence

  • 1. 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 2. The Evolution of Java Persistence Shaun Smith @shaunMsmith 2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 3. 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. 3 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 4. Java Persistence: The Problem Space Customer <customer id=―…‖> <name>…</name> id: int JAXB … name: String </contact-info> creditRating: int </customer> Java XML JPA DBWS CUST JPA: Java Persistence API ID NAME C_RATING JAXB: Java Architecture for XML Binding Relational 4 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 5. Java Persistence  Standards: JPA 2.0, JAXB 2.2,  Tomorrow SDO 2.1.1  JPA 2.1  Recent – JSON Binding  JSON-B – Dynamic JPA  Java Standard for – Tenant Isolation NoSQL Persistence? – RESTful JPA – NoSQL 5 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 6. EclipseLink Project Java SE Java EE OSGi JPA MOXy DBWS Databases XML Data Legacy Systems 6 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 7. JSON Binding 7 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 8. JSON Binding / EclipseLink ―JSON-B‖  Provides Java/JSON binding similar to EclipseLink JAXB‘s Java/XML binding.  Marshall Java domain model to and from JSON  Currently no Java standard—EclipseLink interprets JAXB XML bindings for JSON  Content-type selectable by setting property on Marshaller/Unmarshaller 8 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 9. EclipseLink JSON-B Goals  Offer the same flexibility as object-to-XML mappings  Support both XML and JSON with one set of mappings  No additional compile time dependencies over the JAXB APIs  Be easy to use with JAX-RS (i.e., MessageBodyReader and MessageBodyWriter) 9 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 10. XML and JSON from JAXB Mappings XML JAXB mapped Java JSON 10 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 11. Challenges – Mapping JPA Entities to XML <?xml version="1.0" ?> <employee> <first>Mark</first> <last>Twain</last> <id>1</id> JAXB JPA </employee> • Bidirectional/Cyclical Relationships • Composite Keys/Embedded Key Classes • Byte Code Weaving 11 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 12. Bidirectional Relationship @Entity public class Project{ ... @OneToMany(mappedBy=“project") private List<Employee> members; } @Entity public class Employee{ ... @ManyToOne private Project project; } 12 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 13. Bidirectional Relationships in JAXB  JAXB specification does not support bidirectional relationships. One side must be marked @XmlTransient.  But that loses the relationship! <?xml version="1.0" ?> <employee> <first>Mark</first> members <last>Twain</last> <id>1</id> X </employee> Employee Project Employee Project project project Marshall Unmarshall 13 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 14. EclipseLink XmlInverseReference @Entity public class Project{ ... @OneToMany(mappedBy=“project") private List<Employee> members; } @Entity public class Employee{ ... @ManyToOne @XmlInverseReference(mappedBy=“members") private Project project; } 14 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 15. EclipseLink XmlInverseReference  EclipseLink restores relationships on unmarshall! members members Employee Project <?xml version="1.0" ?> Employee Project <employee> <first>Mark</first> <last>Twain</last> project <id>1</id> project </employee> Marshall Unmarshall 15 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 16. Demo JAXB/JPA Fidelity JSON Binding 16 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 17. Dynamic JPA 17 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 18. Dynamic JPA Post development flexibility  JPA entities without .java or .class – Entity definitions defined through eclipselink-orm.xml – VIRTUAL entities and attribute access – Entity classes created on the fly (ASM)  Extensible entity types – Define additional attributes to static entities – Values stored in Map – Full query and metamodel support 18 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 19. Dynamic Entity <entity class="model.Address" access="VIRTUAL"> <attributes> <id name="addressId" attribute-type="int"> <column name="ADDRESS_ID" /> </id> <basic name="city" attribute-type="String” /> <basic name="country" attribute-type="String” /> <basic name="pCode" attribute-type="String” > <column name="P_CODE" /> </basic> 19 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 20. Extensible Entity Types  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> 20 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 21. Extensions Configuration @VirtualAccessMethods public class Player{ … @Transient private 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); } PLAYER ID F_NAME L_NAME FLEX_1 FLEX_2 1 John Doe ‗R‘ ‘22‘ 2 Jane Smith ‗NONE‘ 21 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 22. 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> 22 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 23. RESTful JPA: JPA-RS 23 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 24. REST and JAX-RS  REST – REpresentational State Transfer – Addressable resources (URI per resource) – Small set of well-defined – Representation-oriented – Communicate statelessly  JAX-RS (JSR 331 & in progress 339): Java API for RESTful Services – Java EE framework for implementing RESTful services – Provides annotations to bind combination of URI and HTTP operation to Java methods. 24 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 25. JAX-RS with JPA Example – GET Invoice public class InvoiceService {... public Invoice read(int id) { return null; } ... 25 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 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 © 2012, Oracle and/or its affiliates. All rights reserved.
  • 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); } ... 27 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 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); } ... 28 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 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); } ... 29 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 30. 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); } ... GET http://[machine]:[port]/[web-context]/invoice/4 30 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 31. JAX-RS with JPA—High Level Architecture Client Java EE Server RDBMS HTTP/S JDBC Offline db 31 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 32. JAX-RS with JPA Example JAX-RS Invoice Bean Contract Bean Payment Bean Accounting Application Accounting Persistence Unit JPA 32 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 33. JAX-RS with JPA GET http://.../invoice/4 GET http://.../invoice/4 mapped to bean JAX-RS Invoice Bean Contract Bean Payment Bean Accounting Application Bean Accounting Persistence Unit uses JPA JPA 33 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 34. GET http://.../jpa-rs/Accounting/Invoice/... JPA-RS JAX-RS http://.../jpa-rs/Accounting/Invoice/... JAX-RS mapped to JPA-RS service JPA-RS JPA-RS maps URI http://.../jpa- rs/Accounting/Invoice/... Accounting PU to Accounting PU and Invoice entityPU Contracting PU Human Resources ... JPA 34 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 35. JPA-RS Features  Access relational data through REST with JSON or XML  Provides REST operations for entities in persistence unit (GET, PUT, POST, DELETE)  Supports invocation of named queries via HTTP  Server Caching—EclipseLink clustered cache  Dynamic Persistence also supported – Entities defined via metadata—no Java classes required – Enables persistence services for HTML 5/JavaScript applications 35 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 36. Demo EclipseLink JPA-RS 36 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 37. NoSQL Java Persistence 37 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 38. NoSQL Databases  NoSQL database are increasingly popular  No common definition (document, graph, columnar) – Differing feature sets – Some offer query language/API—some not  No standards  Every database offers a unique API – Cost in terms of learning – Zero portability across databases 38 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 39. EclipseLink NoSQL  Support JPA-style 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‖) 39 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 40. Applicability of JPA to NoSQL  Core JPA concepts apply to NoSQL: – Persistent Entities, Embeddables, ElementCollection, OneToOne, OneToMany, Many ToOne, Version, etc.  Some concepts apply with some databases: – JPQL, NamedNativeQuery  Pure relational concepts don‘t apply: – CollectionTable, Column, SecondaryTable, SequenceGenerator, TableGen erator, etc. 40 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 41. Querying NoSQL with JPA  Two kinds of queries – JQPL—portable query language defined by the spec – Native query—lets you leverage database specific features – Dynamic or static @NamedQuery  JPQL translated to underlying database query framework. 41 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 42. Example MongoDB Mapped Entity 42 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 43. MongoDB Query Examples  JPQL Select o from Order o where o.totalCost > 1000 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(); 43 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 44. Demo EclipseLink NoSQL 44 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 45. ―…we are gearing up for a shift to polyglot persistence - where any decent sized enterprise will have a variety of different data storage technologies for different kinds of data…we'll be first asking how we want to manipulate the data and only then figuring out what technology is the best bet for it..‖ Martin Fowler ThoughtWorks 45 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 46. Demo Polyglot Persistence 46 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 47. Releases & Roadmap 2010 2011 2012 2013 EclipseLink 2.1 EclipseLink 2.3 EclipseLink 2.4 EclipseLink 2.5 Helios Indigo Juno Kepler • Query Extensions • TREAT AS • Tenant Isolation • JSON Binding • JPA 2.1 • FUNC • SINGLE_TABLE • JPA-RS • … • Batch IN and • Extensible • Tenant Isolation EXISTS • Attribute Group • External • Tenant per • Load Metadata Table/Schema • Fetch • Multiple DBs • ALTER Schema • Copy • Data Partitioning • Merge • NoSQL • eclispelink- oxm.xml • Dynamic MOXy 47 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 48. Summary  Java is evolving—and EclipseLink is evolving too! – JSON Binding – JAXB/JPA Fidelity – Dynamic JPA – JPA-RS – NoSQL – Polyglot Persistence  EclipseLink is the center of innovation in Java persistence 48 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 49. 49 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Editor's Notes

  1. -The “mappedBy” concept used by MOXy follows the “mappedBy” concept used by JPA.
  2. -The “mappedBy” concept used by MOXy follows the “mappedBy” concept used by JPA.
  3. You have to write Beans that provide access to entities via methods that are mapped with JAX-RS to URIs.
  4. Apparent even within a singleapplicationCost of complexity has to be addressedhttp://www.nearinfinity.com/blogs/scott_leberknight/polyglot_persistence.htmlhttp://martinfowler.com/bliki/PolyglotPersistence.htmlNoSQL Distilled (Sadalage and Fowler, 2012)