||EJB 3.0 EntityManager
||JDO 2.0 PersistenceManager
|Cause an object to become part of the database and tracked by the manager.
||In JDO any referenced objects that can be persistent will become persistent implicitly at the transaction boundary, which is known as persistence by reachability. In EJB 3.0 persistence by declarative reachability will be used where any referenced objects that can be persistent will be so only if they have explicit metadata defined.
|Allow objects to be detached with identity from the transaction to act as DTOs for another tier.
||In EJB when closing the EntityManager or ending a transaction, all objects loaded become detached. In JDO, only objects targeted by business logic are detached, and it is not required to close the PersistenceManager. JDO also allows the use of a fetch group to allow objects or fields involved in a custom use case to be detached down the graph of the root objects. EJB uses cascading metadata to achieve the same effect. In JDO there can be many named use-case fetch groups. In EJB there is only one definition of cascading relationships.
|Allow objects previously detached with identity to be attached, and apply any changes made during detachment to the existing database objects.
||On merge or attach, all objects changed will be compared using timestamps and updated optimistically. In JDO all reachable objects are automatically attached. In EJB only objects that have explicit metadata are attached.
|Find an object by identity in the database.
|Flush changes to objects managed by the manager to the database.
||In both EJB and JDO this method is called implicitly at commit time. The effects of this method for both EJB and JDO are changed based on the database isolation level that is chosen.
|Create a Query object to find objects in the database.
||The Query object encapsulates SQL behavior in an object.
|Create a named query.
|Create a SQL query instead of an EJBQL or JDOQL query
||newQuery("sql", "SQL STRING")
||JDO uses the same newQuery() method with different invocation parameters.
|Refresh objects in the manager's cache from the database.
|Evict objects in the manager's cache from the JVM.
|Find out if an object is currently managed by the manager.
Table 1 Comparing Behaviors
As a subset of the behavior found in the PersistenceManager, proposed behavior in the EntityManager corresponds to these behaviors in the PersistenceManager.