New features in JPA 2.0

Today I had a look at the early draft of the JPA 2.0 spec and like. Here are my highlights of the new features:

  • Added support for persistently ordered lists using OrderColumn and provider-managed ordering column.
    -> Greate! That was really missing!
  • Defined support for foreign key mapping strategy for unidirectional one-to-many relationships.
    -> Very good. It’s not very handy to use a relationship table in a one-to-many mapping
  • Added clear method to EntityManager interface to allow entities to be evicted from the persistence context; added CLEAR cascade option.
    -> Bulk Update and Delete will be even more useful
  • Added Cache interface.
    -> I’m not sure if it’s a great idea, but who knows…
  • Added support for pessimistic locking and new lock mode types.
    -> I hope JPA will also provide support for SELECT FOR UPDATE
  • Added overloaded find and refresh methods added to support locking with standardized and vendor-specific properties and hints.
    -> Very good, it’s no longer required to define an extra query
  • Added standardized hint javax.persistence.lock.timeout for use in locking configuration.
    -> Great idea!
  • Added the standardized properties javax.persistence.jdbc.driver, javax.persistence.jdbc.url, javax.persistence.jdbc.user, javax.persistence.jdbc.password for use in persistence unit and entity manager factory configuration.
    -> Super! It will be simpler to change the persistence provider in standalone environment. And it will be easier for the tools provider to support persitence.xml properties completion.
  • Added Query getNamedParameters and getPositionalParameters methods.
    -> good thing, at least for debugging

I hope there will be more of them in the next version of the spec…