Interface ODatabaseDocument
- All Superinterfaces:
AutoCloseable,Closeable,OBackupable,ODatabase<ORecord>
- All Known Subinterfaces:
ODatabaseDocumentInternal,ODatabaseSession
- All Known Implementing Classes:
ODatabaseDocumentAbstract,ODatabaseDocumentDistributed,ODatabaseDocumentDistributedPooled,ODatabaseDocumentEmbedded,ODatabaseDocumentEmbeddedPooled,ODatabaseDocumentRemote,ODatabaseDocumentRemotePooled
Generic interface for document based Database implementations.
- Author:
- Luca Garulli (l.garulli--(at)--orientdb.com)
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.orientechnologies.orient.core.db.ODatabase
ODatabase.ATTRIBUTES, ODatabase.STATUS -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionintaddBlobCluster(String iClusterName, Object... iParameters) Add a cluster for blob records.browseClass(String iClassName) Deprecated.browseClass(String iClassName, boolean iPolymorphic) Deprecated.<REC extends ORecord>
ORecordIteratorCluster<REC>browseCluster(String iClusterName) Deprecated.<REC extends ORecord>
ORecordIteratorCluster<REC>browseCluster(String iClusterName, Class<REC> iRecordClass) Deprecated.<REC extends ORecord>
ORecordIteratorCluster<REC>browseCluster(String iClusterName, Class<REC> iRecordClass, long startClusterPosition, long endClusterPosition) Deprecated.<DB extends ODatabaseDocument>
DBcheckSecurity(ORule.ResourceGeneric iResourceGeneric, int iOperation, Object iResourceSpecific) Checks if the operation on a resource is allowed for the current user.<DB extends ODatabaseDocument>
DBcheckSecurity(ORule.ResourceGeneric iResourceGeneric, int iOperation, Object... iResourcesSpecific) Checks if the operation against multiple resources is allowed for the current user.<DB extends ODatabaseDocument>
DBcheckSecurity(ORule.ResourceGeneric resourceGeneric, String resourceSpecific, int iOperation) Checks if the operation on a resource is allowed for the current user.longcountClass(String iClassName) Counts the entities contained in the specified class and sub classes (polymorphic).longcountClass(String iClassName, boolean iPolymorphic) Counts the entities contained in the specified class.longdefault OClasscreateClassIfNotExist(String className, String... superclasses) If a class with given name already exists, it's just returned, otherwise the method creates a new class and returns it.default OClasscreateEdgeClass(String className) creates a new edge class (a class that extends E)default OClasscreateVertexClass(String className) creates a new vertex class (a class that extends V)voidfreeze()Flush all indexes and cached storage content to the disk.voidfreeze(boolean throwException) Flush all indexes and cached storage content to the disk.<RET extends ORecord>
RETgetRecord(OIdentifiable iIdentifiable) Returns the record for a OIdentifiable instance.byteDeprecated.booleanisPooled()booleanTells if validation of record is active.newBlob()Create a new empty instance of a blob.newBlob(byte[] bytes) Create a new instance of a blob containing the given bytes.default OEdgeCreates a new Edge of type ECreates a new EdgeCreates a new EdgenewElement(String className) newEmbeddedElement(String className) <RET> RETnewInstance(String iClassName) Creates a new entity instance.default OVertexCreates a new Vertex of type VCreates a new VertexCreates a new Vertexvoidrelease()Allows to execute write-related commands on DB.default OElement<DB extends ODatabaseDocument>
DBsetValidationEnabled(boolean iEnabled) Enables or disables the record validation.Methods inherited from interface com.orientechnologies.orient.core.util.OBackupable
backup, restoreMethods inherited from interface com.orientechnologies.orient.core.db.ODatabase
activateOnCurrentThread, addCluster, addCluster, begin, begin, close, command, command, commit, commit, countClusterElements, countClusterElements, countClusterElements, createClass, delete, delete, delete, dropCluster, dropCluster, execute, execute, executeWithRetry, existsCluster, get, getBlobClusterIds, getClass, getClusterIdByName, getClusterNameById, getClusterNames, getClusterRecordSizeById, getClusterRecordSizeByName, getClusters, getConfiguration, getConflictStrategy, getDefaultClusterId, getDictionary, getHooks, getListeners, getLocalCache, getMetadata, getName, getProperties, getProperty, getRecordMetadata, getSize, getStatus, getTransaction, getType, getURL, getUser, incrementalBackup, isActiveOnCurrentThread, isClosed, live, live, load, load, load, load, load, load, lock, lock, newInstance, query, query, registerHook, registerHook, registerListener, reload, reload, reload, rollback, rollback, save, save, set, setConflictStrategy, setConflictStrategy, setProperty, setStatus, truncateCluster, unlock, unregisterHook, unregisterListener
-
Field Details
-
TYPE
- See Also:
-
-
Method Details
-
browseClass
Deprecated.Browses all the records of the specified class and also all the subclasses. If you've a class Vehicle and Car that extends Vehicle then a db.browseClass("Vehicle", true) will return all the instances of Vehicle and Car. The order of the returned instance starts from record id with position 0 until the end. Base classes are worked at first.- Parameters:
iClassName- Class name to iterate- Returns:
- Iterator of ODocument instances
-
browseClass
Deprecated.Browses all the records of the specified class and if iPolymorphic is true also all the subclasses. If you've a class Vehicle and Car that extends Vehicle then a db.browseClass("Vehicle", true) will return all the instances of Vehicle and Car. The order of the returned instance starts from record id with position 0 until the end. Base classes are worked at first.- Parameters:
iClassName- Class name to iterateiPolymorphic- Consider also the instances of the subclasses or not- Returns:
- Iterator of ODocument instances
-
newInstance
Creates a new entity instance. Each database implementation will return the right type.- Returns:
- The new instance.
-
newBlob
Create a new instance of a blob containing the given bytes.- Parameters:
bytes- content of the OBlob- Returns:
- the OBlob instance.
-
newBlob
OBlob newBlob()Create a new empty instance of a blob.- Returns:
- the OBlob instance.
-
countClass
Counts the entities contained in the specified class and sub classes (polymorphic).- Parameters:
iClassName- Class name- Returns:
- Total entities
-
countClass
Counts the entities contained in the specified class.- Parameters:
iClassName- Class nameiPolymorphic- True if consider also the sub classes, otherwise false- Returns:
- Total entities
-
countView
-
freeze
void freeze()Flush all indexes and cached storage content to the disk.After this call users can perform only select queries. All write-related commands will queued till
release()command will be called.Given command waits till all on going modifications in indexes or DB will be finished.
IMPORTANT: This command is not reentrant.
-
release
void release()Allows to execute write-related commands on DB. Called afterfreeze()command. -
freeze
void freeze(boolean throwException) Flush all indexes and cached storage content to the disk.After this call users can perform only select queries. All write-related commands will queued till
release()command will be called or exception will be thrown on attempt to modify DB data. Concrete behaviour depends onthrowExceptionparameter.IMPORTANT: This command is not reentrant.
- Specified by:
freezein interfaceODatabase<ORecord>- Parameters:
throwException- IftrueOModificationOperationProhibitedExceptionexception will be thrown in case of write command will be performed.
-
browseCluster
Deprecated.Browses all the records of the specified cluster.- Parameters:
iClusterName- Cluster name to iterate- Returns:
- Iterator of ODocument instances
-
browseCluster
@Deprecated <REC extends ORecord> ORecordIteratorCluster<REC> browseCluster(String iClusterName, Class<REC> iRecordClass) Deprecated.Browses all the records of the specified cluster of the passed record type.- Parameters:
iClusterName- Cluster name to iterateiRecordClass- The record class expected- Returns:
- Iterator of ODocument instances
-
browseCluster
@Deprecated <REC extends ORecord> ORecordIteratorCluster<REC> browseCluster(String iClusterName, Class<REC> iRecordClass, long startClusterPosition, long endClusterPosition) Deprecated. -
getRecord
Returns the record for a OIdentifiable instance. If the argument received already is a ORecord instance, then it's returned as is, otherwise a new ORecord is created with the identity received and returned.- Parameters:
iIdentifiable-- Returns:
- A ORecord instance
-
getRecordType
Deprecated.Returns the default record type for this kind of database. -
checkSecurity
<DB extends ODatabaseDocument> DB checkSecurity(ORule.ResourceGeneric resourceGeneric, String resourceSpecific, int iOperation) Checks if the operation on a resource is allowed for the current user.- Parameters:
resourceGeneric- Generic Resource where to execute the operationresourceGeneric- Specific resource name where to execute the operationiOperation- Operation to execute against the resource- Returns:
- The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
-
checkSecurity
<DB extends ODatabaseDocument> DB checkSecurity(ORule.ResourceGeneric iResourceGeneric, int iOperation, Object iResourceSpecific) Checks if the operation on a resource is allowed for the current user. The check is made in two steps:- Access to all the resource as *
- Access to the specific target resource
- Parameters:
iResourceGeneric- Resource where to execute the operation, i.e.: database.clustersiOperation- Operation to execute against the resourceiResourceSpecific- Target resource, i.e.: "employee" to specify the cluster name.- Returns:
- The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
-
checkSecurity
<DB extends ODatabaseDocument> DB checkSecurity(ORule.ResourceGeneric iResourceGeneric, int iOperation, Object... iResourcesSpecific) Checks if the operation against multiple resources is allowed for the current user. The check is made in two steps:- Access to all the resource as *
- Access to the specific target resources
- Parameters:
iResourceGeneric- Resource where to execute the operation, i.e.: database.clustersiOperation- Operation to execute against the resourceiResourcesSpecific- Target resources as an array of Objects, i.e.: ["employee", 2] to specify cluster name and id.- Returns:
- The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
-
isValidationEnabled
boolean isValidationEnabled()Tells if validation of record is active. Default is true.- Returns:
- true if it's active, otherwise false.
-
setValidationEnabled
Enables or disables the record validation.Since 2.2 this setting is persistent.
- Parameters:
iEnabled- True to enable, false to disable- Returns:
- The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
-
isPooled
boolean isPooled()- Returns:
trueif database is obtained from the pool andfalseotherwise.
-
addBlobCluster
Add a cluster for blob records.- Specified by:
addBlobClusterin interfaceODatabase<ORecord>- Parameters:
iClusterName- Cluster nameiParameters- Additional parameters to pass to the factories- Returns:
- Cluster id
-
newElement
OElement newElement() -
newElement
-
newEmbeddedElement
OElement newEmbeddedElement() -
newEmbeddedElement
-
reload
-
newEdge
Creates a new Edge of type E- Parameters:
from- the starting point vertexto- the endpoint vertex- Returns:
- the edge
-
newEdge
Creates a new Edge- Parameters:
from- the starting point vertexto- the endpoint vertextype- the edge type- Returns:
- the edge
-
newEdge
Creates a new Edge- Parameters:
from- the starting point vertexto- the endpoint vertextype- the edge type- Returns:
- the edge
-
newVertex
Creates a new Vertex of type V- Returns:
-
newVertex
Creates a new Vertex- Parameters:
type- the vertex type- Returns:
-
newVertex
Creates a new Vertex- Parameters:
type- the vertex type (class name)- Returns:
-
createVertexClass
creates a new vertex class (a class that extends V)- Parameters:
className- the class name- Returns:
- The object representing the class in the schema
- Throws:
OSchemaException- if the class already exists or if V class is not defined (Eg. if it was deleted from the schema)
-
createEdgeClass
creates a new edge class (a class that extends E)- Parameters:
className- the class name- Returns:
- The object representing the class in the schema
- Throws:
OSchemaException- if the class already exists or if E class is not defined (Eg. if it was deleted from the schema)
-
createClassIfNotExist
default OClass createClassIfNotExist(String className, String... superclasses) throws OSchemaException If a class with given name already exists, it's just returned, otherwise the method creates a new class and returns it.- Parameters:
className- the class namesuperclasses- a list of superclasses for the class (can be empty)- Returns:
- the class with the given name
- Throws:
OSchemaException- if one of the superclasses does not exist in the schema
-