当前位置: 首页>>代码示例>>Java>>正文


Java Query.bind方法代码示例

本文整理汇总了Java中org.skife.jdbi.v2.Query.bind方法的典型用法代码示例。如果您正苦于以下问题:Java Query.bind方法的具体用法?Java Query.bind怎么用?Java Query.bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.skife.jdbi.v2.Query的用法示例。


在下文中一共展示了Query.bind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: bindDimensionsToQuery

import org.skife.jdbi.v2.Query; //导入方法依赖的package包/类
static void bindDimensionsToQuery(Query<?> query, Map<String, String> dimensions) {
  if (dimensions != null) {
    int i = 0;
    for (Iterator<Map.Entry<String, String>> it = dimensions.entrySet().iterator(); it.hasNext(); i++) {
      Map.Entry<String, String> entry = it.next();
      query.bind("dname" + i, entry.getKey());
      if (!Strings.isNullOrEmpty(entry.getValue())) {
        List<String> values = BAR_SPLITTER.splitToList(entry.getValue());
        if (values.size() > 1) {
          for (int j = 0; j < values.size(); j++) {
            query.bind("dvalue" + i + '_' + j, values.get(j));
          }
        }
        else {
          query.bind("dvalue" + i, entry.getValue());
        }
      }
    }
  }
}
 
开发者ID:openstack,项目名称:monasca-api,代码行数:21,代码来源:MetricQueries.java

示例2: bindDimensionsToQuery

import org.skife.jdbi.v2.Query; //导入方法依赖的package包/类
public static void bindDimensionsToQuery(
    Query<?> query,
    Map<String, String> dimensions) {

  if (dimensions != null) {
    int i = 0;
    for (Iterator<Map.Entry<String, String>> it = dimensions.entrySet().iterator(); it.hasNext(); i++) {
      Map.Entry<String, String> entry = it.next();
      query.bind("dname" + i, entry.getKey());
      if (!Strings.isNullOrEmpty(entry.getValue())) {
        List<String> values = Splitter.on('|').splitToList(entry.getValue());
        int j = 0;
        for (String value : values) {
          query.bind("dvalue" + i + '_' + j, value);
          j++;
        }
      }
    }
  }
}
 
开发者ID:openstack,项目名称:monasca-api,代码行数:21,代码来源:DimensionQueries.java

示例3: findById

import org.skife.jdbi.v2.Query; //导入方法依赖的package包/类
@Override
public AlarmDefinition findById(String tenantId, String alarmDefId) {

  try (Handle h = db.open()) {
    String query = "SELECT alarm_definition.id, alarm_definition.tenant_id, alarm_definition.name, alarm_definition.description, "
        + "alarm_definition.expression, alarm_definition.severity, alarm_definition.match_by, alarm_definition.actions_enabled, "
        +" alarm_definition.created_at, alarm_definition.updated_at, alarm_definition.deleted_at, "
        + "GROUP_CONCAT(alarm_action.action_id) AS notificationIds,group_concat(alarm_action.alarm_state) AS states "
        + "FROM alarm_definition LEFT OUTER JOIN alarm_action ON alarm_definition.id=alarm_action.alarm_definition_id "
        + " WHERE alarm_definition.tenant_id=:tenantId AND alarm_definition.id=:alarmDefId AND alarm_definition.deleted_at "
        + " IS NULL GROUP BY alarm_definition.id";

    Query<?> q = h.createQuery(query);
    q.bind("tenantId", tenantId);
    q.bind("alarmDefId", alarmDefId);

    q.registerMapper(new AlarmDefinitionMapper());
    q = q.mapTo(AlarmDefinition.class);
    AlarmDefinition alarmDefinition = (AlarmDefinition) q.first();
   if(alarmDefinition == null)
   {
     throw new EntityNotFoundException("No alarm definition exists for %s", alarmDefId);
   }
    return alarmDefinition;
  }
}
 
开发者ID:openstack,项目名称:monasca-api,代码行数:27,代码来源:AlarmDefinitionMySqlRepoImpl.java

示例4: getTaskIdHistoryCount

