@Override public QueryBinder<ENTITY> setUUID(int i, UUID v) { for (BoundStatement statement : statements.values()) { statement.setUUID(i, v); } return this; }
@Test(groups = "short") public void should_handle_udts_with_default_codecs() { setUpUserTypes(cluster()); // simple statement session().execute(insertQuery, uuid, "John Doe", addressValue); ResultSet rows = session().execute(selectQuery, uuid); Row row = rows.one(); assertRow(row); // prepared + values PreparedStatement ps = session().prepare(insertQuery); session().execute(ps.bind(uuid, "John Doe", addressValue)); rows = session().execute(selectQuery, uuid); row = rows.one(); assertRow(row); // bound with setUDTValue session() .execute(ps.bind().setUUID(0, uuid).setString(1, "John Doe").setUDTValue(2, addressValue)); rows = session().execute(selectQuery, uuid); row = rows.one(); assertRow(row); }
@Test(groups = "short") public void should_handle_partial_tuples_with_default_codecs() { setUpTupleTypes(cluster()); // simple statement session().execute(insertQuery, uuid, "John Doe", partialLocationValueInserted); ResultSet rows = session().execute(selectQuery, uuid); Row row = rows.one(); assertPartialRow(row); // prepared + values PreparedStatement ps = session().prepare(insertQuery); session().execute(ps.bind(uuid, "John Doe", partialLocationValueInserted)); rows = session().execute(selectQuery, uuid); row = rows.one(); assertPartialRow(row); // bound with setTupleValue session() .execute( ps.bind() .setUUID(0, uuid) .setString(1, "John Doe") .setTupleValue("location", partialLocationValueInserted)); rows = session().execute(selectQuery, uuid); row = rows.one(); assertPartialRow(row); }
@Test(groups = "short") public void should_handle_tuples_with_default_codecs() { setUpTupleTypes(cluster()); // simple statement session().execute(insertQuery, uuid, "John Doe", locationValue); ResultSet rows = session().execute(selectQuery, uuid); Row row = rows.one(); assertRow(row); // prepared + values PreparedStatement ps = session().prepare(insertQuery); session().execute(ps.bind(uuid, "John Doe", locationValue)); rows = session().execute(selectQuery, uuid); row = rows.one(); assertRow(row); // bound with setTupleValue session() .execute( ps.bind() .setUUID(0, uuid) .setString(1, "John Doe") .setTupleValue("location", locationValue)); rows = session().execute(selectQuery, uuid); row = rows.one(); assertRow(row); }
} else if (value.getValue() instanceof java.util.UUID) { if (value.isNamed()) boundStatement.setUUID(value.getName(), (java.util.UUID) value.getValue()); else boundStatement.setUUID(value.getIndex() - 1, (java.util.UUID) value.getValue()); } else if (value.getValue() instanceof List) { if (value.isNamed())
@Override public List<OrganizationJoinRequest> getAllRequestsForOrganization(Organization organization) { return getList( stmtListByOrganization .get() .setUUID("organization", organization.getIdAsUUID()) ); }
@Override public void remove(Invitation invitation) { BoundStatement stmtDelete = stmtDeleteInstance.get(); if (null != invitation) { stmtDelete.setUUID("id", invitation.getIdAsUUID()); session.execute(stmtDelete); logger.invitationRemoved(invitation.getId()); } }
public CompletableFuture<Collection<MessageId>> getOwnerMessageIds(AttachmentId attachmentId) { Preconditions.checkArgument(attachmentId != null); return cassandraAsyncExecutor.execute( selectStatement.bind() .setUUID(ATTACHMENT_ID_AS_UUID, attachmentId.asUUID())) .thenApply(resultSet -> cassandraUtils.convertToStream(resultSet) .map(this::rowToMessageId) .collect(Guavate.toImmutableSet())); }
@Override public PersonaResourceRole create(Persona persona, Resource resource, Role role) { BoundStatement stmtCreate = stmtCreateInstance.get(); PersonaResourceRole prr = new PersonaResourceRole(persona, role, resource); bindBasicParameters(prr, stmtCreate); stmtCreate.setUUID("persona", persona.getIdAsUUID()); stmtCreate.setUUID("resource", resource.getIdAsUUID()); stmtCreate.setUUID("role", role.getIdAsUUID()); session.execute(stmtCreate); logger.personaResourceRoleCreated(persona.getId(), resource.getId(), role.getName()); return prr; }
private CompletableFuture<ModSeq> findHighestModSeq(CassandraId mailboxId) { return cassandraAsyncExecutor.executeSingleRow( select.bind() .setUUID(MAILBOX_ID, mailboxId.asUuid())) .thenApply(optional -> optional.map(row -> new ModSeq(row.getLong(NEXT_MODSEQ))) .orElse(FIRST_MODSEQ)); }
private CompletableFuture<ResultSet> retrieveAllDeleted(CassandraId cassandraId) { return cassandraAsyncExecutor.execute( selectAllUidStatement.bind() .setUUID(MAILBOX_ID, cassandraId.asUuid())); }
public CompletableFuture<Optional<Flags>> retrieveApplicableFlag(CassandraId mailboxId) { return cassandraAsyncExecutor.executeSingleRow( select.bind() .setUUID(MAILBOX_ID, mailboxId.asUuid())) .thenApply(rowOptional -> rowOptional.map(row -> new FlagsExtractor(row).getApplicableFlags())); }
public CompletableFuture<Optional<Rfc4314Rights>> retrieve(String userName, CassandraId mailboxId) { return cassandraAsyncExecutor.executeSingleRow( select.bind() .setString(USER_NAME, userName) .setUUID(MAILBOX_ID, mailboxId.asUuid())) .thenApply(rowOptional -> rowOptional.map(Throwing.function(row -> Rfc4314Rights.fromSerializedRfc4314Rights(row.getString(RIGHTS))))); }
private CompletableFuture<ResultSet> selectFrom(CassandraId mailboxId, MessageUid uid) { return cassandraAsyncExecutor.execute(selectUidGte.bind() .setUUID(MAILBOX_ID, mailboxId.asUuid()) .setLong(IMAP_UID, uid.asLong())); }
public CompletableFuture<Void> addOwner(AttachmentId attachmentId, Username owner) { return executor.executeVoid( addStatement.bind() .setUUID(ID, attachmentId.asUUID()) .setString(OWNER, owner.getValue())); }
public CompletableFuture<Void> updateVersion(SchemaVersion newVersion) { return cassandraAsyncExecutor.executeVoid( writeVersionStatement.bind() .setUUID(KEY, UUIDs.timeBased()) .setInt(VALUE, newVersion.getValue())); } }
@Override public void markAsDispatched(Invitation invitation) { BoundStatement stmtDispatched = stmtDispatchedInstance.get(); invitation.setDispatched(); stmtDispatched.setUUID("id", invitation.getIdAsUUID()); stmtDispatched.setTimestamp("dispatchedAt", zonedDateTimeAdapter.convertToDatabaseColumn(invitation.getDispatchedAt()) ); update(invitation, stmtDispatched); logger.invitationDispatched(invitation.getId()); }
/** * Binds the basic parameters of T into the statement. * @param t the record * @param statement the statement to have the attributes bound to. */ void bindBasicParameters(T t, BoundStatement statement) { statement.setUUID("id", t.getIdAsUUID()); statement.setTimestamp("createdAt", zonedDateTimeAdapter.convertToDatabaseColumn(t.getCreatedAt())); statement.setTimestamp("updatedAt", zonedDateTimeAdapter.convertToDatabaseColumn(t.getUpdatedAt())); }
public CompletableFuture<Void> storeAttachmentForMessageId(AttachmentId attachmentId, MessageId ownerMessageId) { return cassandraAsyncExecutor.executeVoid( insertStatement.bind() .setUUID(ATTACHMENT_ID_AS_UUID, attachmentId.asUUID()) .setString(ATTACHMENT_ID, attachmentId.getId()) .setString(MESSAGE_ID, ownerMessageId.serialize())); } }
public CompletableFuture<Void> storeAttachment(DAOAttachment attachment) { return cassandraAsyncExecutor.executeVoid( insertStatement.bind() .setUUID(ID_AS_UUID, attachment.getAttachmentId().asUUID()) .setString(ID, attachment.getAttachmentId().getId()) .setLong(SIZE, attachment.getSize()) .setString(TYPE, attachment.getType()) .setString(BLOB_ID, attachment.getBlobId().asString())); }