Top Description Inners Methods
com.mysql.cj.xdevapi

public Interface Schema

extends DatabaseObject
Known Direct Implementers
com.mysql.cj.xdevapi.SchemaImpl
Imports
java.util.List

A client-side representation of a database schema. Provides access to the schema contents.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class
public static class

Method Summary

Modifier and TypeMethod and Description
public Collection

Returns:

Collection
createCollection
(String
collection name
name
)

Create a new collection.

public Collection

Returns:

Collection
createCollection
(String
collection name
name
,
boolean
true if allowed to reuse
reuseExisting
)

Create a new collection if it does not already exist on the server.

public Collection

Returns:

Collection
createCollection
(String
collection name
collectionName
,
Schema.CreateCollectionOptions
reuseExisting, validation level and JSON schema options
options
)

Create a new collection.

public void
dropCollection(String
name of collection to drop
collectionName
)

Drop the collection from this schema.

public Collection

Returns:

Collection
getCollection
(String
collection name
name
)

Retrieve a reference to the named collection.

public Collection

Returns:

Collection
getCollection
(String
collection name
name
,
boolean
true if required to exist
requireExists
)

Retrieve a reference to the named collection hinting that an exception should be thrown if the collection is not known to the server.

public Table

Returns:

Table
getCollectionAsTable
(String
collection name
name
)

Retrieve a reference to the named collection using the table API.

public List<Collection>

Returns:

list of Collection objects
getCollections
()

Retrieve the set of collections existing in this schema.

public List<Collection>

Returns:

list of Collection objects
getCollections
(String
match pattern
pattern
)

Retrieve the set of collections existing in this schema and matching the given pattern.

public Table

Returns:

Table
getTable
(String
table name
name
)

Retrieve a reference to the named table.

public Table

Returns:

Table
getTable
(String
table name
tableName
,
boolean
true if required to exist
requireExists
)

Retrieve a reference to the named table hinting that an exception should be thrown if the collection is not known to the server.

public List<Table>

Returns:

list of Table objects
getTables
()

Retrieve the set of tables existing in this schema.

public List<Table>

Returns:

list of Table objects
getTables
(String
match pattern
pattern
)

Retrieve the set of tables existing in this schema and matching the given pattern.

public void
modifyCollection(String
collection name
collectionName
,
Schema.ModifyCollectionOptions
validation level and JSON schema options
options
)

Modify the schema validation of a collection.

Inherited from com.mysql.cj.xdevapi.DatabaseObject:
existsInDatabasegetNamegetSchemagetSession

Method Detail

createCollectionback to summary
public Collection createCollection(String name)

Create a new collection.

Parameters
name:String

collection name

Returns:Collection

Collection

createCollectionback to summary
public Collection createCollection(String name, boolean reuseExisting)

Create a new collection if it does not already exist on the server.

Parameters
name:String

collection name

reuseExisting:boolean

true if allowed to reuse

Returns:Collection

Collection

createCollectionback to summary
public Collection createCollection(String collectionName, Schema.CreateCollectionOptions options)

Create a new collection.

Parameters
collectionName:String

collection name

options:Schema.CreateCollectionOptions

reuseExisting, validation level and JSON schema options

Returns:Collection

Collection

dropCollectionback to summary
public void dropCollection(String collectionName)

Drop the collection from this schema.

Parameters
collectionName:String

name of collection to drop

getCollectionback to summary
public Collection getCollection(String name)

Retrieve a reference to the named collection.

Parameters
name:String

collection name

Returns:Collection

Collection

getCollectionback to summary
public Collection getCollection(String name, boolean requireExists)

Retrieve a reference to the named collection hinting that an exception should be thrown if the collection is not known to the server.

Parameters
name:String

collection name

requireExists:boolean

true if required to exist

Returns:Collection

Collection

getCollectionAsTableback to summary
public Table getCollectionAsTable(String name)

Retrieve a reference to the named collection using the table API.

Parameters
name:String

collection name

Returns:Table

Table

getCollectionsback to summary
public List<Collection> getCollections()

Retrieve the set of collections existing in this schema.

Returns:List<Collection>

list of Collection objects

getCollectionsback to summary
public List<Collection> getCollections(String pattern)

Retrieve the set of collections existing in this schema and matching the given pattern.

Parameters
pattern:String

match pattern

Returns:List<Collection>

list of Collection objects

getTableback to summary
public Table getTable(String name)

Retrieve a reference to the named table.

Parameters
name:String

table name

Returns:Table

Table

getTableback to summary
public Table getTable(String tableName, boolean requireExists)

Retrieve a reference to the named table hinting that an exception should be thrown if the collection is not known to the server.

Parameters
tableName:String

table name

requireExists:boolean

true if required to exist

Returns:Table

Table

getTablesback to summary
public List<Table> getTables()

Retrieve the set of tables existing in this schema.

Returns:List<Table>

list of Table objects

getTablesback to summary
public List<Table> getTables(String pattern)

