## org.hibernate.ejb
Class AbstractEntityManagerImpl

    java.lang.Object
      org.hibernate.ejb.AbstractEntityManagerImpl

All Implemented Interfaces:
  Serializable, EntityManager, HibernateEntityManager, HibernateEntityManagerImplementor

Direct Known Subclasses:
  EntityManagerImpl

    public abstract class AbstractEntityManagerImpl

extends Object
implements HibernateEntityManagerImplementor, Serializable

See Also:
  Serialized Form

Nested Class Summary
`static class` `AbstractEntityManagerImpl.TupleBuilderTransformer`

Nested classes/interfaces inherited from interface org.hibernate.ejb.HibernateEntityManagerImplementor
`HibernateEntityManagerImplementor.Options`

Field Summary
`protected PersistenceContextType` `persistenceContextType`
`protected TransactionImpl` `tx`

Constructor Summary
`protected` `AbstractEntityManagerImpl(EntityManagerFactoryImpl entityManagerFactory, PersistenceContextType type, PersistenceUnitTransactionType transactionType, Map properties)`

Method Summary
`void` `clear()`
`boolean` `contains(Object entity)`
`RuntimeException` `convert(HibernateException e)` Converts a Hibernate-specific exception into a JPA-specified exception; note that the JPA sepcification makes use of exceptions outside its exception hierarchy, though they are all runtime exceptions.
`RuntimeException` `convert(HibernateException e, LockOptions lockOptions)` Converts a Hibernate-specific exception into a JPA-specified exception; note that the JPA sepcification makes use of exceptions outside its exception hierarchy, though they are all runtime exceptions.
`RuntimeException` `convert(RuntimeException e)`
`Query` `createNamedQuery(String name)`

`

`<T> TypedQuery<T>`

`

`createNamedQuery(String name, Class<T> resultClass)`

`Query` `createNativeQuery(String sqlString)`
`Query` `createNativeQuery(String sqlString, Class resultClass)`
`Query` `createNativeQuery(String sqlString, String resultSetMapping)`

`

`<T> TypedQuery<T>`

`

`createQuery(CriteriaQuery<T> criteriaQuery)`

`Query` `createQuery(String jpaqlString)`

`

`<T> TypedQuery<T>`

`

`createQuery(String jpaqlString, Class<T> resultClass)`

`

`<T> TypedQuery<T>`

`

`createQuery(String jpaqlString, Class<T> resultClass, Selection selection, HibernateEntityManagerImplementor.Options options)`
Used during "compiling" a JPA criteria query.

`void` `detach(Object entity)`
`CacheMode` `determineAppropriateLocalCacheMode(Map<String,Object> localProperties)`

`

`<A> A`

`

`find(Class<A> entityClass, Object primaryKey)`

`

`<A> A`

`

`find(Class<A> entityClass, Object primaryKey, LockModeType lockModeType)`

`

`<A> A`

`

`find(Class<A> entityClass, Object primaryKey, LockModeType lockModeType, Map<String,Object> properties)`

`

`<T> T`

`

`find(Class<T> entityClass, Object primaryKey, Map<String,Object> properties)`

`void` `flush()`
`CriteriaBuilder` `getCriteriaBuilder()`
`Object` `getDelegate()` returns the underlying session
`EntityManagerFactoryImpl` `getEntityManagerFactory()`
`HibernateEntityManagerFactory` `getFactory()` Get access to the Hibernate extended EMF contract.
`FlushModeType` `getFlushMode()` Hibernate can be set in various flush modes that are unknown to JPA 2.0.
`LockModeType` `getLockMode(Object entity)`
`LockOptions` `getLockRequest(LockModeType lockModeType, Map<String,Object> properties)` Convert from JPA 2 `LockModeType` & properties into `LockOptions`
`Metamodel` `getMetamodel()`
`Map<String,Object>` `getProperties()`
`protected abstract Session` `getRawSession()` Return a Session (even if the entity manager is closed).

`

`<T> T`

`

`getReference(Class<T> entityClass, Object primaryKey)`

