Top Description Fields Constructors Methods
com.mysql.cj.xdevapi

public Class ModifyStatementImpl

extends FilterableStatement<ModifyStatement, Result>
implements ModifyStatement
Class Inheritance
All Implemented Interfaces
com.mysql.cj.xdevapi.ModifyStatement, com.mysql.cj.xdevapi.Statement
Imports
java.util.ArrayList, .Arrays, .List, java.util.concurrent.CompletableFuture, java.util.stream.Collectors, com.mysql.cj.Messages, .MysqlxSession, com.mysql.cj.protocol.x.XMessage, .XMessageBuilder

ModifyStatement implementation.

Field Summary

Modifier and TypeField and Description
private List<UpdateSpec>
Inherited from com.mysql.cj.xdevapi.FilterableStatement:
filterParams

Constructor Summary

AccessConstructor and Description
pack-priv
ModifyStatementImpl(MysqlxSession mysqlxSession, String schema, String collection, String criteria)

Method Summary

Modifier and TypeMethod and Description
public ModifyStatement
arrayAppend(String
document path to the array field
docPath
,
Object
value to append
value
)

Implements com.mysql.cj.xdevapi.ModifyStatement.arrayAppend.

Append a value to the specified array.

public ModifyStatement
arrayInsert(String
document path to the array field
docPath
,
Object
value to insert
value
)

Implements com.mysql.cj.xdevapi.ModifyStatement.arrayInsert.

Insert a value into the specified array.

public ModifyStatement
change(String
document path to the given value
docPath
,
Object
value to set
value
)

Implements com.mysql.cj.xdevapi.ModifyStatement.change.

Add an update to the statement setting the field, if it exists at the document path, to the given value.

public CompletableFuture<Result>
executeAsync()

Implements com.mysql.cj.xdevapi.Statement.executeAsync.

Execute the statement asynchronously.

protected Result
executePreparedStatement()

Implements abstract com.mysql.cj.xdevapi.PreparableStatement.executePreparedStatement.

Executes a previously server-prepared statement.

protected Result
executeStatement()

Implements abstract com.mysql.cj.xdevapi.PreparableStatement.executeStatement.

Executes the statement directly (non-prepared).

protected XMessage
getPrepareStatementXMessage()

Implements abstract com.mysql.cj.xdevapi.PreparableStatement.getPrepareStatementXMessage.

Returns the XMessage needed to prepare this statement.

public ModifyStatement
patch(DbDoc
patch object
document
)

Implements com.mysql.cj.xdevapi.ModifyStatement.patch.

Takes in a patch object and applies it on all documents matching the modify() filter, using the JSON_MERGE_PATCH() function.

public ModifyStatement
patch(String
patch object
document
)

Implements com.mysql.cj.xdevapi.ModifyStatement.patch.

Takes in a document patch and applies it on all documents matching the modify() filter, using the JSON_MERGE_PATCH() function.

public ModifyStatement
set(String
document path to the given value
docPath
,
Object
value to set
value
)

Implements com.mysql.cj.xdevapi.ModifyStatement.set.

Add an update to the statement setting the field as the document path to the given value for all documents matching the search criteria.

public ModifyStatement
unset(String...
one or more field names
docPath
)

Implements com.mysql.cj.xdevapi.ModifyStatement.unset.

Nullify the given fields.

public ModifyStatement
where(String
expression
searchCondition
)

Overrides com.mysql.cj.xdevapi.FilterableStatement.where.

Deprecated Deprecated in Connector/J 8.0.17. Please use filter criteria in the operation starting method.

Add search condition to this statement.

Inherited from com.mysql.cj.xdevapi.FilterableStatement:
bindclearBindingsisRelationallimitoffsetorderBysort

Field Detail

updatesback to summary
private List<UpdateSpec> updates

Constructor Detail

ModifyStatementImplback to summary
pack-priv ModifyStatementImpl(MysqlxSession mysqlxSession, String schema, String collection, String criteria)

Method Detail

arrayAppendback to summary
public ModifyStatement arrayAppend(String docPath, Object value)

Implements com.mysql.cj.xdevapi.ModifyStatement.arrayAppend.

Doc from com.mysql.cj.xdevapi.ModifyStatement.arrayAppend.

Append a value to the specified array.

Parameters
docPath:String

document path to the array field

value:Object

value to append

Returns:ModifyStatement

ModifyStatement

Annotations
@Override
arrayInsertback to summary
public ModifyStatement arrayInsert(String docPath, Object value)

Implements com.mysql.cj.xdevapi.ModifyStatement.arrayInsert.

Doc from com.mysql.cj.xdevapi.ModifyStatement.arrayInsert.

Insert a value into the specified array.

Parameters
docPath:String

