Why does transaction.wasCommitted () return false?

I am new to hibernate and java-ee in general, and I was wondering if anyone could tell me why this piece of code returns false, although looking at the database I can see that the transaction was actually committed:

    session.beginTransaction();
    session.saveOrUpdate(user);
    session.getTransaction().commit();
    return session.getTransaction().wasCommitted(); //Always false

Thank!

0
source share
1 answer

wasCommitted()do not always have to return true, even if the commit was successful . It will return trueif the transaction was (unambiguously) committedthrough this local transaction; falseotherwise.

From docs : -

wasCommitted

false (). , JTA, no-op, commit() ; wasCommitted() false.

+2

Source: https://habr.com/ru/post/1537664/


All Articles