SlideShare ist ein Scribd-Unternehmen logo
1 von 19
„JPA 2.0“
New Features of JSR 317
JSR 317: Java Persistence API
• Specification Lead:
  Linda DeMichiel, Sun Microsystems, Inc.
• Expert Group:
  Adobe Systems Inc., akquinet tech@spree, BEA Systems, Adam Bien,
  DataDirect Technologies, Ericsson AB, Antonio Goncalves, IBM, Chris Maki,
  Oracle, OW2, Pramati Technologies, RedHat, SAP AG Sun Microsystems
  Inc., Sybase, TmaxSoft Inc., VMWare
• Referenzimplemention:
  EclipseLink 2.x, www.eclipse.org/eclipselink




                                                                              1
Goals
• Expanded O/R mappings
• Improved domain modeling capabilities
• Additions to the Java Persistence query language
• An API for criteria queries
• Standardization of configuration hints
• Additional contracts for detached entities and extended persistence
  contexts
• Support for validation via integration with the work of JSR 303




                                                                        2
@OneToMany / @ManyToOne
 @OneToMany
 @JoinColumn(name = "ID")
 private List<Editor> editors;




markus@eisele.net                3
@ElementCollection

 @ElementCollection
 private Set<String> websites = new HashSet();




markus@eisele.net                                4
@OrderColumn

 @OrderColumn(name="ED_ORDER")
 private List<Editor> editors;




markus@eisele.net                5
@MapKeyJoinColumn
 @JoinTable(name="ADRESSESS",
          joinColumns=
          @JoinColumn(name="AUTORID"),
          inverseJoinColumns=@JoinColumn(name="CONTACTID"))
 @MapKeyJoinColumn(name="ADRESSID")
 Map<Adress, Contactdetails> allAdressess;




markus@eisele.net                                             6
@Embeddable
 @Embedded
 PhoneNumber number;

 @ManyToOne
 PhoneServiceProvider provider;




markus@eisele.net                 7
@Access
@Entity @Access(FIELD)
public class PhoneNumber {
...
@Transient String localnumber;

@Access(PROPERTY)
protected double getInternationalNumber(Locale locale) {
return convertToIntNumber(localnumber);
}
...
}




                                                           8
Combined Primary Keys
 @Entity
 @IdClass(ArticlePK.class)
 public class Article {

 @Id Long id;
 @Id @ManyToOne Magazine magazine;
 @Id @ManyToOne Author author;
 }

 public class ArticlePK {
        Long id;
        Long magazine;
        Long author;
 }




markus@eisele.net                    9
Criteria API I
 // create / inject EntityManager
 EntityManager em = ...;

 // build Criteria Query
 CriteriaBuilder qb = em.getCriteriaBuilder();
 CriteriaQuery cq = qb.createQuery();
 Root<Author> autor = cq.from(Author.class);
 cq.select(author);

 // execute Criteria Query
 Query query = em.createQuery(cq);
 List result = query.getResultList();




markus@eisele.net                                10
Criteria API II
Root autor = cq.from(Author.class);
cq.where(qb.equal(author.get("name"), name));
cq.select(autor);




markus@eisele.net                               11
Metamodel API
@Entity public class Customer {
  @Id int custId;
  String name;
  ...
  @OneToMany(mappedBy="customer") Set<Order> orders;
  ...
}



import javax.persistence.metamodel.*;
@TypesafeMetamodel
public class Customer_ {
    public static volatile Attribute<Customer, Integer> custId;
    public static volatile Attribute<Customer, String> name;
    public static volatile Set<Customer, Order> orders;
    ...
}




                                                                  12
Metamodel API + Criteria API

cq.where(qb.equal(autor.get(Autor_.name), "name"));




markus@eisele.net                                     13
Bean Validation (JSR-303)
@Entity
public class Autor implements Serializable {
[…]
@NotNull
@Size(max=30)
private String name;
[…]
}


 •@NotNull
 •@Size.max
 •@Digits
 •@Min / @Max
 •@Future / @Past
 •@Size


markus@eisele.net                              14
LockModeTypes
.READ => LockModeType.OPTIMISTIC
.WRITE => LockModeType.OPTIMISTIC_FORCE_INCREMENT

