Examples of Upsert


Examples of org.sonar.server.db.migrations.Upsert

          public ActiveRule read(Select.Row row) throws SQLException {
            return new ActiveRule(row.getLong(1), row.getLong(2));
          }
        });

      Upsert upsert = context.prepareUpsert("insert into active_rule_parameters(active_rule_id, rules_parameter_id, value, rules_parameter_key) values (?, ?, ?, ?)");
      for (ActiveRule activeRule : activeRules) {
        upsert
          .setLong(1, activeRule.id)
          .setLong(2, ruleParameter.id)
          .setString(3, ruleParameter.defaultValue)
          .setString(4, ruleParameter.name)
          .addBatch();
      }
      if (!activeRules.isEmpty()) {
        upsert.execute().commit().close();
      }

      // update date for ES indexation
      upsert = context.prepareUpsert("update active_rules set updated_at=? where id=?");
      Date now = new Date(system.now());
      for (ActiveRule activeRule : activeRules) {
        upsert
          .setDate(1, now)
          .setLong(2, activeRule.id)
          .addBatch();
      }
      if (!activeRules.isEmpty()) {
        upsert.execute().commit().close();
      }
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.