`abstract Session` `getSession()` return a Session
`EntityTransaction` `getTransaction()`
`PersistenceUnitTransactionType` `getTransactionType()`
`void` `handlePersistenceException(PersistenceException e)` Handles marking for rollback and other such operations that need to occur depending on the type of exception being handled.
`boolean` `isTransactionInProgress()` Provides access to whether a transaction is currently in progress.
`void` `joinTransaction()`
`void` `lock(Object entity, LockModeType lockMode)`
`void` `lock(Object entity, LockModeType lockModeType, Map<String,Object> properties)`
`protected void` `markAsRollback()`

`

`<A> A`

`

`merge(A entity)`

`void` `persist(Object entity)`
`protected void` `postInit()`
`void` `refresh(Object entity)`
`void` `refresh(Object entity, LockModeType lockModeType)`
`void` `refresh(Object entity, LockModeType lockModeType, Map<String,Object> properties)`
`void` `refresh(Object entity, Map<String,Object> properties)`
`void` `remove(Object entity)`
`void` `setFlushMode(FlushModeType flushModeType)`
`void` `setProperty(String s, Object o)`
`void` `throwPersistenceException(HibernateException e)` Delegates to `HibernateEntityManagerImplementor.convert(org.hibernate.HibernateException, org.hibernate.LockOptions)` and then throws the given exception.
`void` `throwPersistenceException(PersistenceException e)` Delegates to `HibernateEntityManagerImplementor.handlePersistenceException(javax.persistence.PersistenceException)` and then throws the given exception.

`

`<T> T`

`

`unwrap(Class<T> clazz)`