NEW!:
LockModeType.PESSIMISTIC_READ (Repeatable Read)
LockModeType.PESSIMISTIC_WRITE (Serialized)
LockModeType.PESSIMISTIC_FORCE_INCREMENT




 markus@eisele.net                                  15
JPQL Enhancements
•   Timestamp
•   Non-polymorphic Queries
•   Collection Paramters in IN Expression
•   Ordered List Index
•   CASE Statement




                                            16
Second Level Cache

public interface Cache {
boolean contains(Class clz, Object primaryKey);
void evict(Class clz, Object primaryKey);
void evict(Class clz);
void evictAll();
}




 markus@eisele.net                                17
Links und Informationen
•   http://blog.eisele.net/
•   http://blogs.sun.com/ldemichiel/
•   http://www.jcp.org/en/jsr/detail?id=317
•   http://www.eclipse.org/eclipselink




markus@eisele.net                             18

Weitere ähnliche Inhalte

Was ist angesagt?

Creating data with the test data builder pattern
Creating data with the test data builder patternCreating data with the test data builder pattern
Creating data with the test data builder pattern
Alan Parkinson
 
Spring 3: What's New
Spring 3: What's NewSpring 3: What's New
Spring 3: What's New
Ted Pennings
 
Hibernate complete Training
Hibernate complete TrainingHibernate complete Training
Hibernate complete Training
sourabh aggarwal
 
Codebits 2012 - Fast relational web site construction.
Codebits 2012 - Fast relational web site construction.Codebits 2012 - Fast relational web site construction.
Codebits 2012 - Fast relational web site construction.
Nelson Gomes
 

Was ist angesagt? (19)

Creating data with the test data builder pattern
Creating data with the test data builder patternCreating data with the test data builder pattern
Creating data with the test data builder pattern
 
Inversion of Control and Dependency Injection
Inversion of Control and Dependency InjectionInversion of Control and Dependency Injection
Inversion of Control and Dependency Injection
 
Dependency Injection Inversion Of Control And Unity
Dependency Injection Inversion Of Control And UnityDependency Injection Inversion Of Control And Unity
Dependency Injection Inversion Of Control And Unity
 
iOS State Preservation and Restoration
iOS State Preservation and RestorationiOS State Preservation and Restoration
iOS State Preservation and Restoration
 
Drupal 7 Entity & Entity API
Drupal 7 Entity & Entity APIDrupal 7 Entity & Entity API
Drupal 7 Entity & Entity API
 
AJAX
AJAXAJAX
AJAX
 
Consume Spring Data Rest with Angularjs
Consume Spring Data Rest with AngularjsConsume Spring Data Rest with Angularjs
Consume Spring Data Rest with Angularjs
 
Using MongoDB with the .Net Framework
Using MongoDB with the .Net FrameworkUsing MongoDB with the .Net Framework
Using MongoDB with the .Net Framework
 
Spring 3: What's New
Spring 3: What's NewSpring 3: What's New
Spring 3: What's New
 
Cassandra rapid prototyping with achilles
Cassandra rapid prototyping with achillesCassandra rapid prototyping with achilles
Cassandra rapid prototyping with achilles
 
Entity framework 6
Entity framework 6Entity framework 6
Entity framework 6
 
Hibernate complete Training
Hibernate complete TrainingHibernate complete Training
Hibernate complete Training
 
Intro to IndexedDB (Beta)
Intro to IndexedDB (Beta)Intro to IndexedDB (Beta)
Intro to IndexedDB (Beta)
 
Vaadin JPAContainer
Vaadin JPAContainerVaadin JPAContainer
Vaadin JPAContainer
 
Entity Persistence with JPA
Entity Persistence with JPAEntity Persistence with JPA
Entity Persistence with JPA
 
JPA Best Practices
JPA Best PracticesJPA Best Practices
JPA Best Practices
 
Java persistence api 2.1
Java persistence api 2.1Java persistence api 2.1
Java persistence api 2.1
 
Codebits 2012 - Fast relational web site construction.
Codebits 2012 - Fast relational web site construction.Codebits 2012 - Fast relational web site construction.
Codebits 2012 - Fast relational web site construction.
 
C#
C#C#
C#
 

