Package com.mysql.cj.xdevapi
Class ModifyStatementImpl
java.lang.Object
com.mysql.cj.xdevapi.PreparableStatement<RES_T>
com.mysql.cj.xdevapi.FilterableStatement<ModifyStatement,Result>
com.mysql.cj.xdevapi.ModifyStatementImpl
- All Implemented Interfaces:
ModifyStatement
,Statement<ModifyStatement,Result>
public class ModifyStatementImpl extends FilterableStatement<ModifyStatement,Result> implements ModifyStatement
ModifyStatement
implementation.-
Nested Class Summary
Nested classes/interfaces inherited from class com.mysql.cj.xdevapi.PreparableStatement
PreparableStatement.PreparableStatementFinalizer, PreparableStatement.PreparedState
Nested classes/interfaces inherited from interface com.mysql.cj.xdevapi.Statement
Statement.LockContention
-
Field Summary
Fields inherited from class com.mysql.cj.xdevapi.PreparableStatement
mysqlxSession, preparedState, preparedStatementId
-
Method Summary
Modifier and Type Method Description ModifyStatement
arrayAppend(java.lang.String docPath, java.lang.Object value)
Append a value to the specified array.ModifyStatement
arrayInsert(java.lang.String field, java.lang.Object value)
Insert a value into the specified array.ModifyStatement
change(java.lang.String docPath, java.lang.Object value)
Add an update to the statement setting the field, if it exists at the document path, to the given value.java.util.concurrent.CompletableFuture<Result>
executeAsync()
Execute the statement asynchronously.protected Result
executePreparedStatement()
Executes a previously server-prepared statement.protected Result
executeStatement()
Executes the statement directly (non-prepared).protected XMessage
getPrepareStatementXMessage()
Returns theXMessage
needed to prepare this statement.ModifyStatement
patch(DbDoc document)
Takes in a patch object and applies it on all documents matching the modify() filter, using the JSON_MERGE_PATCH() function.ModifyStatement
patch(java.lang.String document)
Takes in a document patch and applies it on all documents matching the modify() filter, using the JSON_MERGE_PATCH() function.ModifyStatement
set(java.lang.String docPath, java.lang.Object value)
Add an update to the statement setting the field as the document path to the given value for all documents matching the search criteria.ModifyStatement
unset(java.lang.String... fields)
Nullify the given fields.ModifyStatement
where(java.lang.String searchCondition)
Deprecated.Deprecated in Connector/J 8.0.17.Methods inherited from class com.mysql.cj.xdevapi.FilterableStatement
bind, clearBindings, isRelational, limit, offset, orderBy, sort
Methods inherited from class com.mysql.cj.xdevapi.PreparableStatement
deallocatePrepared, execute, getMessageBuilder, resetPrepareState, setReprepareState
-
Method Details
-
executeStatement
Description copied from class:PreparableStatement
Executes the statement directly (non-prepared). Implementation is dependent on the statement type.- Specified by:
executeStatement
in classPreparableStatement<Result>
- Returns:
- the object returned from the lower level statement execution
-
getPrepareStatementXMessage
Description copied from class:PreparableStatement
Returns theXMessage
needed to prepare this statement. Implementation is dependent on the statement type.- Specified by:
getPrepareStatementXMessage
in classPreparableStatement<Result>
- Returns:
- the
XMessage
that prepares this statement
-
executePreparedStatement
Description copied from class:PreparableStatement
Executes a previously server-prepared statement. Implementation is dependent on the statement type.- Specified by:
executePreparedStatement
in classPreparableStatement<Result>
- Returns:
- the object returned from the lower level statement execution
-
executeAsync
Description copied from interface:Statement
Execute the statement asynchronously.- Specified by:
executeAsync
in interfaceStatement<ModifyStatement,Result>
- Returns:
CompletableFuture
for result
-
set
Description copied from interface:ModifyStatement
Add an update to the statement setting the field as the document path to the given value for all documents matching the search criteria.- Specified by:
set
in interfaceModifyStatement
- Parameters:
docPath
- document path to the given valuevalue
- value to set- Returns:
ModifyStatement
-
change
Description copied from interface:ModifyStatement
Add an update to the statement setting the field, if it exists at the document path, to the given value.- Specified by:
change
in interfaceModifyStatement
- Parameters:
docPath
- document path to the given valuevalue
- value to set- Returns:
ModifyStatement
-
unset
Description copied from interface:ModifyStatement
Nullify the given fields.- Specified by:
unset
in interfaceModifyStatement
- Parameters:
fields
- one or more field names- Returns:
ModifyStatement
-
patch
Description copied from interface:ModifyStatement
Takes in a patch object and applies it on all documents matching the modify() filter, using the JSON_MERGE_PATCH() function. Please note thatDbDoc
does not support expressions as a field values, please useModifyStatement.patch(String)
method if you need such functionality.- Specified by:
patch
in interfaceModifyStatement
- Parameters:
document
- patch object- Returns:
ModifyStatement
-
patch
Description copied from interface:ModifyStatement
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();- Specified by:
patch
in interfaceModifyStatement
- Parameters:
document
- patch object- Returns:
ModifyStatement
-
arrayInsert
Description copied from interface:ModifyStatement
Insert a value into the specified array.- Specified by:
arrayInsert
in interfaceModifyStatement
- Parameters:
field
- document path to the array fieldvalue
- value to insert- Returns:
ModifyStatement
-
arrayAppend
Description copied from interface:ModifyStatement
Append a value to the specified array.- Specified by:
arrayAppend
in interfaceModifyStatement
- Parameters:
docPath
- document path to the array fieldvalue
- value to append- Returns:
ModifyStatement
-
where
Deprecated.Deprecated in Connector/J 8.0.17. Please use filter criteria in the operation starting method.Description copied from class:FilterableStatement
Add search condition to this statement.table.delete().where("age == 13").execute();
- Overrides:
where
in classFilterableStatement<ModifyStatement,Result>
- Parameters:
searchCondition
- expression- Returns:
- this statement
-