session = sessionFactory.openSession();
tx = session.getTransaction();
final List<Foo> fooList = Lists.newArrayList();
for (int i = 35; i < 46; i++) {
final Foo foo = new Foo();
foo.setName("Foo_" + (i + 120));
final Bar bar = new Bar("bar_" + i);
bar.getFooSet().add(foo);
foo.setBar(bar);
fooList.add(foo);
}
try {
tx.begin();
for (final Foo foo : fooList) {
session.save(foo.getBar());
session.save(foo);
}
tx.commit();
session.flush();
} catch (final HibernateException he) {