Wrong Pagination Backend Filtering
mydeadlyvenoms opened this issue · comments
Hi @BalusC
I found an interesting bug today, I already reported something similar in the past (#10).
I tried the backend filter feature like the following.
EntityAService
public PartialResultList<EntityA> getPage(Page page, boolean count, EntityB entityB, boolean booleanA) {
return getPage(page, count, (criteriaBuilder, criteriaQuery, entityA) -> {
criteriaQuery.where(
criteriaBuilder.and(
criteriaBuilder.equal(entityA.get("entityB"), entityB),
criteriaBuilder.equal(entityA.get("booleanA"), booleanA)
)
);
});
}
EntityABacking
...
@Getter
private PagedDataModel<EntityA> entityAs;
...
@PostConstruct
private void init() {
entityAs = PagedDataModel.lazy((page, count) -> entityAService.getPage(page, count, entityB, true))
.orderBy(EntityA::getA, false)
.orderBy(EntityA::getB, false)
.build();
}
...
The pagination shows the total amount of entities (without the filtering).
Latest tests are showing that there might be a general problem when using backend filtering and pagination.
Indeed, the row counter seems to ignore the QueryBuilder.
Confirmed, execution of the QueryBuilder
is skipped for row counter when there are no criteria specified via PagedDataModel.lazy(...).criteria(...)
. This was initially done for performance reasons.
It's now fixed in OmniPersistence side.
Thank you very much for your help.
I created a new issue inside the OmniPersistence Projekt: omnifaces/omnipersistence#15
Please let me know if I can help you testing it.