Search in sources :

Example 16 with PaginatedCriteriaBuilder

use of com.blazebit.persistence.PaginatedCriteriaBuilder in project blaze-persistence by Blazebit.

the class ExpressionCorrelationTest method testFilterSortJoinCorrelatedSingularViewPaginated.

@Test
// @Category({ NoHibernate42.class, NoHibernate43.class, NoHibernate50.class, NoDatanucleus4.class, NoOpenJPA.class, NoEclipselink.class })
@Category({ NoHibernate42.class, NoHibernate43.class, NoHibernate50.class, NoDatanucleus.class, NoOpenJPA.class, NoEclipselink.class })
public void testFilterSortJoinCorrelatedSingularViewPaginated() {
    EntityViewManager evm = buildEntityViewManagerForFilter();
    CriteriaBuilder<Document> criteria = cbf.create(em, Document.class, "d");
    EntityViewSetting<DocumentSimpleCorrelationViewJoinId, PaginatedCriteriaBuilder<DocumentSimpleCorrelationViewJoinId>> setting;
    setting = EntityViewSetting.create(DocumentSimpleCorrelationViewJoinId.class, 0, 1);
    setting.addAttributeFilter("correlatedOwnerView.name", "PERS2");
    setting.addAttributeSorter("correlatedOwnerView.name", Sorters.ascending());
    setting.addAttributeSorter("id", Sorters.ascending());
    PaginatedCriteriaBuilder<DocumentSimpleCorrelationViewJoinId> cb = evm.applySetting(setting, criteria);
    PagedList<DocumentSimpleCorrelationViewJoinId> results = cb.getResultList();
    assertEquals(1, results.size());
    assertEquals(3, results.getTotalSize());
}
Also used : EntityViewManager(com.blazebit.persistence.view.EntityViewManager) DocumentSimpleCorrelationViewJoinId(com.blazebit.persistence.view.testsuite.correlation.expression.model.DocumentSimpleCorrelationViewJoinId) Document(com.blazebit.persistence.testsuite.entity.Document) PaginatedCriteriaBuilder(com.blazebit.persistence.PaginatedCriteriaBuilder) Category(org.junit.experimental.categories.Category) Test(org.junit.Test) AbstractCorrelationTest(com.blazebit.persistence.view.testsuite.correlation.AbstractCorrelationTest)

Aggregations

PaginatedCriteriaBuilder (com.blazebit.persistence.PaginatedCriteriaBuilder)16 Document (com.blazebit.persistence.testsuite.entity.Document)12 EntityViewManager (com.blazebit.persistence.view.EntityViewManager)12 Test (org.junit.Test)12 Category (org.junit.experimental.categories.Category)8 AbstractEntityViewTest (com.blazebit.persistence.view.testsuite.AbstractEntityViewTest)7 AbstractCorrelationTest (com.blazebit.persistence.view.testsuite.correlation.AbstractCorrelationTest)5 DocumentSimpleCorrelationViewJoinId (com.blazebit.persistence.view.testsuite.correlation.expression.model.DocumentSimpleCorrelationViewJoinId)4 FilteredDocument (com.blazebit.persistence.view.testsuite.basic.model.FilteredDocument)3 CriteriaBuilder (com.blazebit.persistence.CriteriaBuilder)2 BlazeCriteriaBuilder (com.blazebit.persistence.criteria.BlazeCriteriaBuilder)2 DocumentWithEntityView (com.blazebit.persistence.view.testsuite.basic.model.DocumentWithEntityView)2 DocumentMasterView (com.blazebit.persistence.view.testsuite.subview.model.DocumentMasterView)2 LimitBuilder (com.blazebit.persistence.LimitBuilder)1 ObjectBuilder (com.blazebit.persistence.ObjectBuilder)1 PagedList (com.blazebit.persistence.PagedList)1 KeysetPageable (com.blazebit.persistence.deltaspike.data.KeysetPageable)1 BasicCatView (com.blazebit.persistence.examples.showcase.fragments.cte.view.BasicCatView)1 ExpressionFactory (com.blazebit.persistence.parser.expression.ExpressionFactory)1 JpaProvider (com.blazebit.persistence.spi.JpaProvider)1