@Override
protected void configure(Configuration configuration) {
super.configure(configuration);
configuration.setProperty(AvailableSettings.SHOW_SQL, Boolean.TRUE.toString());
configuration.setProperty(AvailableSettings.FORMAT_SQL, Boolean.TRUE.toString());
configuration.setProperty(AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, "10");
}
@Test
public void hhhXXXXTest() throws Exception {
try (Session s = openSession()) {
Transaction tx = s.beginTransaction();
EntityA entityA = new EntityA();
EntityA childA1 = new EntityA();
EntityA childA2 = new EntityA();
EntityB entityB1 = new EntityB();
EntityB entityB2 = new EntityB();
EntityB entityB3 = new EntityB();
entityA.children.addAll(List.of(childA1, childA2));
childA1.parent = entityA;
childA1.listOfEntitiesB.addAll(List.of(entityB1, entityB2, entityB3));
childA2.parent = entityA;
s.persist(entityA);
s.persist(childA1);
s.persist(childA2);
s.persist(entityB1);
s.persist(entityB2);
s.persist(entityB3);
tx.commit();
}
try (Session s = openSession()) {
List<EntityA> entitiesA = s.createQuery("select a from EntityA a where a.parent is null", EntityA.class)
.getResultList();
assertThat(entitiesA).hasSize(1);
assertThat(entitiesA.get(0).children).hasSize(2);
}
}