Andere mochten auch

Shero Company profile,2016
Shero Company profile,2016Shero Company profile,2016
Shero Company profile,2016
?? ?
 
iNut Limited Leather Beani Tablet Range
iNut Limited Leather Beani Tablet RangeiNut Limited Leather Beani Tablet Range
iNut Limited Leather Beani Tablet Range
inutltd
 
осъдителна присъда кюстендилски окръжен съд
осъдителна присъда  кюстендилски окръжен съдосъдителна присъда  кюстендилски окръжен съд
осъдителна присъда кюстендилски окръжен съд
Kristiyan Petroff
 
Zhao_Work samples
Zhao_Work samplesZhao_Work samples
Zhao_Work samples
Yajing Zhao
 

Andere mochten auch (20)

Jpa
JpaJpa
Jpa
 
Hibernate - JPA @luce 5
Hibernate - JPA @luce 5Hibernate - JPA @luce 5
Hibernate - JPA @luce 5
 
Jpa
JpaJpa
Jpa
 
Introducción práctica a JPA2
Introducción práctica a JPA2Introducción práctica a JPA2
Introducción práctica a JPA2
 
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
 
Pdf Pai
Pdf PaiPdf Pai
Pdf Pai
 
Quantum Entanglement - Cryptography and Communication
Quantum Entanglement - Cryptography and CommunicationQuantum Entanglement - Cryptography and Communication
Quantum Entanglement - Cryptography and Communication
 
The silent way
The silent wayThe silent way
The silent way
 
Shero Company profile,2016
Shero Company profile,2016Shero Company profile,2016
Shero Company profile,2016
 
BSidesNYC 2016 - An Adversarial View of SaaS Malware Sandboxes
BSidesNYC 2016 - An Adversarial View of SaaS Malware SandboxesBSidesNYC 2016 - An Adversarial View of SaaS Malware Sandboxes
BSidesNYC 2016 - An Adversarial View of SaaS Malware Sandboxes
 
2016.10.28 Transistor 2 - engelsk tekst - sven age eriksen v.05 - Sven Åge ...
2016.10.28   Transistor 2 - engelsk tekst - sven age eriksen v.05 - Sven Åge ...2016.10.28   Transistor 2 - engelsk tekst - sven age eriksen v.05 - Sven Åge ...
2016.10.28 Transistor 2 - engelsk tekst - sven age eriksen v.05 - Sven Åge ...
 
FOOD ANYWHERE IS FOOD EVERYWHERE
FOOD ANYWHERE IS FOOD EVERYWHEREFOOD ANYWHERE IS FOOD EVERYWHERE
FOOD ANYWHERE IS FOOD EVERYWHERE
 
iNut Limited Leather Beani Tablet Range
iNut Limited Leather Beani Tablet RangeiNut Limited Leather Beani Tablet Range
iNut Limited Leather Beani Tablet Range
 
осъдителна присъда кюстендилски окръжен съд
осъдителна присъда  кюстендилски окръжен съдосъдителна присъда  кюстендилски окръжен съд
осъдителна присъда кюстендилски окръжен съд
 
Strategic Management Ch05
Strategic Management Ch05Strategic Management Ch05
Strategic Management Ch05
 
Building A Social Network Waa 1 17 07 V2 Draft
Building A Social Network   Waa   1 17 07 V2 DraftBuilding A Social Network   Waa   1 17 07 V2 Draft
Building A Social Network Waa 1 17 07 V2 Draft
 
Zhao_Work samples
Zhao_Work samplesZhao_Work samples
Zhao_Work samples
 
Step Up 1 and 2 ppt
Step Up 1 and 2 pptStep Up 1 and 2 ppt
Step Up 1 and 2 ppt
 
Zenoss Monitroing – zendmd Scripting Guide
Zenoss Monitroing – zendmd Scripting GuideZenoss Monitroing – zendmd Scripting Guide
Zenoss Monitroing – zendmd Scripting Guide
 
dfasdfsdf
dfasdfsdfdfasdfsdf
dfasdfsdf
 

Ähnlich wie New Features of JSR 317 (JPA 2.0)

