Interface JpaTransactionManager
-
- All Superinterfaces:
TransactionManager
- All Known Implementing Classes:
JpaTransactionManagerImpl
public interface JpaTransactionManager extends TransactionManager
Sub-interface ofTransactionManager
which defines JPA related methods.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> void
assertDelete(VKey<T> key)
Deletes the entity by its id, throws exception if the entity is not deleted.<T> javax.persistence.TypedQuery<T>
criteriaQuery(javax.persistence.criteria.CriteriaQuery<T> criteriaQuery)
Creates a JPA SQL query for the given criteria query.javax.persistence.EntityManager
getEntityManager()
Returns theEntityManager
for the current request.javax.persistence.EntityManager
getStandaloneEntityManager()
Returns a long-livedEntityManager
not bound to a particular transaction.javax.persistence.Query
query(java.lang.String sqlString)
Creates a JPA SQL query for the given query string.<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.JpaTransactionManager
setDatabaseSnapshot(java.lang.String snapshotId)
Specifies a database snapshot exported by another transaction to use in the current transaction.static javax.persistence.Query
setQueryFetchSize(javax.persistence.Query query, int fetchSize)
Sets the JDBC driver fetch size for thequery
.void
teardown()
Releases all resources and shuts down.void
transactNoRetry(java.lang.Runnable work)
Executes the work in a transaction with no retries.<T> T
transactNoRetry(java.util.function.Supplier<T> work)
Executes the work in a transaction with no retries and returns the result.-
Methods inherited from interface google.registry.persistence.transaction.TransactionManager
assertInTransaction, createQueryComposer, delete, delete, delete, exists, exists, getTransactionTime, insert, insertAll, insertAll, inTransaction, loadAllOf, loadAllOfStream, loadByEntities, loadByEntitiesIfPresent, loadByEntity, loadByKey, loadByKeyIfPresent, loadByKeys, loadByKeysIfPresent, loadSingleton, put, putAll, putAll, transact, transact, update, updateAll, updateAll
-
-
-
-
Method Detail
-
getStandaloneEntityManager
javax.persistence.EntityManager getStandaloneEntityManager()
Returns a long-livedEntityManager
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 theEntityManager
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 thequery
. This overrides the default configuration.
-
-