org.opencms.db.jpa
Class CmsDbContext

java.lang.Object
  extended by org.opencms.db.CmsDbContext
      extended by org.opencms.db.jpa.CmsDbContext

public final class CmsDbContext
extends CmsDbContext

Wraps context information to access the OpenCms database.

Since:
8.0.0

Field Summary
protected  javax.persistence.EntityManager m_entityManager
          The EntityManager instance for this context.
protected  boolean m_shouldCommit
          Tells when the current transaction should be commit or rollback.
 
Fields inherited from class org.opencms.db.CmsDbContext
m_attributes, m_flexRequestContextInfo, m_projectId, m_requestContext
 
Constructor Summary
CmsDbContext()
          Creates a new, empty database context.
CmsDbContext(CmsRequestContext context)
          Creates a new database context initialized with the given user request context.
 
Method Summary
 void clear()
          Clears this database context.
 javax.persistence.EntityManager getEntityManager()
          Returns the entity manager of this db context.
 void report(I_CmsReport report, CmsMessageContainer message, Throwable throwable)
          Reports an error to the given report (if available) and to the OpenCms log file.
 void rollback()
          Rollback current transaction and starts new.
 
Methods inherited from class org.opencms.db.CmsDbContext
currentProject, currentUser, getAttribute, getFlexRequestContextInfo, getHistoryDriver, getProjectDriver, getProjectId, getRequestContext, getUserDriver, getVfsDriver, isDefaultDbContext, pop, removeAttribute, removeSiteRoot, setAttribute, setProjectId, throwException
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_entityManager

protected javax.persistence.EntityManager m_entityManager
The EntityManager instance for this context.


m_shouldCommit

protected boolean m_shouldCommit
Tells when the current transaction should be commit or rollback.

Constructor Detail

CmsDbContext

public CmsDbContext()
Creates a new, empty database context.


CmsDbContext

public CmsDbContext(CmsRequestContext context)
Creates a new database context initialized with the given user request context.

Parameters:
context - the current users request context
Method Detail

clear

public void clear()
Clears this database context.

Overrides:
clear in class CmsDbContext

getEntityManager

public javax.persistence.EntityManager getEntityManager()
Returns the entity manager of this db context.

Returns:
the entity manager of this db context

report

public void report(I_CmsReport report,
                   CmsMessageContainer message,
                   Throwable throwable)
            throws CmsVfsException,
                   CmsException
Reports an error to the given report (if available) and to the OpenCms log file.

Overrides:
report in class CmsDbContext
Parameters:
report - the report to write the error to
message - the message to write to the report / log
throwable - the exception to write to the report / log
Throws:
CmsException - if the throwable parameter is not null and a CmsException
CmsVfsException - if the throwable parameter is not null and no CmsException

rollback

public void rollback()
Rollback current transaction and starts new.

Overrides:
rollback in class CmsDbContext