Transaction management

You will certainly have worked with transactions. They ensure that a unit of work is atomic, consistent, isolated, and durable. Hibernate either uses JDBC to manage transactions or participates in a global transaction, JTA.

Local transactions

We discussed session scope in Chapter 1, Entity and Session. As we saw, one of the options for setting the session context was a local thread. This means that the scope of the session is within the thread that is executing the code, and Hibernate will start the Transaction using the API provided by JDBC. For further information on transaction management using JDBC, refer to the JavaDoc for java.sql.Connection.

In the old days before Hibernate, we had to use the JDBC API to create drivers, ...

Get Mastering Hibernate now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.