document path to the array field

value:Object

value to insert

Returns:ModifyStatement

ModifyStatement

Annotations
@Override
changeback to summary
public ModifyStatement change(String docPath, Object value)

Implements com.mysql.cj.xdevapi.ModifyStatement.change.

Doc from com.mysql.cj.xdevapi.ModifyStatement.change.

Add an update to the statement setting the field, if it exists at the document path, to the given value.

Parameters
docPath:String

document path to the given value

value:Object

value to set

Returns:ModifyStatement

ModifyStatement

Annotations
@Override
executeAsyncback to summary
public CompletableFuture<Result> executeAsync()

Implements com.mysql.cj.xdevapi.Statement.executeAsync.

Doc from com.mysql.cj.xdevapi.Statement.executeAsync.

Execute the statement asynchronously.

Returns:CompletableFuture<Result>

CompletableFuture for result

Annotations
@Override
executePreparedStatementback to summary
protected Result executePreparedStatement()

Implements abstract com.mysql.cj.xdevapi.PreparableStatement.executePreparedStatement.

Doc from com.mysql.cj.xdevapi.PreparableStatement.executePreparedStatement.

Executes a previously server-prepared statement. Implementation is dependent on the statement type.

Returns:Result

the object returned from the lower level statement execution

Annotations
@Override
executeStatementback to summary
protected Result executeStatement()

Implements abstract com.mysql.cj.xdevapi.PreparableStatement.executeStatement.

Doc from com.mysql.cj.xdevapi.PreparableStatement.executeStatement.

Executes the statement directly (non-prepared). Implementation is dependent on the statement type.

Returns:Result

the object returned from the lower level statement execution

Annotations
@Override
getPrepareStatementXMessageback to summary
protected XMessage getPrepareStatementXMessage()

Implements abstract com.mysql.cj.xdevapi.PreparableStatement.getPrepareStatementXMessage.

Doc from com.mysql.cj.xdevapi.PreparableStatement.getPrepareStatementXMessage.

Returns the XMessage needed to prepare this statement. Implementation is dependent on the statement type.

Returns:XMessage

the XMessage that prepares this statement

Annotations
@Override
patchback to summary
public ModifyStatement patch(DbDoc document)

Implements com.mysql.cj.xdevapi.ModifyStatement.patch.

Doc from com.mysql.cj.xdevapi.ModifyStatement.patch.

Takes in a patch object and applies it on all documents matching the modify() filter, using the JSON_MERGE_PATCH() function. Please note that DbDoc does not support expressions as a field values, please use patch(String) method if you need such functionality.

Parameters
document:DbDoc

patch object

Returns:ModifyStatement

ModifyStatement

Annotations
@Override
patchback to summary
public ModifyStatement patch(String document)

Implements com.mysql.cj.xdevapi.ModifyStatement.patch.

Doc from com.mysql.cj.xdevapi.ModifyStatement.patch.

Takes in a document patch and applies it on all documents matching the modify() filter, using the JSON_MERGE_PATCH() function. A document patch is similar to a JSON object, with the key difference that document field values can be nested expressions in addition to literal values.
Example:
collection.modify("_id = :id")
.patch("{\"zip\": address.zip-300000, \"street\": CONCAT($.name, '''s street: ', $.address.street)}")
.bind("id", "2").execute();

Parameters
document:String

patch object

Returns:ModifyStatement

ModifyStatement

Annotations
@Override
setback to summary
public ModifyStatement set(String docPath, Object value)

Implements com.mysql.cj.xdevapi.ModifyStatement.set.

Doc from com.mysql.cj.xdevapi.ModifyStatement.set.

Add an update to the statement setting the field as the document path to the given value for all documents matching the search criteria.

Parameters
docPath:String

document path to the given value

value:Object

value to set

Returns:ModifyStatement

ModifyStatement

Annotations
@Override
unsetback to summary
public ModifyStatement unset(String... docPath)

Implements com.mysql.cj.xdevapi.ModifyStatement.unset.

Doc from com.mysql.cj.xdevapi.ModifyStatement.unset.

Nullify the given fields.

Parameters
docPath:String[]

one or more field names

Returns:ModifyStatement

ModifyStatement

Annotations
@Override
whereback to summary
public ModifyStatement where(String searchCondition)

Overrides com.mysql.cj.xdevapi.FilterableStatement.where.

Doc from com.mysql.cj.xdevapi.FilterableStatement.where.

Deprecated

Deprecated in Connector/J 8.0.17. Please use filter criteria in the operation starting method.

Add search condition to this statement.

table.delete().where("age == 13").execute();
Parameters
searchCondition:String

expression

Returns:ModifyStatement

this statement

Annotations
@Deprecated
@Override