Interface JpaTransactionManager

All Superinterfaces:
All Known Implementing Classes:

public interface JpaTransactionManager extends TransactionManager
Sub-interface of TransactionManager which defines JPA related methods.
  • Method Details

    • getStandaloneEntityManager

      javax.persistence.EntityManager getStandaloneEntityManager()
      Returns a long-lived EntityManager not bound to a particular transaction.

      Caller is responsible for closing the returned instance.

    • getEntityManager

      javax.persistence.EntityManager getEntityManager()
      Returns the EntityManager for the current request.

      The returned instance is closed when the current transaction completes.

      Note that in the current implementation the entity manager is obtained from a static ThreadLocal object that is set up by the outermost TransactionManager.transact(java.util.concurrent.Callable<T>) call. Nested call sites have no control over which database instance to use.

    • query

      <T> javax.persistence.TypedQuery<T> query(String sqlString, Class<T> resultClass)
      Creates a JPA SQL query for the given query string and result class.

      This is a convenience method for the longer jpaTm().getEntityManager().createQuery(...).

    • criteriaQuery

      <T> javax.persistence.TypedQuery<T> criteriaQuery(javax.persistence.criteria.CriteriaQuery<T> criteriaQuery)
      Creates a JPA SQL query for the given criteria query.
    • query

      javax.persistence.Query query(String sqlString)
      Creates a JPA SQL query for the given query string.

      This is a convenience method for the longer jpaTm().getEntityManager().createQuery(...).

      Note that while this method can legally be used for queries that return results, it should not be, as it does not correctly detach entities as must be done for nomulus model objects.

    • assertDelete

      <T> void assertDelete(VKey<T> key)
      Deletes the entity by its id, throws exception if the entity is not deleted.
    • teardown

      void teardown()
      Releases all resources and shuts down.

      The errorprone check forbids injection of Closeable resources.

    • setQueryFetchSize

      static javax.persistence.Query setQueryFetchSize(javax.persistence.Query query, int fetchSize)
      Sets the JDBC driver fetch size for the query. This overrides the default configuration.
    • getDefaultTransactionIsolationLevel

      PersistenceModule.TransactionIsolationLevel getDefaultTransactionIsolationLevel()
      Return the default PersistenceModule.TransactionIsolationLevel specified via the config file.
    • getCurrentTransactionIsolationLevel

      PersistenceModule.TransactionIsolationLevel getCurrentTransactionIsolationLevel()
      Return the PersistenceModule.TransactionIsolationLevel used in the current transaction.