Class Mutation (6.120.0)
Stay organized with collections
Save and categorize content based on your preferences.
6.120.0 (latest)
6.119.0
6.118.0
6.116.0
6.111.1
6.108.0
6.107.0
6.103.0
6.102.1
6.101.1
6.100.0
6.99.0
6.98.1
6.97.1
6.96.1
6.95.1
6.94.0
6.93.0
6.89.0
6.88.0
6.87.0
6.86.0
6.85.0
6.83.0
6.82.0
6.80.1
6.79.0
6.77.0
6.74.1
6.72.0
6.71.0
6.69.0
6.68.0
6.66.0
6.65.1
6.62.0
6.60.0
6.58.0
6.57.0
6.56.0
6.55.0
6.54.0
6.53.0
6.52.1
6.51.0
6.50.1
6.49.0
6.25.1
6.24.0
6.23.4
6.22.0
6.21.2
6.20.0
6.19.1
6.18.0
6.17.4
6.14.1
public final class Mutation implements Serializable
Represents an individual table modification to be applied to Cloud Spanner.
The types of mutation that can be created are defined by Op . To construct a mutation,
use one of the builder methods. For example, to create a mutation that will insert a value of "x"
into "C1" and a value of "y" into "C2" of table "T", write the following code:
Mutation m = Mutation.newInsertBuilder("T")
.set("C1").to("x")
.set("C2").to("y")
.build();
Mutations are applied to a database by performing a standalone write or buffering them as part of
a transaction. TODO(user): Add links/code samples once the corresponding APIs are available.
Mutation instances are immutable.
Static Methods
delete(String table, Key key)
public static Mutation delete ( String table , Key key )
Returns a mutation that will delete the row with primary key key. Exactly equivalent to
delete(table, KeySet.singleKey(key)).
Parameters
Name
Description
table
String
key
Key
delete(String table, KeySet keySet)
public static Mutation delete ( String table , KeySet keySet )
Returns a mutation that will delete all rows with primary keys covered by keySet.
newAckBuilder(String queue)
public static Mutation . AckBuilder newAckBuilder ( String queue )
Returns a builder that can be used to construct an Op#ACK mutation against
queue; see the ACK documentation for mutation semantics.
Parameter
Name
Description
queue
String
newInsertBuilder(String table)
public static Mutation . WriteBuilder newInsertBuilder ( String table )
Returns a builder that can be used to construct an Op#INSERT mutation against
table; see the INSERT documentation for mutation semantics.
Parameter
Name
Description
table
String
newInsertOrUpdateBuilder(String table)
public static Mutation . WriteBuilder newInsertOrUpdateBuilder ( String table )
Returns a builder that can be used to construct an Op#INSERT_OR_UPDATE mutation against
table; see the INSERT_OR_UPDATE documentation for mutation semantics.
Parameter
Name
Description
table
String
newReplaceBuilder(String table)
public static Mutation . WriteBuilder newReplaceBuilder ( String table )
Returns a builder that can be used to construct an Op#REPLACE mutation against
table; see the REPLACE documentation for mutation semantics.
Parameter
Name
Description
table
String
newSendBuilder(String queue)
public static Mutation . SendBuilder newSendBuilder ( String queue )
Returns a builder that can be used to construct an Op#SEND mutation against
queue; see the SEND documentation for mutation semantics.
Parameter
Name
Description
queue
String
newUpdateBuilder(String table)
public static Mutation . WriteBuilder newUpdateBuilder ( String table )
Returns a builder that can be used to construct an Op#UPDATE mutation against
table; see the UPDATE documentation for mutation semantics.
Parameter
Name
Description
table
String
Methods
asMap()
public Map<String , Value > asMap ()
For all types except Op#DELETE , Op#SEND , and Op#ACK , constructs a map
from column name to value. This is mainly intended as a convenience for testing; direct access
via #getColumns() and #getValues() is more efficient.
equals(Object o)
public boolean equals ( Object o )
Parameter
Name
Description
o
Object
Overrides
getColumns()
public Iterable<String> getColumns ()
For all types except Op#DELETE , returns the columns that this mutation will affect.
getDeliveryTime()
public Instant getDeliveryTime ()
Returns the delivery timestamp of the message to the queue that this mutation will affect.
getIgnoreNotFound()
public boolean getIgnoreNotFound ()
Returns whether an error will be ignored for an ACK mutation that affects a message that does
not exist
getKey()
Returns the key of the message to the queue that this mutation will affect.
Returns
Type
Description
Key
getKeySet()
public KeySet getKeySet ()
For Op#DELETE mutations, returns the key set that defines the rows to be deleted.
Returns
Type
Description
KeySet
getOperation()
public Mutation . Op getOperation ()
Returns the type of operation that this mutation will perform.
getPayload()
public Value getPayload ()
Returns the payload of the message to the queue that this mutation will affect.
Returns
Type
Description
Value
getQueue()
Returns the name of the queue that this mutation will affect.
Returns
Type
Description
String
getTable()
Returns the name of the table that this mutation will affect.
Returns
Type
Description
String
getValues()
public Iterable<Value> getValues ()
For all types except Op#DELETE , Op#SEND , and Op#ACK , returns the values
that this mutation will write. The number of elements returned is always the same as the number
returned by #getColumns() , and the ith value corresponds to the ith
column.
hashCode()
Returns
Type
Description
int
Overrides
toString()
Returns
Type
Description
String
Overrides
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-08-05 UTC.
[null,null,["Last updated 2026-08-05 UTC."],[],[]]