use of com.haulmont.cuba.testmodel.many2many_fetchsameentity.Many2Many_FetchSame1 in project cuba by cuba-platform.
the class ManyToManyFetchSameEntityTest method testManyToMany_sameEntityTwice.
@Test
public void testManyToMany_sameEntityTwice() {
DataManager dataManager = AppBeans.get(DataManager.class);
LoadContext<Many2Many_FetchSame1> loadContext = new LoadContext<>(Many2Many_FetchSame1.class).setView("Many2Many_FetchSame1-sameEntityTwice").setId(same1_3);
Many2Many_FetchSame1 result = dataManager.load(loadContext);
Assertions.assertNotNull(result);
Assertions.assertNotNull(result.getOneToMany2());
Assertions.assertNotNull(result.getOneToMany2().get(0).getMany3());
Assertions.assertNotNull(result.getOneToMany2().get(1).getMany3());
}
use of com.haulmont.cuba.testmodel.many2many_fetchsameentity.Many2Many_FetchSame1 in project cuba by cuba-platform.
the class ManyToManyFetchSameEntityTest method testManyToMany_emptyCollection.
@Test
public void testManyToMany_emptyCollection() {
DataManager dataManager = AppBeans.get(DataManager.class);
LoadContext<Many2Many_FetchSame1> loadContext = new LoadContext<>(Many2Many_FetchSame1.class).setView("Many2Many_FetchSame1-emptyCollection");
loadContext.setQueryString("select e from test$Many2Many_FetchSame1 e where e.name <> 'same1_3'");
List<Many2Many_FetchSame1> result = dataManager.loadList(loadContext);
for (Many2Many_FetchSame1 e : result) {
Assertions.assertTrue(!e.getMany2().isEmpty());
}
}
use of com.haulmont.cuba.testmodel.many2many_fetchsameentity.Many2Many_FetchSame1 in project cuba by cuba-platform.
the class ManyToManyFetchSameEntityTest method setUp.
@BeforeEach
public void setUp() throws Exception {
Transaction tx = cont.persistence().createTransaction();
try {
EntityManager em = cont.persistence().getEntityManager();
Metadata metadata = cont.metadata();
same1_1 = metadata.create(Many2Many_FetchSame1.class);
same1_1.setName("same1_1");
em.persist(same1_1);
same1_2 = metadata.create(Many2Many_FetchSame1.class);
same1_2.setName("same1_2");
em.persist(same1_2);
same1_3 = metadata.create(Many2Many_FetchSame1.class);
same1_3.setName("same1_3");
em.persist(same1_3);
same2_1 = metadata.create(Many2Many_FetchSame2.class);
same2_1.setName("same2_1");
em.persist(same2_1);
same2_2 = metadata.create(Many2Many_FetchSame2.class);
same2_2.setName("same2_2");
em.persist(same2_2);
same2_3 = metadata.create(Many2Many_FetchSame2.class);
same2_3.setName("same2_3");
same2_3.setManyToOne1(same1_3);
em.persist(same2_3);
same2_4 = metadata.create(Many2Many_FetchSame2.class);
same2_4.setName("same2_4");
same2_4.setManyToOne1(same1_3);
em.persist(same2_4);
same3_1 = metadata.create(Many2Many_FetchSame3.class);
same3_1.setName("same3_1");
same3_1 = metadata.create(Many2Many_FetchSame3.class);
em.persist(same3_1);
same3_2 = metadata.create(Many2Many_FetchSame3.class);
same3_2.setName("same3_2");
same3_2 = metadata.create(Many2Many_FetchSame3.class);
em.persist(same3_2);
same1_1.setMany2(Collections.singletonList(same2_1));
same1_2.setMany2(Collections.singletonList(same2_2));
same2_3.setMany3(same3_1);
same2_4.setMany3(same3_2);
tx.commit();
} finally {
tx.end();
}
}
Aggregations