Package google.registry.beam.common
Interface RegistryQuery<T>
- All Superinterfaces:
Serializable
Interface for query instances used by
RegistryJpaIO.Read
.-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Number of JPA entities to fetch in each batch during a query. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> RegistryQuery
<T> createQuery
(RegistryQuery.CriteriaQuerySupplier<T> criteriaQuery) Returns aRegistryQuery
from aCriteriaQuery
supplier.static <T> RegistryQuery
<T> createQuery
(String sql, Map<String, Object> parameters, boolean nativeQuery) Returns aRegistryQuery
that creates a string query from constant text.static <T> RegistryQuery
<T> Returns aRegistryQuery
that creates a typed JPQL query from constant text.static <T> T
detach
(jakarta.persistence.EntityManager entityManager, T object) Removes an object from the JPA session cache if applicable.static void
detachObject
(jakarta.persistence.EntityManager entityManager, Object object) stream()
-
Field Details
-
QUERY_FETCH_SIZE
static final int QUERY_FETCH_SIZENumber of JPA entities to fetch in each batch during a query.With Hibernate, for result streaming to work, a query's fetchSize property must be set to a non-zero value.
- See Also:
-
-
Method Details
-
stream
-
createQuery
static <T> RegistryQuery<T> createQuery(String sql, @Nullable Map<String, Object> parameters, boolean nativeQuery) Returns aRegistryQuery
that creates a string query from constant text.- Type Parameters:
T
- Type of each row in the result set,Object
in single-select queries, andObject[]
in multi-select queries.- Parameters:
parameters
- parameters to be substituted in the query.nativeQuery
- whether the given string is to be interpreted as a native query or JPQL.
-
createQuery
static <T> RegistryQuery<T> createQuery(String jpql, @Nullable Map<String, Object> parameters, Class<T> clazz) Returns aRegistryQuery
that creates a typed JPQL query from constant text.- Type Parameters:
T
- Type of each row in the result set.- Parameters:
parameters
- parameters to be substituted in the query.
-
createQuery
Returns aRegistryQuery
from aCriteriaQuery
supplier.A serializable supplier is needed in because
CriteriaQuery
itself must be created within a transaction, and we are not in a transaction yet when this function is called to set up the pipeline.- Type Parameters:
T
- Type of each row in the result set.
-
detach
static <T> T detach(jakarta.persistence.EntityManager entityManager, T object) Removes an object from the JPA session cache if applicable.- Parameters:
object
- An object that represents a row in the result set. It may be a JPA entity, a non-entity object, or an array that holds JPA entities and/or non-entities.
-
detachObject
-