The difference between Hibernate session.getTransaction (). Begin () vs session.beginTransaction ()

I could not find much information on this topic. Can someone explain to me what is the difference between Hibernate session.getTransaction().begin() vs session.beginTransaction()vssession.beginTransaction().begin()

+4
source share
1 answer

The call session.getTransaction().begin()does not make much sense, because it session.getTransaction()will receive a transaction that is already in progress, since it assumes that the transaction is in progress. You basically say: start this transaction, which should already be completed.

session.beginTransaction() it will either start a new transaction if it is not there, or it will use an existing transaction to start the specified unit of work.

session.beginTransaction().begin() == session.beginTransaction()

Hibernate documentation Hibernate. Hibernate, , TransactionManager JDBCTemplate, , .

+7

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


All Articles