`PersistenceException` `wrapLockException(HibernateException e, LockOptions lockOptions)`
`PersistenceException` `wrapStaleStateException(StaleStateException e)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface javax.persistence.EntityManager
`close, isOpen`

Field Detail

### tx

    protected transient TransactionImpl tx

### persistenceContextType

    protected PersistenceContextType persistenceContextType

Constructor Detail

### AbstractEntityManagerImpl

    protected AbstractEntityManagerImpl(EntityManagerFactoryImpl entityManagerFactory,
                                        PersistenceContextType type,
                                        PersistenceUnitTransactionType transactionType,
                                        Map properties)

Method Detail

### getTransactionType

    public PersistenceUnitTransactionType getTransactionType()

### postInit

    protected void postInit()

### createQuery

    public Query createQuery(String jpaqlString)

  Specified by:
    `createQuery` in interface `EntityManager`

### createQuery

    public <T> TypedQuery<T> createQuery(String jpaqlString,
                                         Class<T> resultClass)

  Specified by:
    `createQuery` in interface `EntityManager`

### createQuery

    public <T> TypedQuery<T> createQuery(String jpaqlString,
                                         Class<T> resultClass,
                                         Selection selection,
                                         HibernateEntityManagerImplementor.Options options)

  Description copied from interface: `HibernateEntityManagerImplementor`
  Used during "compiling" a JPA criteria query.

  Specified by:
    `createQuery` in interface `HibernateEntityManagerImplementor`
  Type Parameters:
    `T` - The query type
  Parameters:
    `jpaqlString` - The criteria query rendered as a JPA QL string
    `resultClass` - The result type (the type expected in the result list)
    `selection` - The selection(s)
    `options` - The options to use to build the query.
  Returns:
    The typed query

### createQuery

    public <T> TypedQuery<T> createQuery(CriteriaQuery<T> criteriaQuery)

  Specified by:
    `createQuery` in interface `EntityManager`

### createNamedQuery

    public Query createNamedQuery(String name)

  Specified by:
    `createNamedQuery` in interface `EntityManager`

### createNamedQuery

    public <T> TypedQuery<T> createNamedQuery(String name,
                                              Class<T> resultClass)

  Specified by:
    `createNamedQuery` in interface `EntityManager`

### createNativeQuery

    public Query createNativeQuery(String sqlString)

  Specified by:
    `createNativeQuery` in interface `EntityManager`

### createNativeQuery

    public Query createNativeQuery(String sqlString,
                                   Class resultClass)

  Specified by:
    `createNativeQuery` in interface `EntityManager`

### createNativeQuery

    public Query createNativeQuery(String sqlString,
                                   String resultSetMapping)

  Specified by:
    `createNativeQuery` in interface `EntityManager`

### getReference

    public <T> T getReference(Class<T> entityClass,
                              Object primaryKey)

  Specified by:
    `getReference` in interface `EntityManager`

### find

    public <A> A find(Class<A> entityClass,
                      Object primaryKey)

  Specified by:
    `find` in interface `EntityManager`

### find

    public <T> T find(Class<T> entityClass,
                      Object primaryKey,
                      Map<String,Object> properties)

  Specified by:
    `find` in interface `EntityManager`

### find

    public <A> A find(Class<A> entityClass,
                      Object primaryKey,
                      LockModeType lockModeType)

  Specified by:
    `find` in interface `EntityManager`

### find

    public <A> A find(Class<A> entityClass,
                      Object primaryKey,
                      LockModeType lockModeType,
                      Map<String,Object> properties)

  Specified by:
    `find` in interface `EntityManager`

### determineAppropriateLocalCacheMode

    public CacheMode determineAppropriateLocalCacheMode(Map<String,Object> localProperties)

### persist

    public void persist(Object entity)

  Specified by:
    `persist` in interface `EntityManager`

### merge

    public <A> A merge(A entity)

  Specified by:
    `merge` in interface `EntityManager`

### remove

    public void remove(Object entity)

  Specified by:
    `remove` in interface `EntityManager`

### refresh

    public void refresh(Object entity)

  Specified by:
    `refresh` in interface `EntityManager`

### refresh

    public void refresh(Object entity,
                        Map<String,Object> properties)

  Specified by:
    `refresh` in interface `EntityManager`

### refresh

    public void refresh(Object entity,
                        LockModeType lockModeType)

  Specified by:
    `refresh` in interface `EntityManager`

### refresh

    public void refresh(Object entity,
                        LockModeType lockModeType,
                        Map<String,Object> properties)

  Specified by:
    `refresh` in interface `EntityManager`

### contains

    public boolean contains(Object entity)

  Specified by:
    `contains` in interface `EntityManager`

### getLockMode

    public LockModeType getLockMode(Object entity)

  Specified by:
    `getLockMode` in interface `EntityManager`

### setProperty

    public void setProperty(String s,
                            Object o)

  Specified by:
    `setProperty` in interface `EntityManager`

### getProperties

    public Map<String,Object> getProperties()

  Specified by:
    `getProperties` in interface `EntityManager`

### flush

    public void flush()

  Specified by:
    `flush` in interface `EntityManager`

### getSession

    public abstract Session getSession()

  return a Session

  Specified by:
    `getSession` in interface `HibernateEntityManager`
  Returns:
    The session
  Throws:
    `IllegalStateException` - if the entity manager is closed

### getRawSession

    protected abstract Session getRawSession()

  Return a Session (even if the entity manager is closed).

  Returns:
    A session.

### getTransaction

    public EntityTransaction getTransaction()

  Specified by:
    `getTransaction` in interface `EntityManager`

### getEntityManagerFactory

    public EntityManagerFactoryImpl getEntityManagerFactory()

  Specified by:
    `getEntityManagerFactory` in interface `EntityManager`

### getFactory

    public HibernateEntityManagerFactory getFactory()

  Get access to the Hibernate extended EMF contract.

  Specified by:
    `getFactory` in interface `HibernateEntityManagerImplementor`
  Returns:
    The Hibernate EMF contract for this EM.

### getCriteriaBuilder

    public CriteriaBuilder getCriteriaBuilder()

  Specified by:
    `getCriteriaBuilder` in interface `EntityManager`

### getMetamodel

    public Metamodel getMetamodel()

  Specified by:
    `getMetamodel` in interface `EntityManager`

### setFlushMode

    public void setFlushMode(FlushModeType flushModeType)

  Specified by:
    `setFlushMode` in interface `EntityManager`

### clear

    public void clear()

  Specified by:
    `clear` in interface `EntityManager`

### detach

    public void detach(Object entity)

  Specified by:
    `detach` in interface `EntityManager`

### getFlushMode

    public FlushModeType getFlushMode()

  Hibernate can be set in various flush modes that are unknown to JPA 2.0. This method can then return null. If it returns null, do em.unwrap(Session.class).getFlushMode() to get the Hibernate flush mode

  Specified by:
    `getFlushMode` in interface `EntityManager`

### lock

    public void lock(Object entity,
                     LockModeType lockMode)

  Specified by:
    `lock` in interface `EntityManager`

### lock

    public void lock(Object entity,
                     LockModeType lockModeType,
                     Map<String,Object> properties)

  Specified by:
    `lock` in interface `EntityManager`

### getLockRequest

    public LockOptions getLockRequest(LockModeType lockModeType,
                                      Map<String,Object> properties)

  Description copied from interface: `HibernateEntityManagerImplementor`
  Convert from JPA 2 `LockModeType` & properties into `LockOptions`

  Specified by:
    `getLockRequest` in interface `HibernateEntityManagerImplementor`
  Parameters:
    `lockModeType` - is the requested lock type
    `properties` - are the lock properties
  Returns:
    the LockOptions

### isTransactionInProgress

    public boolean isTransactionInProgress()

  Description copied from interface: `HibernateEntityManagerImplementor`
  Provides access to whether a transaction is currently in progress.

  Specified by:
    `isTransactionInProgress` in interface `HibernateEntityManagerImplementor`
  Returns:
    True if a transaction is considered currently in progress; false otherwise.

### markAsRollback

    protected void markAsRollback()

### joinTransaction

    public void joinTransaction()

  Specified by:
    `joinTransaction` in interface `EntityManager`

### unwrap

    public <T> T unwrap(Class<T> clazz)

  Specified by:
    `unwrap` in interface `EntityManager`

### getDelegate

    public Object getDelegate()

  returns the underlying session

  Specified by:
    `getDelegate` in interface `EntityManager`

### handlePersistenceException

    public void handlePersistenceException(PersistenceException e)

  Handles marking for rollback and other such operations that need to occur depending on the type of exception being handled.

  Specified by:
    `handlePersistenceException` in interface `HibernateEntityManagerImplementor`
  Parameters:
    `e` - The exception being handled.

### throwPersistenceException

    public void throwPersistenceException(PersistenceException e)

  Delegates to `HibernateEntityManagerImplementor.handlePersistenceException(javax.persistence.PersistenceException)` and then throws the given exception.

  Specified by:
    `throwPersistenceException` in interface `HibernateEntityManagerImplementor`
  Parameters:
    `e` - The exception being handled and finally thrown.

### convert

    public RuntimeException convert(HibernateException e)

  Converts a Hibernate-specific exception into a JPA-specified exception; note that the JPA sepcification makes use of exceptions outside its exception hierarchy, though they are all runtime exceptions.

  Any appropriate/needed calls to `HibernateEntityManagerImplementor.handlePersistenceException(javax.persistence.PersistenceException)` are also made.

  Specified by:
    `convert` in interface `HibernateEntityManagerImplementor`
  Parameters:
    `e` - The Hibernate excepton.
  Returns:
    The JPA-specified exception

### convert

    public RuntimeException convert(RuntimeException e)

### convert

    public RuntimeException convert(HibernateException e,
                                    LockOptions lockOptions)

  Converts a Hibernate-specific exception into a JPA-specified exception; note that the JPA sepcification makes use of exceptions outside its exception hierarchy, though they are all runtime exceptions.

  Any appropriate/needed calls to `HibernateEntityManagerImplementor.handlePersistenceException(javax.persistence.PersistenceException)` are also made.

  Specified by:
    `convert` in interface `HibernateEntityManagerImplementor`
  Parameters:
    `e` - The Hibernate excepton.
    `lockOptions` - The lock options in effect at the time of exception (can be null)
  Returns:
    The JPA-specified exception

### throwPersistenceException

    public void throwPersistenceException(HibernateException e)

  Delegates to `HibernateEntityManagerImplementor.convert(org.hibernate.HibernateException, org.hibernate.LockOptions)` and then throws the given exception.

  Specified by:
    `throwPersistenceException` in interface `HibernateEntityManagerImplementor`
  Parameters:
    `e` - The exception being handled and finally thrown.

### wrapStaleStateException

    public PersistenceException wrapStaleStateException(StaleStateException e)

  Specified by:
    `wrapStaleStateException` in interface `HibernateEntityManagerImplementor`

### wrapLockException

    public PersistenceException wrapLockException(HibernateException e,
                                                  LockOptions lockOptions)

Copyright © 2001-2012 Red Hat, Inc. All Rights Reserved.