Top Fields Constructors Methods
com.mysql.cj.xdevapi

public Class CollectionImpl

extends Object
implements Collection
Class Inheritance
All Implemented Interfaces
com.mysql.cj.xdevapi.Collection, com.mysql.cj.xdevapi.DatabaseObject
Imports
java.io.IOException, .StringReader, java.util.Map, com.mysql.cj.Messages, .MysqlxSession, com.mysql.cj.exceptions.AssertionFailedException, .FeatureNotAvailableException, .MysqlErrorNumbers, com.mysql.cj.protocol.x.XMessage, .XMessageBuilder, .XProtocolError

Field Summary

Modifier and TypeField and Description
private MysqlxSession
private String
private SchemaImpl
private XMessageBuilder

Constructor Summary

AccessConstructor and Description
pack-priv
CollectionImpl(MysqlxSession mysqlxSession, SchemaImpl schema, String name)

Method Summary

Modifier and TypeMethod and Description
public AddStatement
add(Map<String, ?>
map of key-value parameters representing the document fields
doc
)

Implements com.mysql.cj.xdevapi.Collection.add.

Add a document in the form of a Map.

public AddStatement
add(String...
one or more documents given as JSON strings
jsonString
)

Implements com.mysql.cj.xdevapi.Collection.add.

Add one or more documents.

public AddStatement
add(DbDoc doc)

Implements com.mysql.cj.xdevapi.Collection.add.

Add a document in the form of a DbDoc.

public AddStatement
add(DbDoc...
one or more documents given as DbDoc
docs
)

Implements com.mysql.cj.xdevapi.Collection.add.

Add a sequence of documents.

public Result
addOrReplaceOne(String
the document id of the document to be replaced
id
,
DbDoc
the new document, which may contain expressions. If doc contains an _id value and it does not match the given id then the error will be thrown.
doc
)

Implements com.mysql.cj.xdevapi.Collection.addOrReplaceOne.

Adds the document to the collection.

public Result
addOrReplaceOne(String
the document id of the document to be replaced
id
,
String
the new document, given as JSON string, which may contain expressions. If doc contains an _id value and it does not match the given id then the error will be thrown.
jsonString
)

Implements com.mysql.cj.xdevapi.Collection.addOrReplaceOne.

Adds the document to the collection.

public long
count()

Implements com.mysql.cj.xdevapi.Collection.count.

Query the number of documents in this collection.

public Result
createIndex(String
index name
indexName
,
DbDoc
JSON document with the following fields:
  • fields: array of IndexField objects, each describing a single document member to be included in the index (see below)
  • type: string, (optional) the type of index. One of INDEX or SPATIAL (case insensitive). Default is INDEX and may be omitted.
where single IndexField description consists of the following fields:
  • field: string, the full document path to the document member or field to be indexed
  • type: string, one of the supported SQL column types to map the field into (see below for a list). For numeric types, the optional UNSIGNED keyword may follow. For the TEXT type, the length to consider for indexing may be added. Type descriptions are case insensitive.
  • required: bool, (optional) true if the field is required to exist in the document. Defaults to false, except for GEOJSON where it defaults to true
  • options: int, (optional) special option flags for use when decoding GEOJSON data
  • srid: int, (optional) srid value for use when decoding GEOJSON data
indexDefinition
)

Implements com.mysql.cj.xdevapi.Collection.createIndex.

Create a new statement defining the creation of an index on this collection.

public Result
createIndex(String
index name
indexName
,
String
JSON document with the following fields:
  • fields: array of IndexField objects, each describing a single document member to be included in the index (see below)
  • type: string, (optional) the type of index. One of INDEX or SPATIAL. Default is INDEX and may be omitted.
where single IndexField description consists of the following fields:
  • field: string, the full document path to the document member or field to be indexed
  • type: string, one of the supported SQL column types to map the field into (see below for a list). For numeric types, the optional UNSIGNED keyword may follow. For the TEXT type, the length to consider for indexing may be added.
  • required: bool, (optional) true if the field is required to exist in the document. Defaults to false, except for GEOJSON where it defaults to true
  • options: int, (optional) special option flags for use when decoding GEOJSON data
  • srid: int, (optional) srid value for use when decoding GEOJSON data
jsonIndexDefinition
)

Implements com.mysql.cj.xdevapi.Collection.createIndex.

Create a new statement defining the creation of an index on this collection.

public void
dropIndex(String
index name
indexName
)

Implements com.mysql.cj.xdevapi.Collection.dropIndex.

Create a new statement defining the removal of an index on this collection.

