Search in sources :

Example 11 with WriteBuilder

use of com.google.cloud.spanner.Mutation.WriteBuilder in project spanner-jdbc by olavloite.

the class XATransaction method prepareMutations.

static void prepareMutations(TransactionContext transaction, String xid, List<Mutation> mutations) throws SQLException {
    int index = 0;
    for (Mutation mutation : mutations) {
        WriteBuilder prepared = Mutation.newInsertBuilder(CloudSpannerXAConnection.XA_PREPARED_MUTATIONS_TABLE);
        prepared.set(CloudSpannerXAConnection.XA_XID_COLUMN).to(xid);
        prepared.set(CloudSpannerXAConnection.XA_NUMBER_COLUMN).to(index);
        prepared.set(CloudSpannerXAConnection.XA_MUTATION_COLUMN).to(serializeMutation(mutation));
        transaction.buffer(prepared.build());
        index++;
    }
}
Also used : WriteBuilder(com.google.cloud.spanner.Mutation.WriteBuilder) Mutation(com.google.cloud.spanner.Mutation)

Aggregations

WriteBuilder (com.google.cloud.spanner.Mutation.WriteBuilder)11 Test (org.junit.Test)5 Mutation (com.google.cloud.spanner.Mutation)2 Expression (net.sf.jsqlparser.expression.Expression)2 Column (net.sf.jsqlparser.schema.Column)2 CloudSpannerSQLException (nl.topicus.jdbc.exception.CloudSpannerSQLException)2 ByteArray (com.google.cloud.ByteArray)1 Date (com.google.cloud.Date)1 Timestamp (com.google.cloud.Timestamp)1 ValueBinder (com.google.cloud.spanner.ValueBinder)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Map (java.util.Map)1 Set (java.util.Set)1 BiConsumer (java.util.function.BiConsumer)1 BiFunction (java.util.function.BiFunction)1 ExpressionList (net.sf.jsqlparser.expression.operators.relational.ExpressionList)1 ItemsList (net.sf.jsqlparser.expression.operators.relational.ItemsList)1 ArgumentMatchers.anyDouble (org.mockito.ArgumentMatchers.anyDouble)1 ArgumentMatchers.anyLong (org.mockito.ArgumentMatchers.anyLong)1 SpannerDataException (org.springframework.cloud.gcp.data.spanner.core.mapping.SpannerDataException)1