r/java • • Nov 01 '26

Hibernate lost my update

https://bartoszosipiuk.pl/en/blog/hibernate-lost-my-update/

Hibernate silently commits part of a transaction if Spring Boot (or generally any async operation) shuts down mid-transaction.

In my past experience I found multiple bugs in different libraries, but this is the first time I though it needs a separate blog post. Losing part of the updates is one of the worst things that can happen (breaking business rules, and making debugging issues extremely hard).

Hope you find this useful and use the fix. FYI: it's already tested in prod with +80k/t(ransactions)ps.

72 Upvotes

65 comments sorted by

View all comments

Show parent comment

1

u/Mixon1212 Nov 02 '26

The issue is that Hibernate in the docs says - "you cant use Session if you closed the EntitySessionFactory", but in real applications where you cannot just stop the threads, this is almost impossible. So they can defend themself.

In the other hands, JPA spec says (and in general Atomicity rule) - all or nothing, so...
Please comment the hibernate bug (on the bottom of the article) that you also think this should be fixed. Just my single report might be not enough for them.