public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public DatabaseObject.DbObjectStatus
existsInDatabase()

Implements com.mysql.cj.xdevapi.DatabaseObject.existsInDatabase.

Query the existence of this database object.

public FindStatement
find()

Implements com.mysql.cj.xdevapi.Collection.find.

Create a new find statement retrieving all documents in the collection.

public FindStatement
find(String
condition expression
searchCondition
)

Implements com.mysql.cj.xdevapi.Collection.find.

Create a new find statement retrieving documents matching the given search condition.

public String
getName()

Implements com.mysql.cj.xdevapi.DatabaseObject.getName.

Retrieve the name of the database object represented by the Java object.

public DbDoc
getOne(String
the document id of the document to be retrieved
id
)

Implements com.mysql.cj.xdevapi.Collection.getOne.

Return the document with the given id.

public Schema
getSchema()

Implements com.mysql.cj.xdevapi.DatabaseObject.getSchema.

Retrieve the schema owning this database object.

public Session
getSession()

Implements com.mysql.cj.xdevapi.DatabaseObject.getSession.

Retrieve the session owning the given schema object.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public ModifyStatement
modify(String
condition expression
searchCondition
)

Implements com.mysql.cj.xdevapi.Collection.modify.

Create a new modify statement affecting documents matching the given search condition.

public DbDoc
newDoc()

Implements com.mysql.cj.xdevapi.Collection.newDoc.

Create a new document.

public RemoveStatement
remove(String
condition expression
searchCondition
)

Implements com.mysql.cj.xdevapi.Collection.remove.

Create a new removal statement affecting documents matching the given search condition.

public Result
removeOne(String
the document id of the document to be removed
id
)

Implements com.mysql.cj.xdevapi.Collection.removeOne.

Removes the document with the given id.

public Result
replaceOne(String
the document id of the document to be replaced
id
,
DbDoc
the new document, which may contain expressions. If document contains an _id value, it is ignored.
doc
)

Implements com.mysql.cj.xdevapi.Collection.replaceOne.

Takes in a document object that will replace the matching document.

public Result
replaceOne(String
the document id of the document to be replaced
id
,
String
the new document, given as JSON string, which may contain expressions. If document contains an _id value, it is ignored.
jsonString
)

Implements com.mysql.cj.xdevapi.Collection.replaceOne.

Takes in a document object that will replace the matching document.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

mysqlxSessionback to summary
private MysqlxSession mysqlxSession
nameback to summary
private String name
schemaback to summary
private SchemaImpl schema
xbuilderback to summary
private XMessageBuilder xbuilder

Constructor Detail

CollectionImplback to summary
pack-priv CollectionImpl(MysqlxSession mysqlxSession, SchemaImpl schema, String name)

Method Detail

addback to summary
public AddStatement add(Map<String, ?> doc)

Implements com.mysql.cj.xdevapi.Collection.add.

Doc from com.mysql.cj.xdevapi.Collection.add.

Add a document in the form of a Map.

Parameters
doc:Map<String, ?>

map of key-value parameters representing the document fields

Returns:AddStatement

AddStatement

Annotations
@Override
addback to summary
public AddStatement add(String... jsonString)

Implements com.mysql.cj.xdevapi.Collection.add.

Doc from com.mysql.cj.xdevapi.Collection.add.

Add one or more documents.

Parameters
jsonString:String[]

one or more documents given as JSON strings

Returns:AddStatement

AddStatement

Annotations
@Override
addback to summary
public AddStatement add(DbDoc doc)

Implements com.mysql.cj.xdevapi.Collection.add.

Doc from com.mysql.cj.xdevapi.Collection.add.

Add a document in the form of a DbDoc.

Parameters
doc:DbDoc

DbDoc

Returns:AddStatement

AddStatement

Annotations
@Override
addback to summary
public AddStatement add(DbDoc... docs)

Implements com.mysql.cj.xdevapi.Collection.add.

Doc from com.mysql.cj.xdevapi.Collection.add.

Add a sequence of documents.

Parameters
docs:DbDoc[]

one or more documents given as DbDoc

Returns:AddStatement

AddStatement

Annotations
@Override
addOrReplaceOneback to summary
public Result addOrReplaceOne(String id, DbDoc doc)

Implements com.mysql.cj.xdevapi.Collection.addOrReplaceOne.

Doc from com.mysql.cj.xdevapi.Collection.addOrReplaceOne.

Adds the document to the collection. The following algorithm applies:

Parameters
id:String

the document id of the document to be replaced

doc:DbDoc

