SlideShare a Scribd company logo
1 of 15
www.luxoft.com
Advanced
Java Persistence API
Evgeniy Kapinos
www.luxoft.com
What is Java Persistence API ?
JPA - is the specification of the Java API for the management of
persistence and object/relational mapping
www.luxoft.com
JPA related technologies
EJB
with CMP
EJB 3.0
JPA
1.0 JPA 2.0 JPA 2.1
JDO JDO 2.0
Hibernate
Hibernate
3.2
EE
EE, SE
EE, SE
JSR-
220
JSR-
317
JSR-
338
JSR-
243
2010
2008
1997
2004
JSR-19, JSR-153
JSR-12
2001
Vendors
• Hibernate 3.5
• EclipseLink
• DataNucleus
• Batoo JPA
• Kundera
• ObjectDB
• OpenJPA
• OrientDB
• WebSphere
2007
2009 2013
Vendors
• Hibernate 4.3
• EclipseLink
• DataNucleus
Lightweightalternativeof
www.luxoft.com
How JPA specification has been created ?
 Java Community Process (JCP) established since 1998
- Java Specification Request (JSR)
 Specification: JSR 338: Java™ Persistence API, Version 2.1
 Reference implementation: EclipseLink 2.5.0
 Technology Compatibility Kit: test suite
www.luxoft.com
Architecture
Entity Manager
Factory
Entity Manager
Persistence
Context
(L1 cache)
Transaction Database
Connection and
mapping
metadata
Entity
Shared cache
(L2 cache)
www.luxoft.com
Entity
 Starting point: object/relational mapping
- Annotations or XML descriptor
- Syntax - just Google it
- Java to DDL (vise versa) generation
 Result: Java classes, database schema and
mapping meta information
www.luxoft.com
Entity Manager Factory
 Configuring “persistance.xml” parameters:
- Required: Persistent-Unit name only
- Optional: DB connection parameters, transaction type, mapping
metadata (XML, root jar, list of Classes), persistency-provider properties
 Result: Entity Manager Factory ready for persistence
Entity Manager
Factory
Connection and
mapping
metadata
www.luxoft.com
Entity Manager & Persistent Context
 Entity manager
- Used by Developer. Manages Entity live-circle (CRUD), JPQL, etc.
- Created by Entity Manager Factory
- Interacts with transactions (create / join)
- Entity keep is delegated to Persistent Context
 SQL Read on demand, but Persistent Context
 SQL Write on “flush()” call
- Session scope, not thread-safe
Entity Manager
Persistence
Context
Entity
Entity Manager
Factory
 Persistent Context
- Accessible by Entity Manager ‘s only
- L1 cache. Identity Set (search with ‘’==“)
- Produces REPETABLE_READ behavior
Transaction
www.luxoft.com
Entity Manager – create & delete operations
Search in
Persistence Context by
“==“
no equals()/hashCode()
required
www.luxoft.com
Entity Manager – read operations
REPETABLE_READ
em.find() & JPQL
www.luxoft.com
Entity Manager – update operation
Dirty check – depends on persistent-provider.
No equals()/hashCode() required.
E.g. Hibernate uses “inspection” strategy by default
www.luxoft.com
Entity Manager – transaction types
 JPA supports two transaction types
- RESOURSE_LOCAL – transactions created and controlled
by Entity Manager (Java SE & Java EE).
- JTA – transactions created and controlled by Container
(Java EE, JSR-907). Default value.
 Transaction type is defined in “percistance.xml”
- Entity Manager Factory creates Entity Managers
configured for one and only one transaction type
- Simultaneous work with two transaction types is not
supported within one Entity Manager Factory
 Partly transparent for Developer
Entity Manager
Entity Manager
Factory
Resource-local
Entity Manager
JTA
Entity Manager
www.luxoft.com
Resource-local Entity Manager
Resource-local
Entity Manager
Persistence
Context
Entity Manager
Factory
Entity
Transaction
www.luxoft.com
EJB
JTA Entity Manager (stateless EJB example)
JTA
Entity Manager
Transactional
Persistence
Context
Entity Manager
Factory
Container JTA transaction
EJB
JTA
Entity Manager
www.luxoft.com
THE END

More Related Content

What's hot

Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentation
guest11106b
 
jpa-hibernate-presentation
jpa-hibernate-presentationjpa-hibernate-presentation
jpa-hibernate-presentation
John Slick
 
