Well - I'm not the expert at this may help:
From the API Docs:
Quote:
The lifecycle of a Session is bounded by the beginning and end of a logical transaction
Only a single transaction can therefore be bound to a session
at any one time. Otherwise you would need to say:
Code:
session.save(Object, TransactionToSaveIn)
as opposed to
Code:
session.save(Object)
The behaviour when opening a second nested transaction is therefore undefined in line with your results.
Note that you could perform multiple NON-NESTED transactions within the scope of a single session i.e.:
Code:
Session sess = factory.openSession();
Transaction tx;
try {
tx = sess.beginTransaction();
//do some work
...
tx.commit();
tx = sess.beginTransaction();
//do some more work
...
tx.commit();
}
catch (Exception e) {
if (tx!=null) tx.rollback();
throw e;
}
finally {
sess.close();
}
[/b]