Class Jpa.Builder

java.lang.Object
com.jsgalactic.axiom.jpa.Jpa.Builder
Enclosing class:
Jpa

public static final class Jpa.Builder extends Object
Configures a Jpa; instances are not thread-safe and are used during configuration.
  • Method Details

    • entityManagerFactory

      public Jpa.Builder entityManagerFactory(Object factory)
      Sets the application-owned factory. A value that is not an jakarta.persistence.EntityManagerFactory is rejected by build(). The factory is never closed by this module.
      Parameters:
      factory - application-owned factory
      Returns:
      this builder
    • jta

      Sets a callback that reports an active JTA transaction for the current request. When it returns true the EntityManager joins that transaction and no local transaction is begun, committed or rolled back by this middleware. The callback is supplied by the application or by its JTA adapter; this module has no JTA dependency.
      Parameters:
      jta - request-scoped JTA transaction lookup
      Returns:
      this builder
    • readOnly

      public Jpa.Builder readOnly()
      Makes Jpa.transaction() use read-only semantics: deferred flushing and a rollback when the chain returns. Jpa.readOnlyTransaction() has the same effect without changing this setting.
      Returns:
      this builder
    • rollbackOn

      @SafeVarargs public final Jpa.Builder rollbackOn(Class<? extends Throwable>... types)
      Adds exception types that must roll back. A type matches its own class and subclasses; the nearest matching type wins over a commitOn type of the same class. By default every exception rolls back.
      Parameters:
      types - exception classes
      Returns:
      this builder
    • commitOn

      @SafeVarargs public final Jpa.Builder commitOn(Class<? extends Throwable>... types)
      Adds exception types that must commit. A type matches its own class and subclasses; a more specific rollbackOn type wins. Exceptions that match no rule roll back.
      Parameters:
      types - exception classes
      Returns:
      this builder
    • build

      public Jpa build()
      Creates an immutable adapter and its request-scoped accessor. No EntityManager is opened and no middleware is registered here.
      Returns:
      a reusable adapter
      Throws:
      IllegalStateException - if no factory was supplied
      IllegalArgumentException - if the factory is not an EntityManagerFactory