Difference between a sleep transaction and a database transaction executed using SQL queries?

Is there a difference between the two? For example, in a hibernation transaction, we can access the database, run some Java code, and access the database again. We cannot do this as part of a transaction executed through SQL, can we? Is that the difference?

+6
source share
1 answer

2 are directly related to each other - the Hibernate transaction maps and manages the JDBC transaction (database).

You can do the same with direct JDBC / SQL, without Hibernate - although you will need to call Connection.setAutoCommit(false) to start, otherwise by default a commit is called after each statement - each statement is executed in its own transaction.

Some additional information is available at http://docs.oracle.com/javase/tutorial/jdbc/basics/transactions.html .

+5
source

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


All Articles