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

public interface ODatabaseDocument extends ODatabase<ORecord>
Generic interface for document based Database implementations.
Author:
Luca Garulli (l.garulli--(at)--orientdb.com)
  • Field Details

  • 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 ORecordIteratorClass<ODocument> browseClass(String iClassName, boolean iPolymorphic)
      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 iterate
      iPolymorphic - Consider also the instances of the subclasses or not
      Returns:
      Iterator of ODocument instances
    • newInstance

      <RET> RET newInstance(String iClassName)
      Creates a new entity instance. Each database implementation will return the right type.
      Returns:
      The new instance.
    • newBlob

      OBlob newBlob(byte[] bytes)
      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

      long countClass(String iClassName)
      Counts the entities contained in the specified class and sub classes (polymorphic).
      Parameters:
      iClassName - Class name
      Returns:
      Total entities
    • countClass

      long countClass(String iClassName, boolean iPolymorphic)
      Counts the entities contained in the specified class.
      Parameters:
      iClassName - Class name
      iPolymorphic - True if consider also the sub classes, otherwise false
      Returns:
      Total entities
    • countView

      long countView(String iClassName)
    • 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.

      Specified by:
      freeze in interface ODatabase<ORecord>
      See Also:
    • release

      void release()
      Allows to execute write-related commands on DB. Called after freeze() command.
      Specified by:
      release in interface ODatabase<ORecord>
      See Also:
    • 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 on throwException parameter.

      IMPORTANT: This command is not reentrant.

      Specified by:
      freeze in interface ODatabase<ORecord>
      Parameters:
      throwException - If true OModificationOperationProhibitedException exception will be thrown in case of write command will be performed.
    • browseCluster

      @Deprecated <REC extends ORecord> ORecordIteratorCluster<REC> browseCluster(String iClusterName)
      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 iterate
      iRecordClass - 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

      <RET extends ORecord> RET getRecord(OIdentifiable iIdentifiable)
      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 byte 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 operation
      resourceGeneric - Specific resource name where to execute the operation
      iOperation - 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:
      1. Access to all the resource as *
      2. Access to the specific target resource
      Parameters:
      iResourceGeneric - Resource where to execute the operation, i.e.: database.clusters
      iOperation - Operation to execute against the resource
      iResourceSpecific - 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:
      1. Access to all the resource as *
      2. Access to the specific target resources
      Parameters:
      iResourceGeneric - Resource where to execute the operation, i.e.: database.clusters
      iOperation - Operation to execute against the resource
      iResourcesSpecific - 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

      <DB extends ODatabaseDocument> DB setValidationEnabled(boolean iEnabled)
      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:
      true if database is obtained from the pool and false otherwise.
    • addBlobCluster

      int addBlobCluster(String iClusterName, Object... iParameters)
      Add a cluster for blob records.
      Specified by:
      addBlobCluster in interface ODatabase<ORecord>
      Parameters:
      iClusterName - Cluster name
      iParameters - Additional parameters to pass to the factories
      Returns:
      Cluster id
    • newElement

      OElement newElement()
    • newElement

      OElement newElement(String className)
    • newEmbeddedElement

      OElement newEmbeddedElement()
    • newEmbeddedElement

      OElement newEmbeddedElement(String className)
    • reload

      default OElement reload(OElement element)
    • newEdge

      default OEdge newEdge(OVertex from, OVertex to)
      Creates a new Edge of type E
      Parameters:
      from - the starting point vertex
      to - the endpoint vertex
      Returns:
      the edge
    • newEdge

      OEdge newEdge(OVertex from, OVertex to, OClass type)
      Creates a new Edge
      Parameters:
      from - the starting point vertex
      to - the endpoint vertex
      type - the edge type
      Returns:
      the edge
    • newEdge

      OEdge newEdge(OVertex from, OVertex to, String type)
      Creates a new Edge
      Parameters:
      from - the starting point vertex
      to - the endpoint vertex
      type - the edge type
      Returns:
      the edge
    • newVertex

      default OVertex newVertex()
      Creates a new Vertex of type V
      Returns:
    • newVertex

      OVertex newVertex(OClass type)
      Creates a new Vertex
      Parameters:
      type - the vertex type
      Returns:
    • newVertex

      OVertex newVertex(String type)
      Creates a new Vertex
      Parameters:
      type - the vertex type (class name)
      Returns:
    • createVertexClass

      default OClass createVertexClass(String className) throws OSchemaException
      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

      default OClass createEdgeClass(String className)
      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 name
      superclasses - 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