This document discusses Java Persistence 2.0, an update to the Java Persistence API. Key updates include an expanded object-relational mapping model and query language, support for pessimistic locking, and a new Criteria API for dynamic queries. The specification is in public review and aims for a final release in June as part of Java EE 6. GlassFish will provide a Java Persistence 2.0 reference implementation based on EclipseLink.
2. Java Persistence 1.0
• Standardized O/R Mapping for Java EE and Java
SE environments
• A great start .....
2
3. Java Persistence 2.0
• Expanded O/R mapping functionality
• Expanded query language to match
• Criteria API
• Pessimistic locking
• Standardized hints and properties
• Support for validation
• And...some needed cleanups...
3
4. Progress to Date: Early Draft
• Expanded O/R mapping and modeling
> Collections of basic types and embeddables
> Relationships from embeddables
> Multiple levels of embeddables
> Persistent lists
> Real maps and ternary relationships
> Additional database schema mappings
– one-to-many foreign key mappings for unidirectional relationships
– one-to-one, many-to-one join table mappings
> Real overlapping PK/FK modeling support
– “derived identities”
> Combinations of access types
> Orphan deletion 4
5. Progress to Date: Early Draft
• Pessimistic locking
> At both entity and query result levels
• Standardized hints and properties
> For locking
> For configuration
• Simple API for interaction with provider's cache
5
6. Progress to Date: Public Review Draft
• Java Persistence Query Language
> Extensions for new mapping types
> Support for non-polymorphic queries
> Scalar expressions in SELECT list
> Case statements
> INDEX, KEY, VALUE, ENTRY operators for maps and
lists
> Collection-valued parameters for IN expressions
> More flexibility in subqueries
> ...
6
7. Progress to Date: Public Review Draft
• Criteria API
> Dynamic, non-string-based API
> Supports everything that JPQL queries can do
> Integrates with existing Query API
– Create query definitions
– Pass them to createQuery to create Query objects
7
9. Status and Roadmap
• Public Review Draft
> Submitted to JCP last week
> Expected to appear in 1 - 2 weeks
> http://jcp.org/en/jsr/detail?id=317
• Proposed Final Draft in December
> Will target support for Validation (JSR 303)
• Final Release in June
> As part of Java EE 6 and as standalone
Your feedback is important!
> jsr-317-pdr-feedback@sun.com 9
10. GlassFish and Java Persistence
• Java Persistence 1.0 in GlassFish v3 Prelude today
> EclipseLink 1.0
> Hibernate EntityManager
> OpenJPA
• Java Persistence 2.0 RI will be provided by
EclipseLink project
> Will be available in GlassFish v3
10