I am aware that Hibernate uses JDBC API for persistece.
However, I have one query regarding JDBC transactions in Hibernate. I am posting the below snippet and have written what I understand from each line of code:
Could you please verify and correct my understanding, before I study further?
That looks accurate, to my understanding. The overall pattern is:
* get a transaction (from somewhere--here you are using the session, but sometimes you can get that other ways).
* do your processing. If all goes well, commit the transaction (make all the stuff actually happen).
* if all does NOT go well, you can have that exception. I don't see a comment, but I bet you already know this part.
In the event of failure, you can rollback the transaction. That makes all the database changes you had setup during the processing, go away. That means, had you added five rows to 3 different tables, and then there was some kind of key constraint problem, your exception would have happened, and all the tables would be restored to the previously (presumably healthy) state.
And you probably knew this was all about the "C" in ACID--Consistency. No half-complete database changes.
No one does anything from a single motive.
--Samuel Taylor Coleridge
Let's get him boys! We'll make him read this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads