You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@deltaspike.apache.org by "Shultz, Dmitry" <Dm...@kaltire.com> on 2021/03/13 01:02:19 UTC
Data module - how to create/initialize TypedQuery with CriteriaQuery
Hi Guys,
I'm using Data module and trying to implement the PrimeFaces LazyDataModel using JPA c riteria API, like BaluC advised here:
https://stackoverflow.com/questions/17261124/get-rid-of-if-else-ladder-when-creating-jpa-criteria-query-based-on-sort-filter
My repository extends AbstractFullEntityRepository and I'm implementing method with signature:
public List<Message> findWithCriteria(int start, int pageSize, Map<String, SortMeta> sortBy, Map<String, FilterMeta> filters) {
CriteriaQuery<Message> criteriaQuery = criteriaBuilder.createQuery(Message.class);
... // add predicates and orders to the criteriaQuery
entityManager().createQuery(criteriaQuery).setFirstResult(start).setMaxResults(pageSize);
}
The problem I'm facing is - I don't know how to get the entityManager from inside repository class. Or maybe I don't need to get it and there is some other way to feed to criteriaQuery into the TypedQuery?
Thanks,
Dmitry