---
<property name="hibernate.connection.pool_size">20</property>
<property name="hibernate.connection.timeout">5000</property>
@Entity
@Cacheable(true)
try (Session session = sessionFactory.openSession()) {
}
Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
for (int i = 0; i < entities.size(); i++) {
session.save(entities.get(i));
if (i % 20 == 0) {
session.flush();
session.clear();
}
}
tx.commit();
session.close();
@Entity
public class Parent {
@OneToMany(mappedBy = "parent", fetch = FetchType.LAZY)
private List<Child> children;
}