Hibernate Tutorial
Hibernate TutorialHibernate Tutorial
Hibernate Tutorial
Ram132
 

What's hot (19)

Java persistence api
Java persistence api Java persistence api
Java persistence api
 
Introduction to JPA Framework
Introduction to JPA FrameworkIntroduction to JPA Framework
Introduction to JPA Framework
 
Jpa 2.1 Application Development
Jpa 2.1 Application DevelopmentJpa 2.1 Application Development
Jpa 2.1 Application Development
 
Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentation
 
Hibernate architecture
Hibernate architectureHibernate architecture
Hibernate architecture
 
jpa-hibernate-presentation
jpa-hibernate-presentationjpa-hibernate-presentation
jpa-hibernate-presentation
 
Jpa
JpaJpa
Jpa
 
Hibernate Developer Reference
Hibernate Developer ReferenceHibernate Developer Reference
Hibernate Developer Reference
 
Introduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examplesIntroduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examples
 
Hibernate
HibernateHibernate
Hibernate
 
Hibernate
HibernateHibernate
Hibernate
 
Java Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and ExampleJava Hibernate Programming with Architecture Diagram and Example
Java Hibernate Programming with Architecture Diagram and Example
 
JPA and Hibernate
JPA and HibernateJPA and Hibernate
JPA and Hibernate
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
 
Lecture 9 - Java Persistence, JPA 2
Lecture 9 - Java Persistence, JPA 2Lecture 9 - Java Persistence, JPA 2
Lecture 9 - Java Persistence, JPA 2
 
Hibernate in Action
Hibernate in ActionHibernate in Action
Hibernate in Action
 
JPA 2.1 performance tuning tips
JPA 2.1 performance tuning tipsJPA 2.1 performance tuning tips
JPA 2.1 performance tuning tips
 
hibernate with JPA
hibernate with JPAhibernate with JPA
hibernate with JPA
 
Hibernate Tutorial
Hibernate TutorialHibernate Tutorial
Hibernate Tutorial
 

Viewers also liked

ADO.NET Entity Framework
ADO.NET Entity FrameworkADO.NET Entity Framework
ADO.NET Entity Framework
Doncho Minkov
 
Seven Points for Applying Java EE 7
Seven Points for Applying Java EE 7Seven Points for Applying Java EE 7
Seven Points for Applying Java EE 7
Hirofumi Iwasaki
 

Viewers also liked (10)

ADO.NET Entity Framework
ADO.NET Entity FrameworkADO.NET Entity Framework
ADO.NET Entity Framework
 
Hibernate ve jpa
Hibernate ve jpaHibernate ve jpa
Hibernate ve jpa
 
ICT and travel avoidance
ICT and travel avoidanceICT and travel avoidance
ICT and travel avoidance
 
Hibernate ve jpa
Hibernate ve jpaHibernate ve jpa
Hibernate ve jpa
 
EJB 3.2/JPA 2.1 Best Practices with Real-Life Examples - CON7535
EJB 3.2/JPA 2.1 Best Practices with Real-Life Examples - CON7535EJB 3.2/JPA 2.1 Best Practices with Real-Life Examples - CON7535
EJB 3.2/JPA 2.1 Best Practices with Real-Life Examples - CON7535
 
Batoo jpa
Batoo jpaBatoo jpa
Batoo jpa
 
Optimierung von JPA-­Anwendungen
Optimierung von JPA-­AnwendungenOptimierung von JPA-­Anwendungen
Optimierung von JPA-­Anwendungen
 
[Java eeconf 2016] spring jta principles of work with transactions. Dmytro S...
[Java eeconf 2016] spring jta  principles of work with transactions. Dmytro S...[Java eeconf 2016] spring jta  principles of work with transactions. Dmytro S...
[Java eeconf 2016] spring jta principles of work with transactions. Dmytro S...
 
JPA - Java Persistence API
JPA - Java Persistence APIJPA - Java Persistence API
JPA - Java Persistence API
 
Seven Points for Applying Java EE 7
Seven Points for Applying Java EE 7Seven Points for Applying Java EE 7
Seven Points for Applying Java EE 7
 

Similar to Евгений Капинос "Advanced JPA (Java Persistent API)"

