Package com.jsgalactic.axiom.jpa
Class Jpa.Builder
java.lang.Object
com.jsgalactic.axiom.jpa.Jpa.Builder
- Enclosing class:
Jpa
Configures a
Jpa; instances are not thread-safe and are used during configuration.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Creates an immutable adapter and its request-scoped accessor.final Jpa.BuilderAdds exception types that must commit.entityManagerFactory(Object factory) Sets the application-owned factory.jta(JtaTransactionLookup jta) Sets a callback that reports an active JTA transaction for the current request.readOnly()MakesJpa.transaction()use read-only semantics: deferred flushing and a rollback when the chain returns.final Jpa.BuilderrollbackOn(Class<? extends Throwable>... types) Adds exception types that must roll back.
-
Method Details
-
entityManagerFactory
Sets the application-owned factory. A value that is not anjakarta.persistence.EntityManagerFactoryis rejected bybuild(). 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
MakesJpa.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
Adds exception types that must roll back. A type matches its own class and subclasses; the nearest matching type wins over acommitOntype of the same class. By default every exception rolls back.- Parameters:
types- exception classes- Returns:
- this builder
-
commitOn
Adds exception types that must commit. A type matches its own class and subclasses; a more specificrollbackOntype wins. Exceptions that match no rule roll back.- Parameters:
types- exception classes- Returns:
- this builder
-
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 suppliedIllegalArgumentException- if the factory is not anEntityManagerFactory
-