@Override public void delete(final String id) { session.execute(new BoundStatement(deleteSQL.apply(tableName)).bind(id)); }
@Override public void save(final Session session) { this.session.execute(new BoundStatement(insertSQL.apply(tableName)) .bind( session.id(), new Date(session.createdAt()), new Date(session.accessedAt()), new Date(session.savedAt()), session.attributes())); }
@Override public Session get(final Builder builder) { ResultSet rs = session .execute(new BoundStatement(selectSQL.apply(tableName)).bind(builder.sessionId())); return Optional.ofNullable(rs.one()) .map(row -> { long createdAt = row.getTimestamp(CREATED_AT).getTime(); long accessedAt = row.getTimestamp(ACCESSED_AT).getTime(); long savedAt = row.getTimestamp(SAVED_AT).getTime(); Map<String, String> attributes = row.getMap(ATTRIBUTES, String.class, String.class); Session session = builder .accessedAt(accessedAt) .createdAt(createdAt) .savedAt(savedAt) .set(attributes) .build(); // touch ttl if (timeout > 0) { save(session); } return session; }) .orElse(null); }
@Override public BoundStatement bind(Object... values) { BoundStatement bs = new BoundStatement(this); return bs.bind(values); }
PreparedStatement statement = getSession().prepare( "INSERT INTO pixelstore.image " + "(image_name, " + " upload_time, " + " upload_by, " + " file_type, " + " file_size" + ") VALUES (?, ?, ?, ?, ?);"); // create the bound statement and initialise it with your prepared statement BoundStatement boundStatement = new BoundStatement(statement); session.execute( // this is where the query is executed boundStatement.bind( // here you are binding the 'boundStatement' "background", TimeUtil.getTimeUUID(), "lyubent", "png", "130527"));
BoundStatement q = new BoundStatement(stmt).bind(paramterValues); execute(q, event); if (counterTable) {
ByteBuffer buffer =ByteBuffer.wrap(b); .... // image is of type blob PreparedStatement ps = session.prepare("insert into Messages (image, user, interaction_time,imagelength) values(?,?,?,?)"); BoundStatement boundStatement = new BoundStatement(ps); session.execute(boundStatement.bind(buffer, "Andy", convertor.getTimeUUID(),length));
public List<Token> getByPrincipalForTrustedConsumers(String principal) { return session .execute(stmtGetByPrincipal.get().bind(principal)) .all() .stream() .map(this::getFullTokenFromRow) .collect(Collectors.toList()); }
@Override public BoundStatement bind(Object... values) { BoundStatement bs = new BoundStatement(this); return bs.bind(values); }
private BoundStatement getSelectStatement(String entityId, String startKey) { BoundStatement stmt; if (StringUtils.isEmpty(startKey)) { stmt = new BoundStatement(selectStatement).bind(entityId); } else { stmt = new BoundStatement(selectDateStatement).bind(entityId, Long.valueOf(startKey.split(FIELD_SEPARATOR)[1])); } return stmt; }
@Override public BoundStatement bind(Object... values) { BoundStatement bs = new BoundStatement(this); return bs.bind(values); }
public List<Token> getByPrincipalForDistribution(String principal) { return session .execute(stmtGetByPrincipal.get().bind(principal)) .all() .stream() .map(this::getSecureTokenFromRow) .collect(Collectors.toList()); }
@Override public void denyAll(String resource) { final BoundStatement denyStatement = new BoundStatement(getStatement(StatementName.DENY)); denyStatement.bind(resource, "*"); session.execute(denyStatement); }
@Override public void permit(K key, String resource) { final BoundStatement permitStatement = new BoundStatement(getStatement(StatementName.PERMIT)); permitStatement.bind(resource, (key == null) ? "" : key.getKey()); session.execute(permitStatement); }
private void c2_clearDueSlotForTargetId(String targetId, long newDueSlot) throws PersistenceException { PreparedStatementCollection psc = this.getStatementCollection(newDueSlot); try { PreparedStatement ps = psc.createDueSlotForTargetId; BoundStatement boundStatement = new BoundStatement(ps); boundStatement.bind(targetId, 0L); ResultSet res = session.execute(boundStatement); } catch (Exception e1) { String msg = "Failed to execute clearDueSlotForTargetId() !"; throw new PersistenceException(msg, e1); } }
public void c2_updateAlertingSupport(long dueSlot, String targetId, UUID dbId) throws PersistenceException { PreparedStatementCollection psc = this.getStatementCollection(dueSlot); try { PreparedStatement ps = psc.updateAlertingSupport; BoundStatement boundStatement = new BoundStatement(ps); boundStatement.bind(true, dueSlot, targetId, dbId); ResultSet res = session.execute(boundStatement); } catch (Exception e1) { String msg = "Failed to execute c2_updateAlertingSupport() !"; throw new PersistenceException(msg, e1); } }
@Override public void save(final Session session) { this.session.execute(new BoundStatement(insertSQL.apply(tableName)) .bind( session.id(), new Date(session.createdAt()), new Date(session.accessedAt()), new Date(session.savedAt()), session.attributes())); }
private Long fetchKeyTokenFromDB(Object keyValue) { PreparedStatement statement = store.getSession().prepare(tokenQuery); BoundStatement boundStatement = new BoundStatement(statement); boundStatement.bind(keyValue); ResultSet rs = store.getSession().execute(boundStatement); Long keyTokenValue = rs.one().getLong(0); return keyTokenValue; }
@Override public void putEventsV1(List<EntityAuditEvent> events) throws AtlasException { BoundStatement stmt = new BoundStatement(insertStatement); BatchStatement batch = new BatchStatement(); events.forEach(event -> batch.add(stmt.bind(event.getEntityId(), event.getTimestamp(), event.getAction().toString(), event.getUser(), event.getDetails(), (persistEntityDefinition ? event.getEntityDefinitionString() : null)))); cassSession.execute(batch); }
@Override public void putEventsV2(List<EntityAuditEventV2> events) throws AtlasBaseException { BoundStatement stmt = new BoundStatement(insertStatement); BatchStatement batch = new BatchStatement(); events.forEach(event -> batch.add(stmt.bind(event.getEntityId(), event.getTimestamp(), event.getAction().toString(), event.getUser(), event.getDetails(), (persistEntityDefinition ? event.getEntity().toString() : null)))); cassSession.execute(batch); }