Your SlideShare is downloading. ×
0
New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

New Features of JSR 317 (JPA 2.0)

4,878

Published on

Short presentation about the new features of the JPA 2.0 in Java EE 6.0

Short presentation about the new features of the JPA 2.0 in Java EE 6.0

Published in: Technology
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,878
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
7
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. „JPA 2.0“ New Features of JSR 317
  • 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

×