the new document, which may contain expressions. If doc contains an _id value and it does not match the given id then the error will be thrown.

Returns:Result

Result object, which will indicate the number of affected documents (0 - if none, 1 - if added, 2 - if replaced)

Annotations
@Override
addOrReplaceOneback to summary
public Result addOrReplaceOne(String id, String jsonString)

Implements com.mysql.cj.xdevapi.Collection.addOrReplaceOne.

Doc from com.mysql.cj.xdevapi.Collection.addOrReplaceOne.

Adds the document to the collection. The following algorithm applies:

Parameters
id:String

the document id of the document to be replaced

jsonString:String

the new document, given as JSON string, which may contain expressions. If doc contains an _id value and it does not match the given id then the error will be thrown.

Returns:Result

Result object, which will indicate the number of affected documents (0 - if none, 1 - if added, 2 - if replaced)

Annotations
@Override
countback to summary
public long count()

Implements com.mysql.cj.xdevapi.Collection.count.

Doc from com.mysql.cj.xdevapi.Collection.count.

Query the number of documents in this collection.

Returns:long

The number of documents in this collection

Annotations
@Override
createIndexback to summary
public Result createIndex(String indexName, DbDoc indexDefinition)

Implements com.mysql.cj.xdevapi.Collection.createIndex.

Doc from com.mysql.cj.xdevapi.Collection.createIndex.

Create a new statement defining the creation of an index on this collection.

Example: collection.createIndex("myIndex", "{\"fields\": [{\"field\": \"$.myGeoJsonField\", \"type\": \"GEOJSON\", \"required\": true, \"options\": 2, \"srid\": 4326}], \"type\":\"SPATIAL\"}");

Parameters
indexName:String

index name

indexDefinition:DbDoc

JSON document with the following fields:

  • fields: array of IndexField objects, each describing a single document member to be included in the index (see below)
  • type: string, (optional) the type of index. One of INDEX or SPATIAL (case insensitive). Default is INDEX and may be omitted.
where single IndexField description consists of the following fields:
  • field: string, the full document path to the document member or field to be indexed
  • type: string, one of the supported SQL column types to map the field into (see below for a list). For numeric types, the optional UNSIGNED keyword may follow. For the TEXT type, the length to consider for indexing may be added. Type descriptions are case insensitive.
  • required: bool, (optional) true if the field is required to exist in the document. Defaults to false, except for GEOJSON where it defaults to true
  • options: int, (optional) special option flags for use when decoding GEOJSON data
  • srid: int, (optional) srid value for use when decoding GEOJSON data
Returns:Result

Result

Annotations
@Override
createIndexback to summary
public Result createIndex(String indexName, String jsonIndexDefinition)

Implements com.mysql.cj.xdevapi.Collection.createIndex.

Doc from com.mysql.cj.xdevapi.Collection.createIndex.

Create a new statement defining the creation of an index on this collection.

Example: collection.createIndex("myIndex", "{\"fields\": [{\"field\": \"$.myGeoJsonField\", \"type\": \"GEOJSON\", \"required\": true, \"options\": 2, \"srid\": 4326}], \"type\":\"SPATIAL\"}");

Parameters
indexName:String

index name

jsonIndexDefinition:String

JSON document with the following fields:

  • fields: array of IndexField objects, each describing a single document member to be included in the index (see below)
  • type: string, (optional) the type of index. One of INDEX or SPATIAL. Default is INDEX and may be omitted.
where single IndexField description consists of the following fields:
  • field: string, the full document path to the document member or field to be indexed
  • type: string, one of the supported SQL column types to map the field into (see below for a list). For numeric types, the optional UNSIGNED keyword may follow. For the TEXT type, the length to consider for indexing may be added.
  • required: bool, (optional) true if the field is required to exist in the document. Defaults to false, except for GEOJSON where it defaults to true
  • options: int, (optional) special option flags for use when decoding GEOJSON data
  • srid: int, (optional) srid value for use when decoding GEOJSON data
Returns:Result

Result

Annotations
@Override
dropIndexback to summary
public void dropIndex(String indexName)

Implements com.mysql.cj.xdevapi.Collection.dropIndex.

Doc from com.mysql.cj.xdevapi.Collection.dropIndex.

Create a new statement defining the removal of an index on this collection.

Parameters
indexName:String

index name

Annotations
@Override
equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
existsInDatabaseback to summary
public DatabaseObject.DbObjectStatus existsInDatabase()

Implements com.mysql.cj.xdevapi.DatabaseObject.existsInDatabase.

Doc from com.mysql.cj.xdevapi.DatabaseObject.existsInDatabase.

