JPA Entity Manager API notes

Bare basic stuff…

  • Categorizes JPA Entity Manager operations
  • Good for quick glance

Persistence Context Operations

CRUD operations

  • <T> T find(java.lang.Class<T> entityClass, java.lang.Object primaryKey)
  • <T> T find(java.lang.Class<T> entityClass, java.lang.Object primaryKey, LockModeType lockMode)
  • <T> T find(java.lang.Class<T> entityClass, java.lang.Object primaryKey, LockModeType lockMode, java.util.Map<java.lang.String,java.lang.Object> properties)
  • <T> T find(java.lang.Class<T> entityClass, java.lang.Object primaryKey, java.util.Map<java.lang.String,java.lang.Object> properties)
  • <T> T merge(T entity)
  • void persist(java.lang.Object entity)
  • void remove(java.lang.Object entity)

other operations

  • void refresh(java.lang.Object entity)
  • void refresh(java.lang.Object entity, LockModeType lockMode)
  • void refresh(java.lang.Object entity, LockModeType lockMode, java.util.Map<java.lang.String,java.lang.Object> properties)
  • void refresh(java.lang.Object entity, java.util.Map<java.lang.String,java.lang.Object> properties)
  • void flush()

  • void clear()

  • void detach(java.lang.Object entity)
  • boolean contains(java.lang.Object entity)

Operations on self

  • void close()
  • boolean isOpen()

Query Operations

  • Query createNamedQuery(java.lang.String name)
  • <T> TypedQuery<T> createNamedQuery(java.lang.String name, java.lang.Class<T> resultClass)
  • StoredProcedureQuery createNamedStoredProcedureQuery(java.lang.String name)
  • Query createNativeQuery(java.lang.String sqlString)
  • Query createNativeQuery(java.lang.String sqlString, java.lang.Class resultClass)
  • Query createNativeQuery(java.lang.String sqlString, java.lang.String resultSetMapping)
  • Query createQuery(CriteriaDelete deleteQuery)
  • <T> TypedQuery<T> createQuery(CriteriaQuery<T> criteriaQuery)
  • Query createQuery(CriteriaUpdate updateQuery)
  • Query createQuery(java.lang.String qlString)
  • <T> TypedQuery<T> createQuery(java.lang.String qlString, java.lang.Class<T> resultClass)
  • StoredProcedureQuery createStoredProcedureQuery(java.lang.String procedureName)
  • StoredProcedureQuery createStoredProcedureQuery(java.lang.String procedureName, java.lang.Class… resultClasses)
  • StoredProcedureQuery createStoredProcedureQuery(java.lang.String procedureName, java.lang.String… resultSetMappings)
  • CriteriaBuilder getCriteriaBuilder()

Entity Graph operations

  • <T> EntityGraph<T> createEntityGraph(java.lang.Class<T> rootType)
  • EntityGraph<?> createEntityGraph(java.lang.String graphName)
  • EntityGraph<?> getEntityGraph(java.lang.String graphName)
  • <T> java.util.List<EntityGraph<? super T>> getEntityGraphs(java.lang.Class<T> entityClass)

Transaction operations

  • <T> T getReference(java.lang.Class<T> entityClass, java.lang.Object primaryKey)
  • EntityTransaction getTransaction()
  • boolean isJoinedToTransaction()
  • void joinTransaction()

Lock operations

  • void lock(java.lang.Object entity, LockModeType lockMode)
  • void lock(java.lang.Object entity, LockModeType lockMode, java.util.Map<java.lang.String,java.lang.Object> properties)


  • java.lang.Object getDelegate()
  • EntityManagerFactory getEntityManagerFactory()
  • FlushModeType getFlushMode()
  • LockModeType getLockMode(java.lang.Object entity)
  • Metamodel getMetamodel()
  • java.util.Map<java.lang.String,java.lang.Object getProperties()
  • void setFlushMode(FlushModeType flushMode)
  • void setProperty(java.lang.String propertyName, java.lang.Object value)
  • <T> T unwrap(java.lang.Class<T> cls)


About Abhishek

Loves Go, NoSQL DBs and messaging systems
This entry was posted in Java EE and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s