Interface JpaTransactionManager

    • Method Detail

      • getStandaloneEntityManager

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

        Caller is responsible for closing the returned instance.

      • setDatabaseSnapshot

        JpaTransactionManager setDatabaseSnapshot​(java.lang.String snapshotId)
        Specifies a database snapshot exported by another transaction to use in the current transaction.

        This is a Postgresql-specific feature. This method must be called before any other SQL commands in a transaction.

        To support large queries, transaction isolation level is fixed at the REPEATABLE_READ to avoid exhausting predicate locks at the SERIALIZABLE level.

        See Also:
        DatabaseSnapshot
      • getEntityManager

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

        The returned instance is closed when the current transaction completes.

      • query

        <T> javax.persistence.TypedQuery<T> query​(java.lang.String sqlString,
                                                  java.lang.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​(java.lang.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.

      • transactNoRetry

        <T> T transactNoRetry​(java.util.function.Supplier<T> work)
        Executes the work in a transaction with no retries and returns the result.
      • transactNoRetry

        void transactNoRetry​(java.lang.Runnable work)
        Executes the work in a transaction with no retries.
      • 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.