Query the existence of this database object.

Returns:DatabaseObject.DbObjectStatus

DbObjectStatus

Annotations
@Override
findback to summary
public FindStatement find()

Implements com.mysql.cj.xdevapi.Collection.find.

Doc from com.mysql.cj.xdevapi.Collection.find.

Create a new find statement retrieving all documents in the collection.

Returns:FindStatement

FindStatement

Annotations
@Override
findback to summary
public FindStatement find(String searchCondition)

Implements com.mysql.cj.xdevapi.Collection.find.

Doc from com.mysql.cj.xdevapi.Collection.find.

Create a new find statement retrieving documents matching the given search condition.

Parameters
searchCondition:String

condition expression

Returns:FindStatement

FindStatement

Annotations
@Override
getNameback to summary
public String getName()

Implements com.mysql.cj.xdevapi.DatabaseObject.getName.

Doc from com.mysql.cj.xdevapi.DatabaseObject.getName.

Retrieve the name of the database object represented by the Java object.

Returns:String

name

Annotations
@Override
getOneback to summary
public DbDoc getOne(String id)

Implements com.mysql.cj.xdevapi.Collection.getOne.

Doc from com.mysql.cj.xdevapi.Collection.getOne.

Return the document with the given id.

Parameters
id:String

the document id of the document to be retrieved

Returns:DbDoc

the document, or NULL if no match found

Annotations
@Override
getSchemaback to summary
public Schema getSchema()

Implements com.mysql.cj.xdevapi.DatabaseObject.getSchema.

Doc from com.mysql.cj.xdevapi.DatabaseObject.getSchema.

Retrieve the schema owning this database object.

Returns:Schema

Schema

Annotations
@Override
getSessionback to summary
public Session getSession()

Implements com.mysql.cj.xdevapi.DatabaseObject.getSession.

Doc from com.mysql.cj.xdevapi.DatabaseObject.getSession.

Retrieve the session owning the given schema object.

Returns:Session

Session

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
modifyback to summary
public ModifyStatement modify(String searchCondition)

Implements com.mysql.cj.xdevapi.Collection.modify.

Doc from com.mysql.cj.xdevapi.Collection.modify.

Create a new modify statement affecting documents matching the given search condition.

Parameters
searchCondition:String

condition expression

Returns:ModifyStatement

ModifyStatement

Annotations
@Override
newDocback to summary
public DbDoc newDoc()

Implements com.mysql.cj.xdevapi.Collection.newDoc.

Doc from com.mysql.cj.xdevapi.Collection.newDoc.

Create a new document.

Returns:DbDoc

DbDoc

Annotations
@Override
removeback to summary
public RemoveStatement remove(String searchCondition)

Implements com.mysql.cj.xdevapi.Collection.remove.

Doc from com.mysql.cj.xdevapi.Collection.remove.

Create a new removal statement affecting documents matching the given search condition.

Parameters
searchCondition:String

condition expression

Returns:RemoveStatement

RemoveStatement

Annotations
@Override
removeOneback to summary
public Result removeOne(String id)

Implements com.mysql.cj.xdevapi.Collection.removeOne.

Doc from com.mysql.cj.xdevapi.Collection.removeOne.

Removes the document with the given id.

Parameters
id:String

the document id of the document to be removed

Returns:Result

Returns a Result object, which will indicate the number of removed documents (1 or 0, if none)

Annotations
@Override
replaceOneback to summary
public Result replaceOne(String id, DbDoc doc)

Implements com.mysql.cj.xdevapi.Collection.replaceOne.

Doc from com.mysql.cj.xdevapi.Collection.replaceOne.

Takes in a document object that will replace the matching document. If no matches are found, the function returns normally with no changes being made.

Parameters
id:String

the document id of the document to be replaced

doc:DbDoc

the new document, which may contain expressions. If document contains an _id value, it is ignored.

Returns:Result

Result object, which will indicate the number of affected documents (1 or 0, if none)

Annotations
@Override
replaceOneback to summary
public Result replaceOne(String id, String jsonString)

Implements com.mysql.cj.xdevapi.Collection.replaceOne.

Doc from com.mysql.cj.xdevapi.Collection.replaceOne.

Takes in a document object that will replace the matching document. If no matches are found, the function returns normally with no changes being made.

Parameters
id:String

the document id of the document to be replaced

jsonString:String

the new document, given as JSON string, which may contain expressions. If document contains an _id value, it is ignored.

Returns:Result

Result object, which will indicate the number of affected documents (1 or 0, if none)

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override