About EntityManager

81-90 of 200Refresh
Manual
13

Storing JPA Entity Objects

state is New. An explicit call to persist associates the object with an owner EntityManager em ... managed by the EntityManager) or by commit. Referenced Embedded Objects The following code stores ... to the database using flush are considered temporary and are only visible to the owner EntityManager
Manual
13

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
13

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
Manual
13

Query Parameters in JPA [2011-04-01]

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

Query Parameters in JPA

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

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
Tutorial
11

Step 4: Add a Servlet Class

)getServletContext().getAttribute("emf"); EntityManager em = emf.createEntityManager ... , and then an EntityManager (representing a database connection) is constructed. If a new guest
Manual
11

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
11

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
Tutorial
11

Step 4: Add a Servlet Class

"); EntityManager em = emf.createEntityManager(); try { // Handle a new guest (if any ... is retrieved from the application scope attribute, and then an EntityManager (representing a database