• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
New Features of JSR 317 (JPA 2.0)
 

New Features of JSR 317 (JPA 2.0)

on

  • 6,453 views

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

Statistics

Views

Total Views
6,453
Views on SlideShare
6,149
Embed Views
304

Actions

Likes
6
Downloads
0
Comments
0

3 Embeds 304

http://blog.eisele.net 274
http://www.slideshare.net 29
http://webcache.googleusercontent.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    New Features of JSR 317 (JPA 2.0) New Features of JSR 317 (JPA 2.0) Presentation Transcript

    • „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