Search in sources :

Example 1 with EmbeddableTestEntitySimpleFetchView

use of com.blazebit.persistence.view.testsuite.fetch.embedded.model.EmbeddableTestEntitySimpleFetchView in project blaze-persistence by Blazebit.

the class EmbeddedFetchTest method testCorrelation.

protected <T extends EmbeddableTestEntitySimpleFetchView> void testCorrelation(Class<T> entityView, Integer batchSize) {
    EntityViewManager evm = build(entityView, IntIdEntitySimpleSubView.class, IntIdEntityFetchSubView.class, EmbeddableTestEntitySimpleFetchView.class, EmbeddableTestEntitySimpleFetchView.Id.class, EmbeddableTestEntityEmbeddableFetchSubView.class);
    CriteriaBuilder<EmbeddableTestEntity2> criteria = cbf.create(em, EmbeddableTestEntity2.class, "d").orderByAsc("id.key");
    EntityViewSetting<T, CriteriaBuilder<T>> setting = EntityViewSetting.create(entityView);
    if (batchSize != null) {
        setting.setProperty(ConfigurationProperties.DEFAULT_BATCH_SIZE + ".manyToOne", batchSize);
    }
    CriteriaBuilder<T> cb = evm.applySetting(setting, criteria);
    List<T> results = cb.getResultList();
    Assert.assertEquals(4, results.size());
    if (EmbeddableTestEntityFetchAsEntityView.class.isAssignableFrom(entityView)) {
        assertEquals(doc1, (EmbeddableTestEntityFetchAsEntityView) results.get(0));
        assertEquals(doc2, (EmbeddableTestEntityFetchAsEntityView) results.get(1));
        assertEquals(doc3, (EmbeddableTestEntityFetchAsEntityView) results.get(2));
        assertEquals(doc4, (EmbeddableTestEntityFetchAsEntityView) results.get(3));
    } else {
        assertEquals(doc1, (EmbeddableTestEntityFetchAsViewView) results.get(0));
        assertEquals(doc2, (EmbeddableTestEntityFetchAsViewView) results.get(1));
        assertEquals(doc3, (EmbeddableTestEntityFetchAsViewView) results.get(2));
        assertEquals(doc4, (EmbeddableTestEntityFetchAsViewView) results.get(3));
    }
}
Also used : EmbeddableTestEntity2(com.blazebit.persistence.view.testsuite.entity.EmbeddableTestEntity2) CriteriaBuilder(com.blazebit.persistence.CriteriaBuilder) EmbeddableTestEntitySimpleFetchView(com.blazebit.persistence.view.testsuite.fetch.embedded.model.EmbeddableTestEntitySimpleFetchView) EntityViewManager(com.blazebit.persistence.view.EntityViewManager)

Aggregations

CriteriaBuilder (com.blazebit.persistence.CriteriaBuilder)1 EntityViewManager (com.blazebit.persistence.view.EntityViewManager)1 EmbeddableTestEntity2 (com.blazebit.persistence.view.testsuite.entity.EmbeddableTestEntity2)1 EmbeddableTestEntitySimpleFetchView (com.blazebit.persistence.view.testsuite.fetch.embedded.model.EmbeddableTestEntitySimpleFetchView)1