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); }
private List<Object> bindPrimaryKey( Object primaryKey, PropertyMeta idMeta, boolean onlyStaticColumns) { List<Object> values = new ArrayList<>(); if (idMeta.structure().isEmbeddedId()) { values.addAll(idMeta.forTranscoding().encodeToComponents(primaryKey, onlyStaticColumns)); } else { values.add(idMeta.forTranscoding().encodeToCassandra(primaryKey)); } return values; }