Easy data-with-spring-data-jpa
Easy data-with-spring-data-jpaEasy data-with-spring-data-jpa
Easy data-with-spring-data-jpa
Staples
 
Smoothing Your Java with DSLs
Smoothing Your Java with DSLsSmoothing Your Java with DSLs
Smoothing Your Java with DSLs
intelliyole
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
Fabio Franzini
 
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
lennartkats
 

Ähnlich wie New Features of JSR 317 (JPA 2.0) (20)

Easy data-with-spring-data-jpa
Easy data-with-spring-data-jpaEasy data-with-spring-data-jpa
Easy data-with-spring-data-jpa
 
Requery overview
Requery overviewRequery overview
Requery overview
 
S313431 JPA 2.0 Overview
S313431 JPA 2.0 OverviewS313431 JPA 2.0 Overview
S313431 JPA 2.0 Overview
 
Using the latest Java Persistence API 2 Features - Tech Days 2010 India
Using the latest Java Persistence API 2 Features - Tech Days 2010 IndiaUsing the latest Java Persistence API 2 Features - Tech Days 2010 India
Using the latest Java Persistence API 2 Features - Tech Days 2010 India
 
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
 
NoSQL Endgame DevoxxUA Conference 2020
NoSQL Endgame DevoxxUA Conference 2020NoSQL Endgame DevoxxUA Conference 2020
NoSQL Endgame DevoxxUA Conference 2020
 
Smoothing Your Java with DSLs
Smoothing Your Java with DSLsSmoothing Your Java with DSLs
Smoothing Your Java with DSLs
 
Context and Dependency Injection
Context and Dependency InjectionContext and Dependency Injection
Context and Dependency Injection
 
Crafting Evolvable Api Responses
Crafting Evolvable Api ResponsesCrafting Evolvable Api Responses
Crafting Evolvable Api Responses
 
CDI @javaonehyderabad
CDI @javaonehyderabadCDI @javaonehyderabad
CDI @javaonehyderabad
 
Suportando Aplicações Multi-tenancy com Java EE
Suportando Aplicações Multi-tenancy com Java EESuportando Aplicações Multi-tenancy com Java EE
Suportando Aplicações Multi-tenancy com Java EE
 
Code decoupling from Symfony (and others frameworks) - PHP Conference Brasil ...
Code decoupling from Symfony (and others frameworks) - PHP Conference Brasil ...Code decoupling from Symfony (and others frameworks) - PHP Conference Brasil ...
Code decoupling from Symfony (and others frameworks) - PHP Conference Brasil ...
 
Green dao
Green daoGreen dao
Green dao
 
NoSQL Endgame Percona Live Online 2020
NoSQL Endgame Percona Live Online 2020NoSQL Endgame Percona Live Online 2020
NoSQL Endgame Percona Live Online 2020
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Mongoose and MongoDB 101
Mongoose and MongoDB 101Mongoose and MongoDB 101
Mongoose and MongoDB 101
 
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
 
A Cocktail of Guice and Seam, the missing ingredients for Java EE 6
A Cocktail of Guice and Seam, the missing ingredients for Java EE 6A Cocktail of Guice and Seam, the missing ingredients for Java EE 6
A Cocktail of Guice and Seam, the missing ingredients for Java EE 6
 
Scalable web application architecture
Scalable web application architectureScalable web application architecture
Scalable web application architecture
 
