About EntityManager

81-90 of 200Refresh
Manual
21

Locking in JPA

another EntityManager) since it was retrieved by the current updater. Optimistic locking ... another EntityManager instance) currently holds a PESSIMISTIC_WRITE lock on that database object. A PESSIMISTIC ... .lock(e1, lockMode1); em2.lock(e2, lockMode2); em1 and em2 are two EntityManager instances
Manual
21

UPDATE SET Queries in JPA/JPQL

objects into an EntityManager. Updating the relevant entity object fields within an active transaction ... them, but it should be used cautiously because bypassing the EntityManager may break its synchronization with the database. For example, the EntityManager may not be aware that a cached entity object in
Manual
16

JPA Lifecycle Events

(added to the EntityManager). @PostPersist - after storing a new entity in the database (during commit or ... - when an entity is identified as modified by the EntityManager. @PostUpdate - after updating an entity in ... the EntityManager. @PostRemove - after deleting an entity from the database (during commit or flush). An entity
Tutorial
16

Step 3: Define an EJB Session Bean

; import java.util.List; import javax.ejb.Stateless; import javax.persistence.EntityManager; import ... class GuestDao { // Injected database connection: @PersistenceContext private EntityManager ... ). Prepares an EntityManager automatically and injects it into the em field (because it is annotated
Tutorial
16

Step 3: Define an EJB Session Bean

.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.persistence.TypedQuery ... : @PersistenceContext private EntityManager em; // Stores a new guest: public void persist(Guest guest ... shown in the next step). Prepares an EntityManager automatically and injects it into the em field
Manual
16

Query Parameters in JPA

getCountryByName(EntityManager em, String name) { TypedQuery query = em.createQuery ... Country getCountryByName(EntityManager em, String name) { TypedQuery query = em ... without parameters: public Country getCountryByName(EntityManager em, String name) { TypedQuery
Manual
13

Entity Management Settings

the persistence context of the EntityManager (which serves as a first level cache). The valid values are "weak ... all its EntityManager instances. The level 2 cache is disabled by specifying 0 or 0mb. The element
Manual
13

JPA Metamodel API

by the EntityManager's getMetamodel method (both methods are equivalent). For example, given an EntityManager, em, a Metamodel instance can be obtained by: Metamodel metamodel = em.getMetamodel
Result
13

ObjectDB Object Database Features

entity object cache (per EntityManager). L2 shared entity data cache (per EntityManagerFactory ... availability and fault tolerance. Online Backup Online backup by a simple query on an EntityManager
Manual
13

SELECT clause (JPQL / Criteria API)

The ability to retrieve managed entity objects is a major advantage of JPQL. For example, the following query returns Country objects that become managed by the EntityManager em: TypedQuery ... are not associated with an EntityManager and changes to them when a transaction is active are not