Enterprise Java Web Application Frameworks Sample Stack Implementation
Enterprise Java Web Application Frameworks   Sample Stack ImplementationEnterprise Java Web Application Frameworks   Sample Stack Implementation
Enterprise Java Web Application Frameworks Sample Stack Implementation
Mert Çalışkan
 
5050 dev nation
5050 dev nation5050 dev nation
5050 dev nation
Arun Gupta
 
Contextual Dependency Injection for Apachecon 2010
Contextual Dependency Injection for Apachecon 2010Contextual Dependency Injection for Apachecon 2010
Contextual Dependency Injection for Apachecon 2010
Rohit Kelapure
 

Similar to Евгений Капинос "Advanced JPA (Java Persistent API)" (20)

50 New Features of Java EE 7 in 50 minutes
50 New Features of Java EE 7 in 50 minutes50 New Features of Java EE 7 in 50 minutes
50 New Features of Java EE 7 in 50 minutes
 
Java EE 6 workshop at Dallas Tech Fest 2011
Java EE 6 workshop at Dallas Tech Fest 2011Java EE 6 workshop at Dallas Tech Fest 2011
Java EE 6 workshop at Dallas Tech Fest 2011
 
Enterprise Java Web Application Frameworks Sample Stack Implementation
Enterprise Java Web Application Frameworks   Sample Stack ImplementationEnterprise Java Web Application Frameworks   Sample Stack Implementation
Enterprise Java Web Application Frameworks Sample Stack Implementation
 
5050 dev nation
5050 dev nation5050 dev nation
5050 dev nation
 
The Java EE 7 Platform: Productivity & HTML5 at San Francisco JUG
The Java EE 7 Platform: Productivity & HTML5 at San Francisco JUGThe Java EE 7 Platform: Productivity & HTML5 at San Francisco JUG
The Java EE 7 Platform: Productivity & HTML5 at San Francisco JUG
 
JavaOne 2014 Java EE 8 Booth Slides
JavaOne 2014 Java EE 8 Booth SlidesJavaOne 2014 Java EE 8 Booth Slides
JavaOne 2014 Java EE 8 Booth Slides
 
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
Java EE 6 & GlassFish = Less Code + More Power at CEJUGJava EE 6 & GlassFish = Less Code + More Power at CEJUG
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
 
50 features of Java EE 7 in 50 minutes at JavaZone 2014
50 features of Java EE 7 in 50 minutes at JavaZone 201450 features of Java EE 7 in 50 minutes at JavaZone 2014
50 features of Java EE 7 in 50 minutes at JavaZone 2014
 
Advance java session 5
Advance java session 5Advance java session 5
Advance java session 5
 
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnitionJava EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnition
 
Java EE 6 = Less Code + More Power
Java EE 6 = Less Code + More PowerJava EE 6 = Less Code + More Power
Java EE 6 = Less Code + More Power
 
50 New Features of Java EE 7 in 50 minutes @ Devoxx France 2014
50 New Features of Java EE 7 in 50 minutes @ Devoxx France 201450 New Features of Java EE 7 in 50 minutes @ Devoxx France 2014
50 New Features of Java EE 7 in 50 minutes @ Devoxx France 2014
 
Contextual Dependency Injection for Apachecon 2010
Contextual Dependency Injection for Apachecon 2010Contextual Dependency Injection for Apachecon 2010
Contextual Dependency Injection for Apachecon 2010
 
Configuring jpa in a Spring application
Configuring jpa in a  Spring applicationConfiguring jpa in a  Spring application
Configuring jpa in a Spring application
 
Java EE7 Demystified
Java EE7 DemystifiedJava EE7 Demystified
Java EE7 Demystified
 
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
 
Javaee6 Overview
Javaee6 OverviewJavaee6 Overview
Javaee6 Overview
 
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3 Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
 
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...
 
Overview of Java EE 6 by Roberto Chinnici at SFJUG
Overview of Java EE 6 by Roberto Chinnici at SFJUGOverview of Java EE 6 by Roberto Chinnici at SFJUG
Overview of Java EE 6 by Roberto Chinnici at SFJUG
 

More from Anna Shymchenko

More from Anna Shymchenko (20)

Константин Маркович: "Creating modular application using Spring Boot "
Константин Маркович: "Creating modular application using Spring Boot "Константин Маркович: "Creating modular application using Spring Boot "
Константин Маркович: "Creating modular application using Spring Boot "
 
