Top Description Methods
jakarta.persistence

public Interface EntityTransaction


Interface used to control transactions on resource-local entity managers. The EntityManager#getTransaction method returns the EntityTransaction interface.
Since
1.0

Method Summary

Modifier and TypeMethod and Description
public void
begin()

Start a resource transaction.

public void
commit()

Commit the current resource transaction, writing any unflushed changes to the database.

public boolean

Returns:

boolean indicating whether the transaction has been marked for rollback
getRollbackOnly
()

Determine whether the current resource transaction has been marked for rollback.

public Integer
getTimeout()

The transaction timeout.

public boolean

Returns:

boolean indicating whether transaction is in progress
isActive
()

Indicate whether a resource transaction is in progress.

public void
rollback()

Roll back the current resource transaction.

public void
setRollbackOnly()

Mark the current resource transaction so that the only possible outcome of the transaction is for the transaction to be rolled back.

public void
setTimeout(Integer
the timeout, in seconds, or null to indicate that the database server should set the timeout
timeout
)

Set the transaction timeout, in seconds.

Method Detail

beginback to summary
public void begin()

Start a resource transaction.

Exceptions
IllegalStateException:
if isActive() is true
commitback to summary
public void commit()

Commit the current resource transaction, writing any unflushed changes to the database.

Exceptions
IllegalStateException:
if isActive() is false
RollbackException:
if the commit fails
getRollbackOnlyback to summary
public boolean getRollbackOnly()

Determine whether the current resource transaction has been marked for rollback.

Returns:boolean

boolean indicating whether the transaction has been marked for rollback

Exceptions
IllegalStateException:
if isActive() is false
getTimeoutback to summary
public Integer getTimeout()

The transaction timeout.

Since
3.2
isActiveback to summary
public boolean isActive()

Indicate whether a resource transaction is in progress.

Returns:boolean

boolean indicating whether transaction is in progress

Exceptions
PersistenceException:
if an unexpected error condition is encountered
rollbackback to summary
public void rollback()

Roll back the current resource transaction.

Exceptions
IllegalStateException:
if isActive() is false
PersistenceException:
if an unexpected error condition is encountered
setRollbackOnlyback to summary
public void setRollbackOnly()

Mark the current resource transaction so that the only possible outcome of the transaction is for the transaction to be rolled back.

Exceptions
IllegalStateException:
if isActive() is false
setTimeoutback to summary
public void setTimeout(Integer timeout)

Set the transaction timeout, in seconds. This is a hint.

Parameters
timeout:Integer

the timeout, in seconds, or null to indicate that the database server should set the timeout

Since
3.2