import org.skife.jdbi.v2.Query; //导入方法依赖的package包/类
public int getTaskIdHistoryCount(Optional<String> requestId, Optional<String> deployId, Optional<String> runId, Optional<String> host,
    Optional<ExtendedTaskState> lastTaskStatus, Optional<Long> startedBefore, Optional<Long> startedAfter, Optional<Long> updatedBefore,
    Optional<Long> updatedAfter) {

  final Map<String, Object> binds = new HashMap<>();
  final StringBuilder sqlBuilder = new StringBuilder(GET_TASK_ID_HISTORY_COUNT_QUERY);

  applyTaskIdHistoryBaseQuery(sqlBuilder, binds, requestId, deployId, runId, host, lastTaskStatus, startedBefore, startedAfter, updatedBefore, updatedAfter);

  final String sql = sqlBuilder.toString();

  LOG.trace("Generated sql for task search count: {}, binds: {}", sql, binds);

  final Query<Integer> query = getHandle().createQuery(sql).mapTo(Integer.class);
  for (Map.Entry<String, Object> entry : binds.entrySet()) {
    query.bind(entry.getKey(), entry.getValue());
  }

  return query.first();
}
 
开发者ID:HubSpot,项目名称:Singularity,代码行数:21,代码来源:HistoryJDBI.java

示例5: getLogs

import org.skife.jdbi.v2.Query; //导入方法依赖的package包/类
@JsonRequest
@ApiOperation(value = "Get logs", authorizations = @Authorization(value = "master_key"))
@Path("/get_logs")
public List<LogEntry> getLogs(@Named("project") RequestContext context, @ApiParam(value = "start", required = false) Instant start, @ApiParam(value = "end", required = false) Instant end, @ApiParam(value = "prefix") String prefix) {
    String sql = "SELECT id, type, error, created FROM javascript_logs WHERE project = :project AND prefix = :prefix";
    if (start != null) {
        sql += " AND created > :start";
    }
    if (end != null) {
        sql += " AND created < :end";
    }

    sql += " ORDER BY created DESC";

    try (Handle handle = dbi.open()) {
        Query<Map<String, Object>> query = handle.createQuery(sql + " LIMIT 100");
        query.bind("project", context.project);
        query.bind("prefix", prefix);

        if (start != null) {
            query.bind("start", start.toEpochMilli());
        }
        if (end != null) {
            query.bind("end", end.toEpochMilli());
        }

        return query.map((index, r, ctx) -> {
            return new LogEntry(r.getString(1), Level.valueOf(r.getString(2)), r.getString(3), Instant.ofEpochMilli(r.getLong(4)));
        }).list();
    }
}
 
开发者ID:rakam-io,项目名称:rakam,代码行数:32,代码来源:JSCodeJDBCLoggerService.java

示例6: bindOffsetToQuery

import org.skife.jdbi.v2.Query; //导入方法依赖的package包/类
static void bindOffsetToQuery(Query<Map<String, Object>> query, String offset) {
  List<String> offsets =  UNDERSCORE_SPLITTER.splitToList(offset);
  if (offsets.size() > 1) {
    query.bind("offset_id", offsets.get(0));
    query.bind("offset_timestamp",
               new Timestamp(DateTime.parse(offsets.get(1)).getMillis()));
  } else {
    query.bind("offset_timestamp",
               new Timestamp(DateTime.parse(offsets.get(0)).getMillis()));
  }
}
 
开发者ID:openstack,项目名称:monasca-api,代码行数:12,代码来源:MetricQueries.java

示例7: checkForMultipleDefinitions

import org.skife.jdbi.v2.Query; //导入方法依赖的package包/类
static void checkForMultipleDefinitions(Handle h, String tenantId, String name, Map<String, String> dimensions)
    throws MultipleMetricsException {

  String namePart = "";
  if (name != null && !name.isEmpty()) {
    namePart = "AND name = :name ";
  }

  String sql = String.format(METRIC_DEF_SUB_SQL,
                             "",
                             namePart,
                             buildDimensionAndClause(dimensions,
                                               TABLE_TO_JOIN_ON),
                             "") + " limit 2";

  Query<Map<String, Object>> query = h.createQuery(sql);

  query.bind("tenantId", tenantId);

  if (name != null) {
    query.bind("name", name);
  }

  bindDimensionsToQuery(query, dimensions);

  List<Map<String, Object>> rows = query.list();

  if (rows.size() > 1) {
    throw new MultipleMetricsException(name, dimensions);
  }
}
 
