JPA allows you to map entities to databases and also to query them using different criteria.
JPA’s power is that it offers the ability to query entities and their relationships in an object oriented
way without having to use the underlying database foreign keys or columns. The central
piece of the API responsible for orchestrating entities is the entity manager. Its role is to
manage entities, read from and write to a given database, and allow simple CRUD operations
on entities as well as complex queries using JPQL. In a technical sense, the entity manager is
just an interface whose implementation is done by the persistence provider, EclipseLink.
What’s New in JPA 2.0?
This second version brings new APIs, extends JPQL, and adds these new
functionalities:
• New mapping annotations have been added.
• Optimistic locking was already supported, but now pessimistic locking has been
added.
• Collections of simple data types (String, Integer, etc.) and of embeddable objects
can now be mapped in separate tables. Previously, you could only map collections of
entities.
• Map support has been extended so that maps can have keys and values of basic types,
entities, or embeddables.
• Maintaining a persistent ordering is now possible with the @OrderColumn annotation.
• Orphan removal allows child objects to be removed from a relationship if the parent
object is removed.
• A brand-new Query Definition API has been introduced to allow queries to be constructed
in an object-oriented manner.
• JPQL syntax is richer (e.g., it now allows case expressions).
• Embeddable objects can now be nested into other embeddable objects and have relationships
to entities.
• The dot (.) navigation syntax has been extended to handle embeddables with relationships
and embeddables of embeddables.
• Support for a new caching API has been added.





