Search in sources :

Example 1 with LegacyOrderPositionDefault

use of com.blazebit.persistence.view.testsuite.entity.LegacyOrderPositionDefault in project blaze-persistence by Blazebit.

the class EntityViewUpdateSubviewInverseEmbeddedSimpleTest method testLoadMultipleUpdatableWithUpdatableFlatViewIds.

@Test
public void testLoadMultipleUpdatableWithUpdatableFlatViewIds() {
    transactional(new TxVoidWork() {

        @Override
        public void work(EntityManager em) {
            LegacyOrder o = new LegacyOrder();
            em.persist(o);
            LegacyOrderPosition p = new LegacyOrderPosition(new LegacyOrderPositionId(o.getId(), 0));
            p.setArticleNumber("123");
            p.setOrder(o);
            em.persist(p);
            o.getPositions().add(p);
            LegacyOrderPositionDefault d1 = new LegacyOrderPositionDefault(new LegacyOrderPositionDefaultId(p.getId(), 1));
            d1.setValue("1");
            em.persist(d1);
            LegacyOrderPositionDefault d2 = new LegacyOrderPositionDefault(new LegacyOrderPositionDefaultId(p.getId(), 2));
            d2.setValue("1");
            em.persist(d2);
            p.getDefaults().add(d1);
            p.getDefaults().add(d2);
        }
    });
    em.clear();
    List<UpdatableLegacyOrderPositionDefaultView> resultList = evm.applySetting(EntityViewSetting.create(UpdatableLegacyOrderPositionDefaultView.class), cbf.create(em, LegacyOrderPositionDefault.class)).getResultList();
    // Making the id view updatable at some point caused just a part of the id to be considered when de-duplicating updatable views
    assertEquals(2, resultList.size());
    assertNotEquals(resultList.get(0).getId(), resultList.get(1).getId());
}
Also used : LegacyOrderPosition(com.blazebit.persistence.view.testsuite.entity.LegacyOrderPosition) EntityManager(javax.persistence.EntityManager) UpdatableLegacyOrderPositionDefaultView(com.blazebit.persistence.view.testsuite.update.subview.inverse.embedded.simple.model.UpdatableLegacyOrderPositionDefaultView) TxVoidWork(com.blazebit.persistence.testsuite.tx.TxVoidWork) LegacyOrderPositionDefault(com.blazebit.persistence.view.testsuite.entity.LegacyOrderPositionDefault) LegacyOrderPositionId(com.blazebit.persistence.view.testsuite.entity.LegacyOrderPositionId) LegacyOrderPositionDefaultId(com.blazebit.persistence.view.testsuite.entity.LegacyOrderPositionDefaultId) LegacyOrder(com.blazebit.persistence.view.testsuite.entity.LegacyOrder) AbstractEntityViewUpdateTest(com.blazebit.persistence.view.testsuite.update.AbstractEntityViewUpdateTest) Test(org.junit.Test)

Aggregations

TxVoidWork (com.blazebit.persistence.testsuite.tx.TxVoidWork)1 LegacyOrder (com.blazebit.persistence.view.testsuite.entity.LegacyOrder)1 LegacyOrderPosition (com.blazebit.persistence.view.testsuite.entity.LegacyOrderPosition)1 LegacyOrderPositionDefault (com.blazebit.persistence.view.testsuite.entity.LegacyOrderPositionDefault)1 LegacyOrderPositionDefaultId (com.blazebit.persistence.view.testsuite.entity.LegacyOrderPositionDefaultId)1 LegacyOrderPositionId (com.blazebit.persistence.view.testsuite.entity.LegacyOrderPositionId)1 AbstractEntityViewUpdateTest (com.blazebit.persistence.view.testsuite.update.AbstractEntityViewUpdateTest)1 UpdatableLegacyOrderPositionDefaultView (com.blazebit.persistence.view.testsuite.update.subview.inverse.embedded.simple.model.UpdatableLegacyOrderPositionDefaultView)1 EntityManager (javax.persistence.EntityManager)1 Test (org.junit.Test)1