Евгений Бова: "Modularity in Java: introduction to Jigsaw through the prism o...
Евгений Бова: "Modularity in Java: introduction to Jigsaw through the prism o...Евгений Бова: "Modularity in Java: introduction to Jigsaw through the prism o...
Евгений Бова: "Modularity in Java: introduction to Jigsaw through the prism o...
 
Евгений Руднев: "Programmers Approach to Error Handling"
Евгений Руднев: "Programmers Approach to Error Handling"Евгений Руднев: "Programmers Approach to Error Handling"
Евгений Руднев: "Programmers Approach to Error Handling"
 
Александр Куцан: "Static Code Analysis in C++"
Александр Куцан: "Static Code Analysis in C++" Александр Куцан: "Static Code Analysis in C++"
Александр Куцан: "Static Code Analysis in C++"
 
Алесей Решта: “Robotics Sport & Luxoft Open Robotics Club”
Алесей Решта: “Robotics Sport & Luxoft Open Robotics Club” Алесей Решта: “Robotics Sport & Luxoft Open Robotics Club”
Алесей Решта: “Robotics Sport & Luxoft Open Robotics Club”
 
Орхан Гасимов: "Reactive Applications in Java with Akka"
Орхан Гасимов: "Reactive Applications in Java with Akka"Орхан Гасимов: "Reactive Applications in Java with Akka"
Орхан Гасимов: "Reactive Applications in Java with Akka"
 
Евгений Хыст: "Server-Side Geo-Clustering Based on Geohash"
Евгений Хыст: "Server-Side Geo-Clustering Based on Geohash"Евгений Хыст: "Server-Side Geo-Clustering Based on Geohash"
Евгений Хыст: "Server-Side Geo-Clustering Based on Geohash"
 
Денис Прокопюк: “JMX in Java EE applications”
Денис Прокопюк: “JMX in Java EE applications”Денис Прокопюк: “JMX in Java EE applications”
Денис Прокопюк: “JMX in Java EE applications”
 
Роман Яворский "Introduction to DevOps"
Роман Яворский "Introduction to DevOps"Роман Яворский "Introduction to DevOps"
Роман Яворский "Introduction to DevOps"
 
Максим Сабарня “NoSQL: Not only SQL in developer’s life”
Максим Сабарня “NoSQL: Not only SQL in developer’s life” Максим Сабарня “NoSQL: Not only SQL in developer’s life”
Максим Сабарня “NoSQL: Not only SQL in developer’s life”
 
Андрей Лисниченко "SQL Injection"
Андрей Лисниченко "SQL Injection"Андрей Лисниченко "SQL Injection"
Андрей Лисниченко "SQL Injection"
 
Светлана Мухина "Metrics on agile projects"
Светлана Мухина "Metrics on agile projects"Светлана Мухина "Metrics on agile projects"
Светлана Мухина "Metrics on agile projects"
 
Андрей Слободяник "Test driven development using mockito"
Андрей Слободяник "Test driven development using mockito"Андрей Слободяник "Test driven development using mockito"
Андрей Слободяник "Test driven development using mockito"
 
Евгений Хыст "Application performance database related problems"
Евгений Хыст "Application performance database related problems"Евгений Хыст "Application performance database related problems"
Евгений Хыст "Application performance database related problems"
 
Даурен Муса “IBM WebSphere - expensive but effective”
Даурен Муса “IBM WebSphere - expensive but effective” Даурен Муса “IBM WebSphere - expensive but effective”
Даурен Муса “IBM WebSphere - expensive but effective”
 
Event-driven architecture with Java technology stack
Event-driven architecture with Java technology stackEvent-driven architecture with Java technology stack
Event-driven architecture with Java technology stack
 
Do we need SOLID principles during software development?
Do we need SOLID principles during software development?Do we need SOLID principles during software development?
Do we need SOLID principles during software development?
 
Guava - Elements of Functional Programming
Guava - Elements of Functional Programming Guava - Elements of Functional Programming
Guava - Elements of Functional Programming
 
Максим Сабарня и Иван Дрижирук “Vert.x – tool-kit for building reactive app...
 	Максим Сабарня и Иван Дрижирук “Vert.x – tool-kit for building reactive app... 	Максим Сабарня и Иван Дрижирук “Vert.x – tool-kit for building reactive app...
