Interface IJpaTransaction

All Superinterfaces:
AutoCloseable, Closeable

public interface IJpaTransaction extends Closeable
Common interface representing a JPA transaction context, which encapsulates a single JPA entity transaction. This interface provides methods to manage the transaction lifecycle, including committing and rolling back transactions.

Note: Transactions need be set to be committed on close explicitly by calling commit(). Otherwise, the transaction will be rolled back automatically when the context is closed.

This interface extends Closeable to allow for automatic resource management, ensuring that the transaction is properly closed and resources are released.

Note: This interface is designed for internal use only. Plugins should not use this interface. This interface may be moved to a different package in the future, so plugins should not depend on it.

Since:
8.5.0
Author:
Norman Lorenz
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes the JPA transaction context, committing the JPA transaction if set to do so.
    void
    Marks the transaction to be committed when the transaction context is closed.
    javax.persistence.EntityManager
    em()
    Returns the JPA EntityManager associated with this transaction context.
    boolean
    Checks if the transaction is marked to be committed when it is closed.
    void
    Marks the transaction to be rolled back when the transaction context is closed.
  • Method Details

    • close

      void close()
      Closes the JPA transaction context, committing the JPA transaction if set to do so.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IllegalStateException - if the JPA EntityManager is closed or the JPA transaction is not active
      RuntimeException - if the commit fails
      See Also:
    • commit

      void commit()
      Marks the transaction to be committed when the transaction context is closed.
      See Also:
    • em

      javax.persistence.EntityManager em()
      Returns the JPA EntityManager associated with this transaction context.
      Returns:
      the EntityManager
    • isCommit

      boolean isCommit()
      Checks if the transaction is marked to be committed when it is closed.
      Returns:
      true if the transaction is set to be committed, false otherwise
      See Also:
    • rollback

      void rollback()
      Marks the transaction to be rolled back when the transaction context is closed.
      See Also: