Interface ORecord
- All Superinterfaces:
Comparable<OIdentifiable>,Comparator<OIdentifiable>,OIdentifiable,ORecordElement,OSerializableStream,Serializable
- All Known Implementing Classes:
ODocument,ODocumentEmbedded,OEdgeDelegate,OEdgeDocument,ORecordAbstract,ORecordBytes,ORecordBytesLazy,ORecordFlat,OVertexDelegate,OVertexDocument,OViewDocument
Generic record representation. The object can be reused across multiple calls to the database by
using the
reset() method.-
Nested Class Summary
Nested classes/interfaces inherited from interface com.orientechnologies.orient.core.db.record.ORecordElement
ORecordElement.STATUS -
Method Summary
Modifier and TypeMethodDescription<RET extends ORecord>
RETclear()All the fields are deleted but the record identity is maintained.<RET extends ORecord>
RETcopy()Creates a copy of the record.<RET extends ORecord>
RETdelete()Deprecated.booleandetach()Removes all the dependencies with other records.<RET extends ORecord>
RETFills the record parsing the content in JSON format.Deprecated.Returns the record identity as <cluster-id>:<cluster-position>Returns the current status of the record.intgetSize()Returns the size in bytes of the record.intReturns the current version number of the record.booleanisDirty()Checks if the record is dirty, namely if it was changed in memory.<RET extends ORecord>
RETload()Deprecated.<RET extends ORecord>
RETreload()Deprecated.<RET extends ORecord>
RETDeprecated.<RET extends ORecord>
RETreset()Resets the record to be reused.<RET extends ORecord>
RETsave()Deprecated.<RET extends ORecord>
RETsave(boolean forceCreate) Deprecated.<RET extends ORecord>
RETDeprecated.<RET extends ORecord>
RETDeprecated.voidsetInternalStatus(ORecordElement.STATUS iStatus) Changes the current internal status.toJSON()Exports the record in JSON format.Exports the record in JSON format specifying additional formatting settings.<RET extends ORecord>
RETunload()Unloads current record.Methods inherited from interface java.lang.Comparable
compareToMethods inherited from interface java.util.Comparator
compare, equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongMethods inherited from interface com.orientechnologies.orient.core.db.record.OIdentifiable
getRecord, isLocked, lock, lockingStrategy, unlockMethods inherited from interface com.orientechnologies.orient.core.db.record.ORecordElement
getOwner, setDirty, setDirtyNoChangedMethods inherited from interface com.orientechnologies.orient.core.serialization.OSerializableStream
fromStream, toStream
-
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
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
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
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
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:
getIdentityin interfaceOIdentifiable- 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.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.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.UseODatabaseSession#reload(ORecord, String, boolean)instead.- Throws:
ORecordNotFoundException
-
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.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.UseODatabaseSession#save(ORecord, String)instead.- Returns:
-
save
Deprecated.UseODatabaseSession#save(ORecord, String)instead.- Returns:
-
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
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
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
- 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
Changes the current internal status.- Parameters:
iStatus- status between the values defined in the enumORecordElement.STATUS
-