@Override
  public SQLAction batchAction(BatchQuery query) {
    // check run strategy...

    // optimistic locking is not supported in batches due to JDBC driver limitations
    boolean useOptimisticLock = query.isUsingOptimisticLocking();

    boolean runningAsBatch = !useOptimisticLock && dataNode.getAdapter().supportsBatchUpdates();
    return new PostgresBatchAction(query, dataNode, runningAsBatch);
  }
  public String createLOBSelectString(
      BatchQuery updateQuery, List selectedLOBAttributes, List qualifierAttributes) {

    boolean status;
    if (updateQuery.getDbEntity().getDataMap() != null
        && updateQuery.getDbEntity().getDataMap().isQuotingSQLIdentifiers()) {
      status = true;
    } else {
      status = false;
    }
    QuotingStrategy strategy = getAdapter().getQuotingStrategy(status);

    StringBuffer buf = new StringBuffer();
    buf.append("SELECT ");

    Iterator it = selectedLOBAttributes.iterator();
    while (it.hasNext()) {
      buf.append(strategy.quoteString(((DbAttribute) it.next()).getName()));

      if (it.hasNext()) {
        buf.append(", ");
      }
    }

    buf.append(" FROM ")
        .append(strategy.quoteFullyQualifiedName(updateQuery.getDbEntity()))
        .append(" WHERE ");

    it = qualifierAttributes.iterator();
    while (it.hasNext()) {
      DbAttribute attribute = (DbAttribute) it.next();
      appendDbAttribute(buf, attribute);
      buf.append(" = ?");
      if (it.hasNext()) {
        buf.append(" AND ");
      }
    }

    buf.append(" FOR UPDATE");
    return buf.toString();
  }
  /** Binds BatchQuery parameters to the PreparedStatement. */
  @Override
  public void bindParameters(PreparedStatement statement, BatchQuery query)
      throws SQLException, Exception {

    List<DbAttribute> dbAttributes = query.getDbAttributes();
    int attributeCount = dbAttributes.size();

    // i - attribute position in the query
    // j - PreparedStatement parameter position (starts with "1")
    for (int i = 0, j = 1; i < attributeCount; i++) {
      Object value = query.getValue(i);
      DbAttribute attribute = dbAttributes.get(i);
      int type = attribute.getType();

      // TODO: (Andrus) This works as long as there is no LOBs in qualifier
      if (isUpdateableColumn(value, type)) {
        adapter.bindParameter(statement, value, j, type, attribute.getScale());

        j++;
      }
    }
  }