use of com.scalar.db.storage.jdbc.query.UpsertQuery in project scalardb by scalar-labs.
the class JdbcService method put.
public boolean put(Put put, Connection connection) throws SQLException, ExecutionException {
operationChecker.check(put);
TableMetadata tableMetadata = tableMetadataManager.getTableMetadata(put);
if (!put.getCondition().isPresent()) {
UpsertQuery upsertQuery = queryBuilder.upsertInto(put.forNamespace().get(), put.forTable().get(), tableMetadata).values(put.getPartitionKey(), put.getClusteringKey(), put.getColumns()).build();
try (PreparedStatement preparedStatement = connection.prepareStatement(upsertQuery.sql())) {
upsertQuery.bind(preparedStatement);
preparedStatement.executeUpdate();
return true;
}
} else {
return new ConditionalMutator(put, tableMetadata, connection, queryBuilder).mutate();
}
}
Aggregations