session.doWork(connection -> {
try (StatelessSession statelessSession = session.getSessionFactory().openStatelessSession(connection)) {
statelessSession.setJdbcBatchSize(2);
statelessSession.insert(new TestEntity(1));
statelessSession.insert(new TestEntity(2));
statelessSession.insert(new TestEntity(3));
}
});
session.flush();
List<TestEntity> entities = session.createQuery("select t from TestEntity t", TestEntity.class).getResultList();
Assert.assertEquals("All 3 entities were persisted", 3, entities.size());