Class HqlInClauseBatchHelper
java.lang.Object
com.atlassian.crowd.util.persistence.hibernate.HqlInClauseBatchHelper
A reusable batching helper for HQL queries using "in" clause with a list of parameters. This helper is here to help with not exceeding the in clause limit on various databases
Clients may supply a
Consumer
instances for applying various parameters for Hibernate Query.
Default batch size is 1000 elements provided to "in" clause, which can be overwritten using "crowd.query.in.batch.size" system property
Sample usage:
final List<String> parameters = Lists.newArrayList("param1", "param2")
HqlInClauseBatchHelper
.ofNamedQuery(session, "removeInternalUserAttributesById")
.executeUpdate("parametersNames", parameters);
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
-
Method Summary
Modifier and TypeMethodDescription<T> void
executeUpdate
(String inClauseParameterName, Iterable<T> inClauseObjects) Executes HQL query in batchesstatic int
ofHqlQuery
(org.hibernate.Session session, String query) Constructs a new builder for HQL "in" clause helper with supplied hibernate session object and HQL queryofNamedQuery
(org.hibernate.Session session, String queryName) Constructs a new builder for HQL "in" clause helper with supplied hibernate session object and query name<T> List<T>
static void
setBatchSize
(int newBatchSize) splitIntoBatches
(Iterable<T> inClauseObjects) splitIntoBatchesList
(Iterable<T> inClauseObjects)
-
Method Details
-
ofNamedQuery
public static HqlInClauseBatchHelper.HqlInClauseBatchHelperBuilder ofNamedQuery(org.hibernate.Session session, String queryName) Constructs a new builder for HQL "in" clause helper with supplied hibernate session object and query name- Parameters:
session
- hibernate session objectqueryName
- name of the HQL query- Returns:
- new HqlInClauseBatchHelperBuilder
-
ofHqlQuery
public static HqlInClauseBatchHelper.HqlInClauseBatchHelperBuilder ofHqlQuery(org.hibernate.Session session, String query) Constructs a new builder for HQL "in" clause helper with supplied hibernate session object and HQL query- Parameters:
session
- hibernate session objectquery
- the HQL query- Returns:
- new HqlInClauseBatchHelperBuilder
-
splitIntoBatches
-
splitIntoBatchesList
-
setBatchSize
public static void setBatchSize(int newBatchSize) -
getBatchSize
public static int getBatchSize() -
executeUpdate
Executes HQL query in batches- Type Parameters:
T
- represents a type of objects supplied to the query- Parameters:
inClauseParameterName
- name of the in clause parameter in queryinClauseObjects
- list of parameters that will be supplied to in cluase parameter in query
-
query
-