开发者ID:openstack,项目名称:monasca-api,代码行数:32,代码来源:MetricQueries.java

示例8: bindGroupBy

import org.skife.jdbi.v2.Query; //导入方法依赖的package包/类
static void bindGroupBy(Query<Map<String, Object>> query, List<String> groupBy) {
  int i = 0;
  for (String value: groupBy) {
    query.bind("groupBy" + i, value);
    i++;
  }
}
 
开发者ID:openstack,项目名称:monasca-api,代码行数:8,代码来源:MetricQueries.java

示例9: bindDimensionsToQuery

import org.skife.jdbi.v2.Query; //导入方法依赖的package包/类
public static void bindDimensionsToQuery(Query query, Map<String, String> dimensions) {
  if (dimensions != null) {
    int i = 0;
    for (Map.Entry<String, String> entry: dimensions.entrySet()) {
      query.bind("dname" + i, entry.getKey());
      query.bind("dvalue" + i, entry.getValue());
      i++;
    }
  }
}
 
开发者ID:openstack,项目名称:monasca-api,代码行数:11,代码来源:SubAlarmDefinitionQueries.java

示例10: bindDimensionsToQuery

import org.skife.jdbi.v2.Query; //导入方法依赖的package包/类
private void bindDimensionsToQuery(Query query, Map<String, String> dimensions) {
  if (dimensions != null) {
    int i = 0;
    for (Map.Entry<String, String> entry : dimensions.entrySet()) {
      query.bind("dname" + i, entry.getKey());
      query.bind("dvalue" + i, entry.getValue());
      i++;
    }
  }
}
 
开发者ID:openstack,项目名称:monasca-api,代码行数:11,代码来源:MySQLUtils.java

示例11: bindSeverityToQuery

import org.skife.jdbi.v2.Query; //导入方法依赖的package包/类
public static void bindSeverityToQuery(Query query, List<AlarmSeverity> severities) {
  if (severities != null && !severities.isEmpty()) {
    for (int i = 0; i < severities.size(); i++) {
      query.bind("severity" + String.valueOf(i), severities.get(i).name());
    }
  }
}
 
开发者ID:openstack,项目名称:monasca-api,代码行数:8,代码来源:MySQLUtils.java

示例12: keyValuesFor

import org.skife.jdbi.v2.Query; //导入方法依赖的package包/类
/**
 * Returns a map of key/value pairs for the given {@code keyValueSelectingSql} with the
 * {@code orderedParameters}.
 * 
 * @param handle to execute statement against
 * @param keyValueSelectingSql statement that selects a key and value
 * @param orderedParameters ordered parameters to set against the {@code keyValueSelectingSql}
 * @return a map of key value pairs
 */
public static Map<String, String> keyValuesFor(Handle handle, String keyValueSelectingSql,
    Object... orderedParameters) {
  Query<Map<String, Object>> q = handle.createQuery(keyValueSelectingSql);
  for (int i = 0; i < orderedParameters.length; i++)
    q.bind(i, orderedParameters[i]);

  KeyValueMapper mapper = new KeyValueMapper();
  Iterator<Object> it = q.map(mapper).iterator();
  while (it.hasNext())
    it.next();

  return mapper.map;
}
 
开发者ID:openstack,项目名称:monasca-common,代码行数:23,代码来源:SqlQueries.java

示例13: getTaskIdHistory

