Perhaps the greatest number of changes with the release of the Java EE 6 specification was introduced in JPA (Java Persistence API). In a series of articles, starting with this one, I plan to tell in detail about each of the innovations.
Introduction
JPA technology is an abstraction over JDBC and allows you to be independent of SQL. All classes and JPA interfaces are located in the javax.persistence package, the main components of the technology are:
ORM (object-relational mapping mechanism);
Entity manager API - allows you to perform basic CRUD operations;
JPQL and Criteria API - data extraction mechanisms;
Transaction and lock management (both with and without JTA);
Callbacks and listeners.
JPA 2.0 changes the following:
Improved support for maps: now both the key and the value can be a simple type, entity or embedded object (embedded);
Collections of embedded objects and simple types (Integer, etc.) can now be rendered into separate tables. Previously, it was possible to carry out only collections of entities in separate tables;
Now you can manage the ordering of persistent objects using the annotation @OrderColumn ;
Now it is possible to delete orphan objects (orphan removal): when a parent is deleted, the child is also deleted;
There was support for pessimistic blocking (optimistic supported with JPA 1.0);
New Query Definition API, which allows you to build queries in the style of OOP (as opposed to writing in the string JPQL queries);
The possibilities of JPQL (query language in JPA) have greatly expanded;
Embedded objects can now be part of other embedded objects, as well as participate in relationships with entities. Navigation through the object graph using the point has been extended for use with embedded objects;
Added support for new caching APIs.
At the moment, the only provider of JPA 2.0 is EclipseLink , it is also a reference implementation of JPA 2.0. I have been using it for several months now and am ready to say that I find this project very stable. ')
In the next article I will talk about the innovations in the declaration of ORM.