JPA Learning - Lesson 6, EntityTransaction

EntityTransaction The
EntityTransaction interface is used to manage the transaction operations of the resource layer entity manager. Obtain its instance by calling the entity manager's getTransaction method.

begin()
is used to start a transaction, after which multiple database operations will be committed or undone as a whole. If the transaction has been started at this time, an IllegalStateException will be thrown.
commit()
is used to commit the current transaction. That is, all database update operations after the transaction is started are persisted to the database.

rollback()
undoes (rolls back) the current transaction. That is, all database update operations after the transaction is started are undone, so that the database will not be affected.

setRollbackOnly()
makes the current transaction only undoable.

getRollbackOnly ()
to see if the current transaction has the undo-only flag set.

isActive()
to see if the current transaction is active. If it returns true, the begin method cannot be called, otherwise an IllegalStateException will be thrown; if it returns false, the commit, rollback, setRollbackOnly and getRollbackOnly methods cannot be called, otherwise an IllegalStateException will be thrown.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326692743&siteId=291194637