Interface ORecord

All Superinterfaces:
Comparable<OIdentifiable>, Comparator<OIdentifiable>, OIdentifiable, ORecordElement, OSerializableStream, Serializable
All Known Subinterfaces:
OBlob, OEdge, OElement, OVertex
All Known Implementing Classes:
ODocument, ODocumentEmbedded, OEdgeDelegate, OEdgeDocument, ORecordAbstract, ORecordBytes, ORecordBytesLazy, ORecordFlat, OVertexDelegate, OVertexDocument, OViewDocument

public interface ORecord extends ORecordElement, OIdentifiable, Serializable, OSerializableStream
Generic record representation. The object can be reused across multiple calls to the database by using the reset() method.
  • Method Details

    • detach

      boolean detach()
      Removes all the dependencies with other records. All the relationships remain in form of RecordID. If some links contain dirty records, the detach cannot be complete and this method returns false.
      Returns:
      True if the document has been successfully detached, otherwise false.
    • reset

      <RET extends ORecord> RET reset()
      Resets the record to be reused. The record is fresh like just created. Use this method to recycle records avoiding the creation of them stressing the JVM Garbage Collector.
      Returns:
      The Object instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • unload

      <RET extends ORecord> RET unload()
      Unloads current record. All information are lost but the record identity. At the next access the record will be auto-reloaded. Useful to free memory or to avoid to keep an old version of it.
      Returns:
      The Object instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • clear

      <RET extends ORecord> RET clear()
      All the fields are deleted but the record identity is maintained. Use this to remove all the document's fields.
      Returns:
      The Object instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • copy

      <RET extends ORecord> RET copy()
      Creates a copy of the record. All the record contents are copied.
      Returns:
      The Object instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • getIdentity

      ORID getIdentity()
      Returns the record identity as <cluster-id>:<cluster-position>
      Specified by:
      getIdentity in interface OIdentifiable
      Returns:
      ORID instance
    • getVersion

      int getVersion()
      Returns the current version number of the record. When the record is created has version = 0. At every change the storage increment the version number. Version number is used by Optimistic transactions to check if the record is changed in the meanwhile of the transaction.
      Returns:
      The version number. 0 if it's a brand new record.
      See Also:
    • getDatabase

      Deprecated.
      Returns the database where the record belongs.
      Returns:
    • isDirty

      boolean isDirty()
      Checks if the record is dirty, namely if it was changed in memory.
      Returns:
      True if dirty, otherwise false
    • load

      @Deprecated <RET extends ORecord> RET load() throws ORecordNotFoundException
      Deprecated.
      Loads the record content in memory. If the record is in cache will be returned a new instance, so pay attention to use the returned. If the record is dirty, then it returns to the original content. If the record does not exist a ORecordNotFoundException exception is thrown.

      Use ODatabaseSession#load(ORecord) instead.

      Returns:
      The record loaded or itself if the record has been reloaded from the storage. Useful to call methods in chain.
      Throws:
      ORecordNotFoundException
    • reload

      @Deprecated <RET extends ORecord> RET reload() throws ORecordNotFoundException
      Deprecated.
      Loads the record content in memory. No cache is used. If the record is dirty, then it returns to the original content. If the record does not exist a ORecordNotFoundException exception is thrown.

      Use ODatabaseDocument.reload(OElement) instead.

      Returns:
      The Object instance itself giving a "fluent interface". Useful to call multiple methods in chain.
      Throws:
      ORecordNotFoundException
    • reload

      @Deprecated <RET extends ORecord> RET reload(String fetchPlan, boolean ignoreCache, boolean force) throws ORecordNotFoundException
      Deprecated.
      Use ODatabaseSession#reload(ORecord, String, boolean) instead.
      Throws:
      ORecordNotFoundException
    • save

      @Deprecated <RET extends ORecord> RET save()
      Deprecated.
      Saves in-memory changes to the database. Behavior depends by the current running transaction if any. If no transaction is running then changes apply immediately. If an Optimistic transaction is running then the record will be changed at commit time. The current transaction will continue to see the record as modified, while others not. If a Pessimistic transaction is running, then an exclusive lock is acquired against the record. Current transaction will continue to see the record as modified, while others cannot access to it since it's locked.

      Use ODatabaseSession#save(ORecord) instead.

      Returns:
      The Object instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • save

      @Deprecated <RET extends ORecord> RET save(String iCluster)
      Deprecated.
      Saves in-memory changes to the database defining a specific cluster where to save it. Behavior depends by the current running transaction if any. If no transaction is running then changes apply immediately. If an Optimistic transaction is running then the record will be changed at commit time. The current transaction will continue to see the record as modified, while others not. If a Pessimistic transaction is running, then an exclusive lock is acquired against the record. Current transaction will continue to see the record as modified, while others cannot access to it since it's locked.

      Use ODatabaseSession#save(ORecord, String) instead.

      Returns:
      The Object instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • save

      @Deprecated <RET extends ORecord> RET save(boolean forceCreate)
      Deprecated.
      Use ODatabaseSession#save(ORecord, String) instead.
      Returns:
    • save

      @Deprecated <RET extends ORecord> RET save(String iCluster, boolean forceCreate)
      Deprecated.
      Use ODatabaseSession#save(ORecord, String) instead.
      Returns:
    • delete

      @Deprecated <RET extends ORecord> RET delete()
      Deprecated.
      Deletes the record from the database. Behavior depends by the current running transaction if any. If no transaction is running then the record is deleted immediately. If an Optimistic transaction is running then the record will be deleted at commit time. The current transaction will continue to see the record as deleted, while others not. If a Pessimistic transaction is running, then an exclusive lock is acquired against the record. Current transaction will continue to see the record as deleted, while others cannot access to it since it's locked.
      Returns:
      The Object instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • fromJSON

      <RET extends ORecord> RET fromJSON(String iJson)
      Fills the record parsing the content in JSON format.
      Parameters:
      iJson - Object content in JSON format
      Returns:
      The Object instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • toJSON

      String toJSON()
      Exports the record in JSON format.
      Returns:
      Object content in JSON format
    • toJSON

      String toJSON(String iFormat)
      Exports the record in JSON format specifying additional formatting settings.
      Parameters:
      iFormat - Format settings separated by comma. Available settings are:
      • rid: exports the record's id as property "@rid"
      • version: exports the record's version as property "@version"
      • class: exports the record's class as property "@class"
      • attribSameRow: exports all the record attributes in the same row
      • indent:<level>: Indents the output if the <level> specified. Default is 0
      Example: "rid,version,class,indent:6" exports record id, version and class properties along with record properties using an indenting level equals of 6.
      Returns:
      Object content in JSON format
    • getSize

      int getSize()
      Returns the size in bytes of the record. The size can be computed only for not new records.
      Returns:
      the size in bytes
    • getInternalStatus

      ORecordElement.STATUS getInternalStatus()
      Returns the current status of the record.
      Returns:
      Current status as value between the defined values in the enum ORecordElement.STATUS
    • setInternalStatus

      void setInternalStatus(ORecordElement.STATUS iStatus)
      Changes the current internal status.
      Parameters:
      iStatus - status between the values defined in the enum ORecordElement.STATUS