Interface JpaTransactionManager

All Superinterfaces:
TransactionManager
All Known Implementing Classes:
JpaTransactionManagerImpl

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

    • getStandaloneEntityManager Link icon

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

      Caller is responsible for closing the returned instance.

    • getMetaModel Link icon

      jakarta.persistence.metamodel.Metamodel getMetaModel()
      Returns the JPA Metamodel.
    • getEntityManager Link icon

      jakarta.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 transact(google.registry.persistence.PersistenceModule.TransactionIsolationLevel, java.util.concurrent.Callable<T>, boolean) call. Nested call sites have no control over which database instance to use.

    • query Link icon

      <T> jakarta.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 Link icon

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

      jakarta.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 Link icon

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

      void teardown()
      Releases all resources and shuts down.

      The errorprone check forbids injection of Closeable resources.

    • setQueryFetchSize Link icon

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

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

      PersistenceModule.TransactionIsolationLevel getCurrentTransactionIsolationLevel()
      Return the PersistenceModule.TransactionIsolationLevel used in the current transaction.
    • transact Link icon

      <T> T transact(PersistenceModule.TransactionIsolationLevel isolationLevel, Callable<T> work, boolean logSqlStatements)
      Executes the work with the given isolation level, possibly logging all SQL statements used.
    • transactNoRetry Link icon

      <T> T transactNoRetry(PersistenceModule.TransactionIsolationLevel isolationLevel, Callable<T> work, boolean logSqlStatements)
      Executes the work with the given isolation level without retry, possibly logging all SQL statements used.