import org.skife.jdbi.v2.Query; //导入方法依赖的package包/类
public List<SingularityTaskIdHistory> getTaskIdHistory(Optional<String> requestId, Optional<String> deployId, Optional<String> runId, Optional<String> host,
    Optional<ExtendedTaskState> lastTaskStatus, Optional<Long> startedBefore, Optional<Long> startedAfter, Optional<Long> updatedBefore,
    Optional<Long> updatedAfter, Optional<OrderDirection> orderDirection, Optional<Integer> limitStart, Integer limitCount) {

  final Map<String, Object> binds = new HashMap<>();
  final StringBuilder sqlBuilder = new StringBuilder(GET_TASK_ID_HISTORY_QUERY);

  applyTaskIdHistoryBaseQuery(sqlBuilder, binds, requestId, deployId, runId, host, lastTaskStatus, startedBefore, startedAfter, updatedBefore, updatedAfter);

  sqlBuilder.append(" ORDER BY startedAt ");
  sqlBuilder.append(orderDirection.or(OrderDirection.DESC).name());

  if (!requestId.isPresent()) {
    sqlBuilder.append(", requestId ");
    sqlBuilder.append(orderDirection.or(OrderDirection.DESC).name());
  }

  if (limitStart.isPresent()) {
    sqlBuilder.append(" LIMIT :limitStart, ");
    binds.put("limitStart", limitStart.get());
  } else {
    sqlBuilder.append(" LIMIT ");
  }

  sqlBuilder.append(":limitCount");
  binds.put("limitCount", limitCount);

  final String sql = sqlBuilder.toString();

  LOG.trace("Generated sql for task search: {}, binds: {}", sql, binds);

  final Query<SingularityTaskIdHistory> query = getHandle().createQuery(sql).mapTo(SingularityTaskIdHistory.class);
  for (Map.Entry<String, Object> entry : binds.entrySet()) {
    query.bind(entry.getKey(), entry.getValue());
  }

  return query.list();
}
 
开发者ID:HubSpot,项目名称:Singularity,代码行数:39,代码来源:HistoryJDBI.java

示例14: query

import org.skife.jdbi.v2.Query; //导入方法依赖的package包/类
public Query query(Handle h){
    Query q = h.createQuery(sql());
    for (int i=0; i< workProperties.size(); i++){
        q.bind(i, workProperties.get(i).getValue());
    }
    return q.map(LongMapper.FIRST);
}
 
开发者ID:nla,项目名称:amberdb,代码行数:8,代码来源:PropertyQueryAssembler.java

示例15: addSummary

import org.skife.jdbi.v2.Query; //导入方法依赖的package包/类
private void addSummary(Query query, Long id, List<WorkSummary> summaries, int currentDepth, int maxDepth) {
    query.bind("id", id);

    Map<String, Object> work = (Map<String, Object>) query.first();

    if (work != null) {
        WorkSummary summary = new WorkSummary();
        summary.setId(id);
        summary.setParentId((Long) work.get("parentId"));
        summary.setTitle((String) work.get("title"));
        summary.setCollectionCode((String) work.get("collection"));
        summary.setForm((String) work.get("form"));
        summary.setCreator((String) work.get("creator"));
        summary.setAccessConditions((String) work.get("accessConditions"));
        summary.setInternalAccessConditions((String) work.get("internalAccessConditions"));
        summary.setDigitalStatus((String) work.get("digitalStatus"));
        summary.setDigitalStatusDate((Date) work.get("digitalStatusDate"));
        summary.setDateCreated((Date) work.get("dateCreated"));
        summary.setRecordSource((String) work.get("recordSource"));
        summary.setLocalSystemNumber((String) work.get("localSystemNumber"));
        summary.setBibLevel((String) work.get("bibLevel"));
        summary.setBibId((String) work.get("bibId"));
        summary.setSubUnitType((String) work.get("subUnitType"));
        summary.setSubUnitNumber((String) work.get("subUnitNo"));
        summary.setSensitiveMaterial((String) work.get("sensitiveMaterial"));
        summary.setObjectId(PIUtil.format((Long) work.get("childId")));

        summaries.add(summary);

        if (summary.getParentId() != null && currentDepth < maxDepth) {
            addSummary(query, summary.getParentId(), summaries, currentDepth + 1, maxDepth);
        }
    }
}
 
开发者ID:nla,项目名称:amberdb,代码行数:35,代码来源:AmberSession.java


注:本文中的org.skife.jdbi.v2.Query.bind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。