Retrieve the set of tables existing in this schema and matching the given pattern.

Parameters
pattern:String

match pattern

Returns:List<Table>

list of Table objects

modifyCollectionback to summary
public void modifyCollection(String collectionName, Schema.ModifyCollectionOptions options)

Modify the schema validation of a collection.

Parameters
collectionName:String

collection name

options:Schema.ModifyCollectionOptions

validation level and JSON schema options

com.mysql.cj.xdevapi back to summary

public Class Schema.CreateCollectionOptions

extends Object
Class Inheritance

Defines options to be passed to Schema#createCollection(String, CreateCollectionOptions).

Allowed options are:

Examples:
schema.createCollection(collName,
        new CreateCollectionOptions().setReuseExisting(false)
                .setValidation(new Validation().setLevel(ValidationLevel.STRICT)
                        .setSchema("{\"id\": \"http://json-schema.org/idx\", \"$schema\": \"http://json-schema.org/draft-06/schema#\","
                                + "\"type\": \"object\", \"properties\": {\"index\": {\"type\": \"number\"}},\"required\": [\"index\"]}")));
schema.createCollection(collName, new CreateCollectionOptions().setReuseExisting(false).setValidation(new Validation().setLevel(ValidationLevel.OFF)));
schema.createCollection(collName,
        new CreateCollectionOptions().setReuseExisting(true);

Field Summary

Modifier and TypeField and Description
private Boolean
private Schema.Validation

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Boolean
public Schema.Validation
public Schema.CreateCollectionOptions
setReuseExisting(boolean reuse)

public Schema.CreateCollectionOptions
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

reuseExistingback to summary
private Boolean reuseExisting
validationback to summary
private Schema.Validation validation

Constructor Detail

CreateCollectionOptionsback to summary
public CreateCollectionOptions()

Method Detail

getReuseExistingback to summary
public Boolean getReuseExisting()
getValidationback to summary
public Schema.Validation getValidation()
setReuseExistingback to summary
public Schema.CreateCollectionOptions setReuseExisting(boolean reuse)
setValidationback to summary
public Schema.CreateCollectionOptions setValidation(Schema.Validation validation)
com.mysql.cj.xdevapi back to summary

public Class Schema.ModifyCollectionOptions

extends Object
Class Inheritance

Defines options to be passed to Schema#modifyCollection(String, ModifyCollectionOptions). Options are defined by Validation object.

Example:

schema.modifyCollection(collName1, new ModifyCollectionOptions().setValidation(new Validation().setLevel(ValidationLevel.OFF)));

Field Summary

Modifier and TypeField and Description
private Schema.Validation

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Schema.Validation
public Schema.ModifyCollectionOptions
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

validationback to summary
private Schema.Validation validation

Constructor Detail

ModifyCollectionOptionsback to summary
public ModifyCollectionOptions()

Method Detail

getValidationback to summary
public Schema.Validation getValidation()
setValidationback to summary
public Schema.ModifyCollectionOptions setValidation(Schema.Validation validation)
com.mysql.cj.xdevapi back to summary

public Class Schema.Validation

extends Object
Class Inheritance

Validation options to be passed to Schema#createCollection(String, CreateCollectionOptions) or Schema#modifyCollection(String, ModifyCollectionOptions).

Allowed options are:

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
Schema.Validation.ValidationLevel

Defines how validation options are applied.

Field Summary

Modifier and TypeField and Description
private Schema.Validation.ValidationLevel
private String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Schema.Validation.ValidationLevel
public String
public Schema.Validation
public Schema.Validation
setSchema(String schema)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

levelback to summary
private Schema.Validation.ValidationLevel level
schemaback to summary
private String schema

Constructor Detail

Validationback to summary
public Validation()

Method Detail

getLevelback to summary
public Schema.Validation.ValidationLevel getLevel()
getSchemaback to summary
public String getSchema()
setLevelback to summary
public Schema.Validation setLevel(Schema.Validation.ValidationLevel level)
setSchemaback to summary
public Schema.Validation setSchema(String schema)
com.mysql.cj.xdevapi back to summary

public final Enum Schema.Validation.ValidationLevel

extends Enum<Schema.Validation.ValidationLevel>
Class Inheritance

Defines how validation options are applied.
  • STRICT - enable JSON schema validation for documents in the collection.
  • OFF - disable JSON schema validation.

Field Summary

Modifier and TypeField and Description
public static final Schema.Validation.ValidationLevel
public static final Schema.Validation.ValidationLevel

Constructor Summary

AccessConstructor and Description
private

Field Detail

OFFback to summary
public static final Schema.Validation.ValidationLevel OFF
STRICTback to summary
public static final Schema.Validation.ValidationLevel STRICT

Constructor Detail

ValidationLevelback to summary
private ValidationLevel()

Method Detail

valueOfback to summary
public static Schema.Validation.ValidationLevel valueOf(String name)
valuesback to summary
public static Schema.Validation.ValidationLevel[] values()