public EntityManager createEntityManager(); public EntityManager createEntityManager(Map map);
The two createEntityManager
methods above create a new
EntityManager
each time they are invoked. The optional
Map
is used to supply vendor-specific settings. If you
have configured your implementation for JTA transactions and a JTA transaction
is active, the returned EntityManager
will be
synchronized with that transaction.
OpenJPA recognizes the following string keys in the map supplied to
createEntityManager
:
openjpa.ConnectionUserName
openjpa.ConnectionPassword
openjpa.ConnectionRetainMode
openjpa.TransactionMode
openjpa.<property>
, where <property>
is any JavaBean property of the
org.apache.openjpa.persistence.OpenJPAEntityManager
.
The last option uses reflection to configure any property of OpenJPA's
EntityManager
implementation with the value supplied in
your map. The first options correspond exactly to the same-named OpenJPA
configuration keys described in Chapter 2,
Configuration
of the
Reference Guide.