Interface TransactionSettings

All Known Subinterfaces:
AvailableSettings
All Known Implementing Classes:
Environment

public interface TransactionSettings
  • Field Details

    • TRANSACTION_CONCURRENCY

      static final String TRANSACTION_CONCURRENCY

      Declares the factory's transaction concurrency baseline without changing connection settings. Accepts an TransactionConcurrency instance or a textual name recognized by the dialect's TransactionConcurrencyResolver.

      A supplied descriptor is used as-is, bypassing concurrency resolution, probing, and validation. The caller is responsible for its accuracy and immutability. Other bootstrap JDBC metadata access is unaffected.

      The built-in resolvers accept the following names, ignoring case and leading or trailing whitespace:

      • READ_UNCOMMITTED: declares JDBC read-uncommitted isolation.
      • READ_COMMITTED: declares JDBC read-committed isolation, leaving the choice of locking or versioned ordinary reads to database observations and established dialect facts. The name alone does not resolve that choice.
      • LOCKING_READ_COMMITTED: declares read-committed isolation with locking ordinary reads.
      • READ_COMMITTED_SNAPSHOT: declares read-committed isolation with versioned ordinary reads. This is distinct from transaction-level SNAPSHOT.
      • REPEATABLE_READ: declares JDBC repeatable-read isolation, with behavior resolved for the dialect.
      • SERIALIZABLE: declares JDBC serializable isolation, with behavior resolved for the dialect.
      • SNAPSHOT: declares the dialect's transaction-level snapshot configuration. The corresponding dialect resolver maps this to the native snapshot isolation value for SQL Server and H2, repeatable-read for PostgreSQL and MySQL, and serializable for Oracle. The Firebird and TiDB community resolvers map it to repeatable-read. Resolvers without a snapshot mapping reject this name.

      These names declare configurations, not portable sets of identical guarantees. A dialect-specific resolver may recognize additional names. Unknown names and named declarations contradicting known observations or established dialect facts fail bootstrap.

      The declaration supplies facts unavailable during bootstrap, especially when JDBC metadata access is disabled. If omitted, resolution uses only available observations and established dialect facts, leaving missing information unknown. This setting does not imply that a connection provider honors the separate connection-isolation setting.

      Since:
      8.0
      See Also:
    • TRANSACTION_COORDINATOR_STRATEGY

      static final String TRANSACTION_COORDINATOR_STRATEGY
      Specify the TransactionCoordinatorBuilder implementation to use for creating instances of TransactionCoordinator which the interface Hibernate uses to manage transactions.

      Accepts either:

      • an instance of TransactionCoordinatorBuilder,
      • a Class representing a class that implements TransactionCoordinatorBuilder,
      • the name of a class that implements TransactionCoordinatorBuilder,
      • jta or jdbc
      Since:
      5.0
      See Also:
      Implementation Specification:
      With non-Jakarta Persistence bootstrapping, Hibernate will use jdbc as the default which will cause problems if the application actually uses JTA-based transactions.
      Default Value:
      With Jakarta Persistence bootstrapping, based on the persistence unit's PersistenceUnitInfo.getTransactionType(); otherwise jdbc.
    • JTA_PLATFORM

      static final String JTA_PLATFORM
      Specifies the JtaPlatform implementation to use for integrating with JTA, either:
      • an instance of JtaPlatform, or
      • the name of a class that implements JtaPlatform.
      • short name of a class (sans package name) that implements JtaPlatform.
      Since:
      4.0
      See Also:
    • JTA_PLATFORM_RESOLVER

      static final String JTA_PLATFORM_RESOLVER
      Specifies a JtaPlatformResolver implementation that should be used to obtain an instance of JtaPlatform.
      Since:
      4.3
      See Also:
    • PREFER_USER_TRANSACTION

      static final String PREFER_USER_TRANSACTION
      When enabled, specifies that the UserTransaction should be used in preference to the TransactionManager for JTA transaction management.

      By default, the TransactionManager is preferred.

      Since:
      5.0
      See Also:
      Default Value:
      false as TransactionManager is preferred.
    • JTA_CACHE_TM

      static final String JTA_CACHE_TM
      When enabled, indicates that it is safe to cache TransactionManager references in the JtaPlatform
      Since:
      4.0
      See Also:
      Default Value:
      Generally true, though JtaPlatform implementations can do their own thing.
    • JTA_CACHE_UT

      static final String JTA_CACHE_UT
      When enabled, indicates that it is safe to cache UserTransaction references in the JtaPlatform
      Since:
      4.0
      See Also:
      Default Value:
      Generally true, though JtaPlatform implementations can do their own thing.
    • JTA_TRACK_BY_THREAD

      static final String JTA_TRACK_BY_THREAD
      A transaction can be rolled back by another thread ("tracking by thread") -- not the original application. Examples of this include a JTA transaction timeout handled by a background reaper thread. The ability to handle this situation requires checking the Thread ID every time Session is called. This can certainly have performance considerations.
      See Also:
      Default Value:
      true (enabled).
    • ALLOW_JTA_TRANSACTION_ACCESS

      static final String ALLOW_JTA_TRANSACTION_ACCESS
      When enabled, allows access to the Transaction even when using a JTA for transaction management.

      Values are true, which grants access, and false, which does not.

      See Also:
      Default Value:
      false when bootstrapped via JPA; true otherwise.
    • AUTO_CLOSE_SESSION

      static final String AUTO_CLOSE_SESSION
      When enabled, specifies that the Session should be closed automatically at the end of each transaction.
      See Also:
      Default Value:
      false
    • FLUSH_BEFORE_COMPLETION

      static final String FLUSH_BEFORE_COMPLETION
      When enabled, specifies that automatic flushing should occur during the JTA Synchronization.beforeCompletion() callback.
      See Also:
      Default Value:
      true unless using JPA bootstrap
    • ENABLE_LAZY_LOAD_NO_TRANS

      @Unsafe static final String ENABLE_LAZY_LOAD_NO_TRANS
      Allows a detached proxy or lazy collection to be fetched even when not associated with an open persistence context, by creating a temporary persistence context when the proxy or collection is accessed. This behavior is not recommended since it can easily break transaction isolation or lead to data aliasing; it is therefore disabled by default.
      See Also:
      API Note:
      Generally speaking, all access to transactional data should be done in a transaction. Use of this setting is discouraged.
      Default Value:
      false (disabled)
    • ALLOW_UPDATE_OUTSIDE_TRANSACTION

      @Unsafe static final String ALLOW_UPDATE_OUTSIDE_TRANSACTION
      When enabled, allows update operations outside a transaction.

      Since version 5.2 Hibernate conforms with the JPA specification and disallows flushing any update outside a transaction.

      Values are true, which allows flushing outside a transaction, and false, which does not.

      The default behavior is to disallow update operations outside a transaction.

      Since:
      5.2
      See Also:
      API Note:
      Generally speaking, all access to transactional data should be done in a transaction. Combining this with second-level caching is not safe. Use of this setting is discouraged.
      Default Value:
      false (disabled)