Максим Сабарня и Иван Дрижирук “Vert.x – tool-kit for building reactive app...
 
Сергей Гончарук "Working with uncertainty"
 	Сергей Гончарук "Working with uncertainty"  	Сергей Гончарук "Working with uncertainty"
Сергей Гончарук "Working with uncertainty"
 

Recently uploaded

Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 

Recently uploaded (20)

Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
WSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - Kanchana
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
 
WSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AIWSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AI
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 

Евгений Капинос "Advanced JPA (Java Persistent API)"

  • 2. www.luxoft.com What is Java Persistence API ? JPA - is the specification of the Java API for the management of persistence and object/relational mapping
  • 3. www.luxoft.com JPA related technologies EJB with CMP EJB 3.0 JPA 1.0 JPA 2.0 JPA 2.1 JDO JDO 2.0 Hibernate Hibernate 3.2 EE EE, SE EE, SE JSR- 220 JSR- 317 JSR- 338 JSR- 243 2010 2008 1997 2004 JSR-19, JSR-153 JSR-12 2001 Vendors • Hibernate 3.5 • EclipseLink • DataNucleus • Batoo JPA • Kundera • ObjectDB • OpenJPA • OrientDB • WebSphere 2007 2009 2013 Vendors • Hibernate 4.3 • EclipseLink • DataNucleus Lightweightalternativeof
  • 4. www.luxoft.com How JPA specification has been created ?  Java Community Process (JCP) established since 1998 - Java Specification Request (JSR)  Specification: JSR 338: Java™ Persistence API, Version 2.1  Reference implementation: EclipseLink 2.5.0  Technology Compatibility Kit: test suite
  • 5. www.luxoft.com Architecture Entity Manager Factory Entity Manager Persistence Context (L1 cache) Transaction Database Connection and mapping metadata Entity Shared cache (L2 cache)
  • 6. www.luxoft.com Entity  Starting point: object/relational mapping - Annotations or XML descriptor - Syntax - just Google it - Java to DDL (vise versa) generation  Result: Java classes, database schema and mapping meta information
  • 7. www.luxoft.com Entity Manager Factory  Configuring “persistance.xml” parameters: - Required: Persistent-Unit name only - Optional: DB connection parameters, transaction type, mapping metadata (XML, root jar, list of Classes), persistency-provider properties  Result: Entity Manager Factory ready for persistence Entity Manager Factory Connection and mapping metadata
  • 8. www.luxoft.com Entity Manager & Persistent Context  Entity manager - Used by Developer. Manages Entity live-circle (CRUD), JPQL, etc. - Created by Entity Manager Factory - Interacts with transactions (create / join) - Entity keep is delegated to Persistent Context  SQL Read on demand, but Persistent Context  SQL Write on “flush()” call - Session scope, not thread-safe Entity Manager Persistence Context Entity Entity Manager Factory  Persistent Context - Accessible by Entity Manager ‘s only - L1 cache. Identity Set (search with ‘’==“) - Produces REPETABLE_READ behavior Transaction
  • 9. www.luxoft.com Entity Manager – create & delete operations Search in Persistence Context by “==“ no equals()/hashCode() required
  • 10. www.luxoft.com Entity Manager – read operations REPETABLE_READ em.find() & JPQL
  • 11. www.luxoft.com Entity Manager – update operation Dirty check – depends on persistent-provider. No equals()/hashCode() required. E.g. Hibernate uses “inspection” strategy by default
  • 12. www.luxoft.com Entity Manager – transaction types  JPA supports two transaction types - RESOURSE_LOCAL – transactions created and controlled by Entity Manager (Java SE & Java EE). - JTA – transactions created and controlled by Container (Java EE, JSR-907). Default value.  Transaction type is defined in “percistance.xml” - Entity Manager Factory creates Entity Managers configured for one and only one transaction type - Simultaneous work with two transaction types is not supported within one Entity Manager Factory  Partly transparent for Developer Entity Manager Entity Manager Factory Resource-local Entity Manager JTA Entity Manager
  • 13. www.luxoft.com Resource-local Entity Manager Resource-local Entity Manager Persistence Context Entity Manager Factory Entity Transaction
  • 14. www.luxoft.com EJB JTA Entity Manager (stateless EJB example) JTA Entity Manager Transactional Persistence Context Entity Manager Factory Container JTA transaction EJB JTA Entity Manager