Class HibernatePrefetchHelper
- java.lang.Object
-
- com.atlassian.confluence.impl.content.render.prefetch.hibernate.HibernatePrefetchHelper
-
public class HibernatePrefetchHelper extends Object
- Since:
- 5.10
-
-
Constructor Summary
Constructors Constructor Description HibernatePrefetchHelper(org.springframework.orm.hibernate5.HibernateOperations hibernate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <I,O>
Collection<O>partitionedQuery(Collection<I> inputItems, int partitionSize, Function<Collection<I>,Collection<O>> query)
A convenience method for running a query against a large set of inputs.<T> Collection<T>
prefetchEntitiesById(String idPropertyName, Collection<?> ids, Class<T> entityType)
Attempts to efficiently load Hibernate entities of a given type given a collection od IDs.
-
-
-
Method Detail
-
prefetchEntitiesById
public <T> Collection<T> prefetchEntitiesById(String idPropertyName, Collection<?> ids, Class<T> entityType)
Attempts to efficiently load Hibernate entities of a given type given a collection od IDs.Note that if the entities are already present in the Hibernate L2 cache, then this query will be doing unnecessary work, and the cached entities could be fetched by
net.sf.hibernate.Session#get(Class, Serializable)
. However, there's no way to make this determination without getting up to our elbows in Hibernate's innards, which probably isn't worth it.- Returns:
- the number of entities that were prefetched
-
partitionedQuery
public static <I,O> Collection<O> partitionedQuery(Collection<I> inputItems, int partitionSize, Function<Collection<I>,Collection<O>> query)
A convenience method for running a query against a large set of inputs. The inputs are partitioned up and the query is executed for each partition. The results are then recombined into a single collection.
-
-