Webinar: Developing with the modern App Stack: MEAN and MERN (with Angular2 a...
Webinar: Developing with the modern App Stack: MEAN and MERN (with Angular2 a...Webinar: Developing with the modern App Stack: MEAN and MERN (with Angular2 a...
Webinar: Developing with the modern App Stack: MEAN and MERN (with Angular2 a...
 

Mehr von Markus Eisele

Stay productive while slicing up the monolith
Stay productive while slicing up the monolith Stay productive while slicing up the monolith
Stay productive while slicing up the monolith
Markus Eisele
 
Nine Neins - where Java EE will never take you
Nine Neins - where Java EE will never take youNine Neins - where Java EE will never take you
Nine Neins - where Java EE will never take you
Markus Eisele
 

Mehr von Markus Eisele (20)

Sustainable Software Architecture - Open Tour DACH '22
Sustainable Software Architecture - Open Tour DACH '22Sustainable Software Architecture - Open Tour DACH '22
Sustainable Software Architecture - Open Tour DACH '22
 
Going from java message service (jms) to eda
Going from java message service (jms) to eda Going from java message service (jms) to eda
Going from java message service (jms) to eda
 
Let's be real. Quarkus in the wild.
Let's be real. Quarkus in the wild.Let's be real. Quarkus in the wild.
Let's be real. Quarkus in the wild.
 
What happens when unicorns drink coffee
What happens when unicorns drink coffeeWhat happens when unicorns drink coffee
What happens when unicorns drink coffee
 
Stateful on Stateless - The Future of Applications in the Cloud
Stateful on Stateless - The Future of Applications in the CloudStateful on Stateless - The Future of Applications in the Cloud
Stateful on Stateless - The Future of Applications in the Cloud
 
Java in the age of containers - JUG Frankfurt/M
Java in the age of containers - JUG Frankfurt/MJava in the age of containers - JUG Frankfurt/M
Java in the age of containers - JUG Frankfurt/M
 
Java in the Age of Containers and Serverless
Java in the Age of Containers and ServerlessJava in the Age of Containers and Serverless
Java in the Age of Containers and Serverless
 
Migrating from Java EE to cloud-native Reactive systems
Migrating from Java EE to cloud-native Reactive systemsMigrating from Java EE to cloud-native Reactive systems
Migrating from Java EE to cloud-native Reactive systems
 
Streaming to a new Jakarta EE / JOTB19
Streaming to a new Jakarta EE / JOTB19Streaming to a new Jakarta EE / JOTB19
Streaming to a new Jakarta EE / JOTB19
 
Cloud wars - A LavaOne discussion in seven slides
Cloud wars - A LavaOne discussion in seven slidesCloud wars - A LavaOne discussion in seven slides
Cloud wars - A LavaOne discussion in seven slides
 
Streaming to a new Jakarta EE
Streaming to a new Jakarta EEStreaming to a new Jakarta EE
Streaming to a new Jakarta EE
 
Reactive Integrations - Caveats and bumps in the road explained
Reactive Integrations - Caveats and bumps in the road explained  Reactive Integrations - Caveats and bumps in the road explained
Reactive Integrations - Caveats and bumps in the road explained
 
Stay productive while slicing up the monolith
Stay productive while slicing up the monolithStay productive while slicing up the monolith
Stay productive while slicing up the monolith
 
Stay productive while slicing up the monolith
Stay productive while slicing up the monolithStay productive while slicing up the monolith
Stay productive while slicing up the monolith
 
Stay productive_while_slicing_up_the_monolith
Stay productive_while_slicing_up_the_monolithStay productive_while_slicing_up_the_monolith
Stay productive_while_slicing_up_the_monolith
 
Architecting for failure - Why are distributed systems hard?
Architecting for failure - Why are distributed systems hard?Architecting for failure - Why are distributed systems hard?
Architecting for failure - Why are distributed systems hard?
 
Stay productive while slicing up the monolith
Stay productive while slicing up the monolith Stay productive while slicing up the monolith
Stay productive while slicing up the monolith
 
Nine Neins - where Java EE will never take you
Nine Neins - where Java EE will never take youNine Neins - where Java EE will never take you
Nine Neins - where Java EE will never take you
 
How lagom helps to build real world microservice systems
How lagom helps to build real world microservice systemsHow lagom helps to build real world microservice systems
How lagom helps to build real world microservice systems
 
CQRS and Event Sourcing for Java Developers
CQRS and Event Sourcing for Java DevelopersCQRS and Event Sourcing for Java Developers
CQRS and Event Sourcing for Java Developers
 

Kürzlich hochgeladen

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

New Features of JSR 317 (JPA 2.0)

  • 2. JSR 317: Java Persistence API • Specification Lead: Linda DeMichiel, Sun Microsystems, Inc. • Expert Group: Adobe Systems Inc., akquinet tech@spree, BEA Systems, Adam Bien, DataDirect Technologies, Ericsson AB, Antonio Goncalves, IBM, Chris Maki, Oracle, OW2, Pramati Technologies, RedHat, SAP AG Sun Microsystems Inc., Sybase, TmaxSoft Inc., VMWare • Referenzimplemention: EclipseLink 2.x, www.eclipse.org/eclipselink 1
  • 3. Goals • Expanded O/R mappings • Improved domain modeling capabilities • Additions to the Java Persistence query language • An API for criteria queries • Standardization of configuration hints • Additional contracts for detached entities and extended persistence contexts • Support for validation via integration with the work of JSR 303 2
  • 4. @OneToMany / @ManyToOne @OneToMany @JoinColumn(name = "ID") private List<Editor> editors; markus@eisele.net 3
  • 5. @ElementCollection @ElementCollection private Set<String> websites = new HashSet(); markus@eisele.net 4
  • 6. @OrderColumn @OrderColumn(name="ED_ORDER") private List<Editor> editors; markus@eisele.net 5
  • 7. @MapKeyJoinColumn @JoinTable(name="ADRESSESS", joinColumns= @JoinColumn(name="AUTORID"), inverseJoinColumns=@JoinColumn(name="CONTACTID")) @MapKeyJoinColumn(name="ADRESSID") Map<Adress, Contactdetails> allAdressess; markus@eisele.net 6
  • 8. @Embeddable @Embedded PhoneNumber number; @ManyToOne PhoneServiceProvider provider; markus@eisele.net 7
  • 9. @Access @Entity @Access(FIELD) public class PhoneNumber { ... @Transient String localnumber; @Access(PROPERTY) protected double getInternationalNumber(Locale locale) { return convertToIntNumber(localnumber); } ... } 8
  • 10. Combined Primary Keys @Entity @IdClass(ArticlePK.class) public class Article { @Id Long id; @Id @ManyToOne Magazine magazine; @Id @ManyToOne Author author; } public class ArticlePK { Long id; Long magazine; Long author; } markus@eisele.net 9
  • 11. Criteria API I // create / inject EntityManager EntityManager em = ...; // build Criteria Query CriteriaBuilder qb = em.getCriteriaBuilder(); CriteriaQuery cq = qb.createQuery(); Root<Author> autor = cq.from(Author.class); cq.select(author); // execute Criteria Query Query query = em.createQuery(cq); List result = query.getResultList(); markus@eisele.net 10
  • 12. Criteria API II Root autor = cq.from(Author.class); cq.where(qb.equal(author.get("name"), name)); cq.select(autor); markus@eisele.net 11
  • 13. Metamodel API @Entity public class Customer { @Id int custId; String name; ... @OneToMany(mappedBy="customer") Set<Order> orders; ... } import javax.persistence.metamodel.*; @TypesafeMetamodel public class Customer_ { public static volatile Attribute<Customer, Integer> custId; public static volatile Attribute<Customer, String> name; public static volatile Set<Customer, Order> orders; ... } 12
  • 14. Metamodel API + Criteria API cq.where(qb.equal(autor.get(Autor_.name), "name")); markus@eisele.net 13
  • 15. Bean Validation (JSR-303) @Entity public class Autor implements Serializable { […] @NotNull @Size(max=30) private String name; […] } •@NotNull •@Size.max •@Digits •@Min / @Max •@Future / @Past •@Size markus@eisele.net 14
  • 16. LockModeTypes .READ => LockModeType.OPTIMISTIC .WRITE => LockModeType.OPTIMISTIC_FORCE_INCREMENT NEW!: LockModeType.PESSIMISTIC_READ (Repeatable Read) LockModeType.PESSIMISTIC_WRITE (Serialized) LockModeType.PESSIMISTIC_FORCE_INCREMENT markus@eisele.net 15
  • 17. JPQL Enhancements • Timestamp • Non-polymorphic Queries • Collection Paramters in IN Expression • Ordered List Index • CASE Statement 16
  • 18. Second Level Cache public interface Cache { boolean contains(Class clz, Object primaryKey); void evict(Class clz, Object primaryKey); void evict(Class clz); void evictAll(); } markus@eisele.net 17
  • 19. Links und Informationen • http://blog.eisele.net/ • http://blogs.sun.com/ldemichiel/ • http://www.jcp.org/en/jsr/detail?id=317 • http://www.eclipse.org/eclipselink markus@eisele.net 18