Module storm.java

Class ORMTemplate.Builder

java.lang.Object
st.orm.template.ORMTemplate.Builder
Enclosing interface:
ORMTemplate

public static final class ORMTemplate.Builder extends Object
Builder for constructing an ORMTemplate with instance-scoped integration strategies.
Since:
1.13
  • Method Details

    • config

      public ORMTemplate.Builder config(StormConfig config)
      Sets the Storm configuration to apply to the template instance.
      Parameters:
      config - the Storm configuration; must not be null.
      Returns:
      this builder.
    • decorator

      public ORMTemplate.Builder decorator(UnaryOperator<TemplateDecorator> decorator)
      Sets a function that transforms the TemplateDecorator to customize template processing.
      Parameters:
      decorator - the decorator function; must not be null.
      Returns:
      this builder.
    • connectionProvider

      public ORMTemplate.Builder connectionProvider(st.orm.core.spi.ConnectionProvider connectionProvider)
      Sets the connection provider used by the template to acquire and release connections.

      Only valid for data source backed templates; build() fails fast otherwise.

      Parameters:
      connectionProvider - the connection provider; must not be null.
      Returns:
      this builder.
    • manualCommitConnections

      public ORMTemplate.Builder manualCommitConnections()
      Declares that the data source hands out connections with auto-commit disabled.

      The declared mode is verified in both directions: a declared template that receives an auto-commit connection fails fast naming the misdeclaration, exactly like an undeclared template that receives a manual-commit one. With the declaration in place, the transactional path performs no auto-commit flips and releases connections in their arrived state; non-transactional connections get auto-commit enabled while Storm uses them and restored before release, so each statement still commits.

      Cannot be combined with a custom connection provider and only valid for data source backed templates; build() fails fast otherwise.

      Returns:
      this builder.
      Since:
      1.14
    • transactionTemplateProvider

      public ORMTemplate.Builder transactionTemplateProvider(st.orm.core.spi.TransactionTemplateProvider transactionTemplateProvider)
      Sets the transaction template provider used by the template to participate in transactions.

      Templates that should share transactions must be configured with the same provider instance.

      Parameters:
      transactionTemplateProvider - the transaction template provider; must not be null.
      Returns:
      this builder.
    • exceptionMapper

      public ORMTemplate.Builder exceptionMapper(st.orm.core.spi.ExceptionMapper exceptionMapper)
      Sets the exception mapper that maps failures raised during query execution to the runtime exception thrown to the caller.
      Parameters:
      exceptionMapper - the exception mapper; must not be null.
      Returns:
      this builder.
    • queryObserver

      public ORMTemplate.Builder queryObserver(st.orm.core.spi.QueryObserver queryObserver)
      Sets the query observer that is notified of query executions performed by the template.
      Parameters:
      queryObserver - the query observer; must not be null.
      Returns:
      this builder.
    • sqlCommenter

      public ORMTemplate.Builder sqlCommenter(st.orm.core.spi.SqlCommenter sqlCommenter)
      Sets the SQL commenter that appends per-execution comment content to statements, such as the current trace context. Note that per-execution content defeats prepared statement caching.
      Parameters:
      sqlCommenter - the SQL commenter; must not be null.
      Returns:
      this builder.
      Since:
      1.13
    • build

      public ORMTemplate build()
      Builds the ORM template.
      Returns:
      the ORM template.