Hi!
From a performance and philosophical point of view, which solution is to be preferred?
Create a fresh session every time:
Code:
foreach (chunk) {
Session session = sf.openSession();
Transaction tx = session.beginTransaction();
session.doSomething();
session.doSomethingElse();
tx.commit();
session.close();
}
Or recycle one session:
Code:
Session session = sf.openSession();
foreach (chunk) {
Transaction tx = session.beginTransaction();
session.doSomething();
session.doSomethingElse();
tx.commit();
}
session.close();
I looked in the documentation, and both is possible.
Thanks for your help!
Christian