org.apache.cayenne.access.translator.batch

## Class DefaultBatchTranslator

- java.lang.Object
- - org.apache.cayenne.access.translator.batch.DefaultBatchTranslator

- All Implemented Interfaces:
    BatchTranslator
  Direct Known Subclasses:
    DeleteBatchTranslator, InsertBatchTranslator, UpdateBatchTranslator

      public abstract class DefaultBatchTranslator
      extends Object
      implements BatchTranslator

  Superclass of batch query translators.
  Since:
    4.0

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected DbAdapter` | `adapter`
    `protected DbAttributeBinding[]` | `bindings`
    `protected BatchQuery` | `query`
    `protected String` | `sql`
    `protected boolean` | `translated`
    `protected String` | `trimFunction`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultBatchTranslator(BatchQuery query, DbAdapter adapter, String trimFunction)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `appendDbAttribute(StringBuilder buf, DbAttribute dbAttribute)` Appends the name of the column to the query buffer.
    `protected abstract DbAttributeBinding[]` | `createBindings()`
    `protected abstract String` | `createSql()`
    `protected abstract DbAttributeBinding[]` | `doUpdateBindings(BatchQueryRow row)`
    `protected void` | `ensureTranslated()`
    `DbAttributeBinding[]` | `getBindings()` Returns the widest possible array of bindings for this query.
    `String` | `getSql()` Translates BatchQuery into an SQL string formatted to use in a PreparedStatement.
    `DbAttributeBinding[]` | `updateBindings(BatchQueryRow row)` Updates internal bindings to be used with a given row, returning updated bindings array.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### query

          protected BatchQuery query

    - #### adapter

          protected DbAdapter adapter

    - #### trimFunction

          protected String trimFunction

    - #### translated

          protected boolean translated

    - #### sql

          protected String sql

    - #### bindings

          protected DbAttributeBinding[] bindings

  - ### Constructor Detail

    - #### DefaultBatchTranslator

          public DefaultBatchTranslator(BatchQuery query,
                                        DbAdapter adapter,
                                        String trimFunction)

  - ### Method Detail

    - #### ensureTranslated

          protected void ensureTranslated()

    - #### getSql

          public String getSql()

      Translates BatchQuery into an SQL string formatted to use in a PreparedStatement.
      Specified by:
        `getSql` in interface `BatchTranslator`

    - #### getBindings

          public DbAttributeBinding[] getBindings()

      Description copied from interface: `BatchTranslator`
      Returns the widest possible array of bindings for this query.
      Specified by:
        `getBindings` in interface `BatchTranslator`

    - #### updateBindings

          public DbAttributeBinding[] updateBindings(BatchQueryRow row)

      Description copied from interface: `BatchTranslator`
      Updates internal bindings to be used with a given row, returning updated bindings array. This method guarantees that the returned array contains the same bindings in the same order as in the array returned from `BatchTranslator.getBindings()` (but in a state corresponding to the 'row' parameter). Usually the returned array is actually the same object reused for every iteration, only with changed object state.
      Specified by:
        `updateBindings` in interface `BatchTranslator`

    - #### createSql

          protected abstract String createSql()

    - #### createBindings

          protected abstract DbAttributeBinding[] createBindings()

    - #### doUpdateBindings

          protected abstract DbAttributeBinding[] doUpdateBindings(BatchQueryRow row)

    - #### appendDbAttribute

          protected void appendDbAttribute(StringBuilder buf,
                                           DbAttribute dbAttribute)

      Appends the name of the column to the query buffer. Subclasses use this method to append column names in the WHERE clause, i.e. for the columns that are not being updated.

Copyright © 2001–2018 Apache Cayenne. All rights reserved.