Your SlideShare is downloading. ×
Codecamp iasi-26 nov 2011-what's new in jpa 2.0
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Codecamp iasi-26 nov 2011-what's new in jpa 2.0

471
views

Published on

Published in: Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
471
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. What’s new in JPA 2.0Alin BurlacuJava Developer @ Endava25.11.2011
  • 2. Airplane viewWhy ?  Serializable  JDBC  Platform independent  More OOP likeHow ?  ORM (Object-Relational Mapping)  Entity manager  JPQL (Java Persistence Query Language)
  • 3. What’s newExpanded mapping functionalityPessimistic lockingExpanded QLCriteria APICache (L2) like a standard (minimal)
  • 4. Expanded mapping functionality@Access(Type Option)Mix access modes in a hierarchyCombine access modes in a single class
  • 5. Expanded mapping functionalityAccess Type Option - CODE
  • 6.  @Transient to prevent the field from being mapped in addition to the property.
  • 7. Expanded mapping functionalityOrphan RemovalOnly relationships with single cardinality on the source side :  @OneToOne  @OneToMany
  • 8. Expanded mapping functionalityOrphan Removal - CODE
  • 9. Be aware of object lifecycle
  • 10. Expanded mapping functionality@ElementCollectionCollections of simple data types mapped in separate tables.Map support has been extended so that maps can have keys and values of basic types, entities, or embeddables
  • 11. Expanded mapping functionality@ElementCollection – CODE(Collection of Basic Types)
  • 12. Expanded mapping functionality@ElementCollection - CODE(Map of Basic Types)
  • 13. Expanded mapping functionalityOther@OrderColumn@Embeded@Embedable@EmbededId@OneToMany (no join Table)Hierarchy of embedablesRelations to embedables
  • 14. Pessimistic locking - CODE
  • 15. Pessimistic locking - CODE
  • 16. Expanded QL Timestamp literals SELECT t from BankTransaction t WHERE t.txTime > {ts „2008-06-0110:00:01.0‟} IN expression may include collection parameter SELECT emp FROM Employee emp WHERE emp.project.id IN [:projectIds] Non- polymorphic queries SELECT e FROM Employee e WHERE CLASS(e) = FullTimeEmployee OR e.wage = “SALARY”
  • 17. Expanded QL Ordered List indexing SELECT t FROM CreditCard c JOIN c.transactionHistory t WHERE INDEX(t) BETWEEN 0 AND 9 CASE statement UPDATE Employee e SET e.salary = CASE e.rating WHEN 1 THEN e.salary * 1.1 WHEN 2 THEN e.salary * 1.05 ELSE e.salary * 1.01 END
  • 18. Criteria APISTRING-BASED CRITERIA - CODE { CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery c = b.createQuery(Account.class); Root acct = c.from(Account.class); c.select(acct) .where( cb.equal(acct.get(“name”), “Jim”)); return em.createQuery(c).getResultList(); }
  • 19. Criteria APISTRONGLY TYPED CRITERIA - CODE { CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Account> c = cb.createQuery(Account.class); Root<Account> acct = c.from(Account.class); c.select(acct).where( cb.equal(acct.get(Account_.name), “Jim”)); Return em.createQuery(c).getResultList(); }
  • 20. Cache (L2) like a standard(minimal)
  • 21. References JSR 317 (http://jcp.org/en/jsr/detail?id=317) ProJPA 2 Mastering the Java™ Persistence API by Mike Keith and Merrick Schincariol Beginning Java™ EE 6 Platform with GlassFish™ 3 by Antonio Goncalves http://www.infoq.com/presentations/whats-new-and- exciting-in-jpa-20 http://en.wikibooks.org/wiki/Java_Persistence/What_is_ new_in_JPA_2.0%3F http://wiki.eclipse.org/EclipseLink/Examples/JPA#JPA_ 2.0 http://www.developer.com/features/article.php/3892261/ JPA-20-Cache-Vs-Hibernate-Cache-Differences-in- Approach.htm
  • 22. Thank you