コード例 #1
0
  public BoundStatementWrapper bindForClusteredCounterSelect(
      PersistentStateHolder context,
      PreparedStatement ps,
      boolean onlyStaticColumns,
      ConsistencyLevel consistencyLevel) {
    EntityMeta entityMeta = context.getEntityMeta();
    Object primaryKey = context.getPrimaryKey();

    log.trace(
        "Bind prepared statement {} for clustered counter read for {} using primary key {}",
        ps.getQueryString(),
        entityMeta,
        primaryKey);

    List<Object> primaryKeys =
        bindPrimaryKey(primaryKey, entityMeta.getIdMeta(), onlyStaticColumns);
    Object[] boundValues = primaryKeys.toArray();

    BoundStatement bs = ps.bind(boundValues);
    return new BoundStatementWrapper(
        context.getEntityClass(),
        bs,
        boundValues,
        getCQLLevel(consistencyLevel),
        NO_LISTENER,
        NO_SERIAL_CONSISTENCY);
  }
コード例 #2
0
  public BoundStatementWrapper bindForClusteredCounterIncrementDecrement(
      PersistentStateHolder context,
      PreparedStatement ps,
      PropertyMeta counterMeta,
      Long increment) {

    EntityMeta entityMeta = context.getEntityMeta();
    Object primaryKey = context.getPrimaryKey();

    log.trace(
        "Bind prepared statement {} for clustered counter increment/decrement for {} using primary key {} and value {}",
        ps.getQueryString(),
        entityMeta,
        primaryKey,
        increment);

    ConsistencyLevel consistencyLevel = overrider.getWriteLevel(context);

    List<Object> primaryKeys =
        bindPrimaryKey(
            primaryKey, entityMeta.getIdMeta(), counterMeta.structure().isStaticColumn());
    Object[] keys = addAll(new Object[] {increment}, primaryKeys.toArray());

    BoundStatement bs = ps.bind(keys);

    return new BoundStatementWrapper(
        context.getEntityClass(),
        bs,
        keys,
        getCQLLevel(consistencyLevel),
        NO_LISTENER,
        NO_SERIAL_CONSISTENCY);
  }
コード例 #3
0
  public BoundStatementWrapper bindForSimpleCounterIncrementDecrement(
      PersistentStateHolder context,
      PreparedStatement ps,
      PropertyMeta pm,
      Long increment,
      ConsistencyLevel consistencyLevel) {

    EntityMeta entityMeta = context.getEntityMeta();
    Object primaryKey = context.getPrimaryKey();

    log.trace(
        "Bind prepared statement {} for simple counter increment of {} using primary key {} and value {}",
        ps.getQueryString(),
        pm,
        primaryKey,
        increment);
    Object[] boundValues =
        ArrayUtils.add(
            extractValuesForSimpleCounterBinding(entityMeta, pm, primaryKey), 0, increment);

    BoundStatement bs = ps.bind(boundValues);
    return new BoundStatementWrapper(
        context.getEntityClass(),
        bs,
        boundValues,
        getCQLLevel(consistencyLevel),
        NO_LISTENER,
        NO_SERIAL_CONSISTENCY);
  }
コード例 #4
0
  public BoundStatementWrapper bindStatementWithOnlyPKInWhereClause(
      PersistentStateHolder context,
      PreparedStatement ps,
      boolean onlyStaticColumns,
      ConsistencyLevel consistencyLevel) {

    Object primaryKey = context.getPrimaryKey();

    log.trace("Bind prepared statement {} with primary key {}", ps.getQueryString(), primaryKey);

    PropertyMeta idMeta = context.getIdMeta();
    List<Object> values = bindPrimaryKey(primaryKey, idMeta, onlyStaticColumns);

    BoundStatement bs = ps.bind(values.toArray());
    return new BoundStatementWrapper(
        context.getEntityClass(),
        bs,
        values.toArray(),
        getCQLLevel(consistencyLevel),
        context.getCASResultListener(),
        context.getSerialConsistencyLevel());
  }
コード例 #5
0
  public BoundStatementWrapper bindForSimpleCounterDelete(
      PersistentStateHolder context, PreparedStatement ps, PropertyMeta pm) {
    EntityMeta entityMeta = context.getEntityMeta();
    Object primaryKey = context.getPrimaryKey();

    log.trace(
        "Bind prepared statement {} for simple counter delete for {} using primary key {}",
        ps.getQueryString(),
        pm,
        primaryKey);

    ConsistencyLevel consistencyLevel = overrider.getWriteLevel(context);

    Object[] boundValues = extractValuesForSimpleCounterBinding(entityMeta, pm, primaryKey);
    BoundStatement bs = ps.bind(boundValues);
    return new BoundStatementWrapper(
        context.getEntityClass(),
        bs,
        boundValues,
        getCQLLevel(consistencyLevel),
        NO_LISTENER,
        NO_SERIAL_CONSISTENCY);
  }
コード例 #6
0
  public BoundStatementWrapper bindForClusteredCounterDelete(
      PersistentStateHolder context, PreparedStatement ps) {
    EntityMeta entityMeta = context.getEntityMeta();
    Object primaryKey = context.getPrimaryKey();

    log.trace(
        "Bind prepared statement {} for simple counter delete for {} using primary key {}",
        ps.getQueryString(),
        entityMeta,
        primaryKey);

    ConsistencyLevel consistencyLevel = overrider.getWriteLevel(context);
    List<Object> primaryKeys = bindPrimaryKey(primaryKey, entityMeta.getIdMeta(), false);
    Object[] boundValues = primaryKeys.toArray(new Object[primaryKeys.size()]);
    BoundStatement bs = ps.bind(boundValues);

    return new BoundStatementWrapper(
        context.getEntityClass(),
        bs,
        boundValues,
        getCQLLevel(consistencyLevel),
        NO_LISTENER,
        NO_SERIAL_CONSISTENCY);
  }