@Override
  public void addChargePoint(List<String> chargeBoxIdList) {
    BatchBindStep batch = ctx.batch(ctx.insertInto(CHARGE_BOX).set(CHARGE_BOX.CHARGE_BOX_ID, ""));

    for (String s : chargeBoxIdList) {
      batch.bind(s);
    }

    batch.execute();
  }
示例#2
0
  private final int[] executePrepared() {
    Map<String, List<Query>> queries = new LinkedHashMap<String, List<Query>>();
    QueryCollector collector = new QueryCollector();

    // Add the QueryCollector to intercept query execution after rendering
    Configuration local =
        configuration.derive(
            Utils.combine(
                configuration.executeListenerProviders(),
                new DefaultExecuteListenerProvider(collector)));

    // [#1537] Communicate with UpdatableRecordImpl
    local.data(Utils.DATA_OMIT_RETURNING_CLAUSE, true);

    // [#1529] Avoid DEBUG logging of single INSERT / UPDATE statements
    local.settings().setExecuteLogging(false);

    for (int i = 0; i < records.length; i++) {
      Configuration previous = ((AttachableInternal) records[i]).configuration();

      try {
        records[i].attach(local);
        executeAction(i);
      } catch (QueryCollectorSignal e) {
        Query query = e.getQuery();
        String sql = e.getSQL();

        // Aggregate executable queries by identical SQL
        if (query.isExecutable()) {
          List<Query> list = queries.get(sql);

          if (list == null) {
            list = new ArrayList<Query>();
            queries.put(sql, list);
          }

          list.add(query);
        }
      } finally {
        records[i].attach(previous);
      }
    }

    // Execute one batch statement for each identical SQL statement. Every
    // SQL statement may have several queries with different bind values.
    // The order is preserved as much as possible
    List<Integer> result = new ArrayList<Integer>();
    for (Entry<String, List<Query>> entry : queries.entrySet()) {
      BatchBindStep batch = create.batch(entry.getValue().get(0));

      for (Query query : entry.getValue()) {
        batch.bind(query.getBindValues().toArray());
      }

      int[] array = batch.execute();
      for (int i : array) {
        result.add(i);
      }
    }

    int[] array = new int[result.size()];
    for (int i = 0; i < result.size(); i++) {
      array[i] = result.get(i);
    }

    updateChangedFlag();
    return array;
  }