Interface ODatabaseObject
- All Superinterfaces:
AutoCloseable,Closeable,OBackupable,ODatabase<Object>,OUserObject2RecordHandler
- All Known Implementing Classes:
OObjectDatabaseTx,OObjectDatabaseTxPooled
Generic interface for object based Database implementations. Binds to/from Document and POJOs.
- 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.OPERATION_MODE, ODatabase.STATUS -
Method Summary
Modifier and TypeMethodDescription<RET> OObjectIteratorClassInterface<RET>browseClass(Class<RET> iClusterClass) Browses all the records of the specified class.<RET> OObjectIteratorClusterInterface<RET>browseCluster(String iClusterName) Browses all the records of the specified cluster.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.<RET> RETMethod that detaches all fields contained in the document to the given object.<RET> RETMethod that detaches all fields contained in the document to the given object.default <RET> RETMethod that detaches all fields contained in the document to the given object and recursively all object tree.<RET> RETMethod that detaches all fields contained in the document to the given object and recursively all object tree.default <T> TexecuteWithRetry(int nRetries, Function<ODatabaseSession, T> function) Tries to execute a lambda in a transaction, retrying it if an ONeedRetryException is thrown.Returns the entity manager that handle the binding from ODocuments and POJOs.Return the OMetadata instance.booleanboolean<T> TnewInstance(Class<T> iType) Creates a new entity of the specified class.<RET> RETnewInstance(String iClassName) Creates a new entity instance.<RET extends List<?>>
RETobjectCommand(String iCommand, Object... iArgs) <RET extends List<?>>
RETobjectCommand(String iCommand, Map<String, Object> iArgs) <RET extends List<?>>
RETobjectQuery(String iCommand, Object... iArgs) <RET extends List<?>>
RETobjectQuery(String iCommand, Map<String, Object> iArgs) pojo2Stream(Object iPojo, ODocument iRecord) voidSets as dirty a POJO.voidsetLazyLoading(boolean lazyLoading) setRetainObjects(boolean iRetainObjects) stream2pojo(ODocument iRecord, Object iPojo, String iFetchPlan) voidunsetDirty(Object iPojo) Sets as not dirty a POJO.Methods inherited from interface com.orientechnologies.orient.core.util.OBackupable
backup, restoreMethods inherited from interface com.orientechnologies.orient.core.db.ODatabase
activateOnCurrentThread, addBlobCluster, addCluster, addCluster, begin, begin, begin, close, command, command, command, commit, commit, countClusterElements, countClusterElements, countClusterElements, countClusterElements, countClusterElements, create, create, create, createClass, declareIntent, delete, delete, delete, drop, dropCluster, dropCluster, execute, execute, exists, existsCluster, freeze, freeze, get, getActiveIntent, getBlobClusterIds, getClass, getClusterIdByName, getClusterNameById, getClusterNames, getClusterRecordSizeById, getClusterRecordSizeByName, getClusters, getConfiguration, getConflictStrategy, getDefaultClusterId, getDictionary, getHooks, getListeners, getLocalCache, getName, getProperties, getProperty, getRecordMetadata, getSize, getStatus, getTransaction, getType, getURL, getUser, incrementalBackup, isActiveOnCurrentThread, isClosed, isMVCC, live, live, load, load, load, load, load, load, lock, lock, newInstance, open, query, query, query, registerHook, registerHook, registerListener, release, reload, reload, reload, rollback, rollback, save, save, save, save, set, setConflictStrategy, setConflictStrategy, setMVCC, setProperty, setStatus, truncateCluster, unlock, unregisterHook, unregisterListenerMethods inherited from interface com.orientechnologies.orient.core.db.OUserObject2RecordHandler
existsUserObjectByRID, getRecordByUserObject, getUserObjectByRecord, registerUserObject, registerUserObjectAfterLinkSave
-
Method Details
-
setDirty
Sets as dirty a POJO. This is useful when you change the object and need to tell to the engine to treat as dirty.- Parameters:
iPojo- User object
-
unsetDirty
Sets as not dirty a POJO. This is useful when you change some other object and need to tell to the engine to treat this one as not dirty.- Parameters:
iPojo- User object
-
browseCluster
Browses all the records of the specified cluster.- Parameters:
iClusterName- Cluster name to iterate- Returns:
- Iterator of Object instances
-
browseClass
Browses all the records of the specified class.- Parameters:
iClusterClass- Class name to iterate- Returns:
- Iterator of Object instances
-
newInstance
Creates a new entity instance. Each database implementation will return the right type.- Returns:
- The new 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
-
newInstance
Creates a new entity of the specified class.- Parameters:
iType- Class name where to originate the instance- Returns:
- New instance
-
getEntityManager
OEntityManager getEntityManager()Returns the entity manager that handle the binding from ODocuments and POJOs.- Returns:
-
detach
Method that detaches all fields contained in the document to the given object. It returns by default a proxied instance. To get a detached non proxied instance @see {@link OObjectEntitySerializer.detach(T, ODatabaseObject)}- Parameters:
iPojo- :- the object to detach- Returns:
- the detached object
-
detach
Method that detaches all fields contained in the document to the given object.- Type Parameters:
RET-- Parameters:
iPojo- :- the object to detachreturnNonProxiedInstance- :- defines if the return object will be a proxied instance or not. If set to TRUE and the object does not contains @Id and @Version fields it could procude data replication- Returns:
- the object serialized or with detached data
-
detachAll
Method that detaches all fields contained in the document to the given object and recursively all object tree. This may throw aStackOverflowErrorwith big objects tree. To avoid it set the stack size with -Xss java option- Type Parameters:
RET-- Parameters:
iPojo- :- the objects to detach- Returns:
- the object serialized or with detached data
-
detachAll
Method that detaches all fields contained in the document to the given object and recursively all object tree. This may throw aStackOverflowErrorwith big objects tree. To avoid it set the stack size with -Xss java option- Type Parameters:
RET-- Parameters:
iPojo- :- the objects to detachreturnNonProxiedInstance- :- defines if the return object will be a proxied instance or not. If set to TRUE and the object does not contains @Id and @Version fields it could procude data replication- Returns:
- the object serialized or with detached data
-
isRetainObjects
boolean isRetainObjects() -
setRetainObjects
-
stream2pojo
-
pojo2Stream
-
isLazyLoading
boolean isLazyLoading() -
setLazyLoading
void setLazyLoading(boolean lazyLoading) -
getMetadata
OMetadataObject getMetadata()Description copied from interface:ODatabaseReturn the OMetadata instance. Cannot be null.- Specified by:
getMetadatain interfaceODatabase<Object>- Returns:
- The OMetadata instance.
-
objectQuery
-
objectQuery
-
objectCommand
-
objectCommand
-
executeWithRetry
default <T> T executeWithRetry(int nRetries, Function<ODatabaseSession, T> function) throws IllegalStateException, IllegalArgumentException, ONeedRetryException, UnsupportedOperationExceptionDescription copied from interface:ODatabaseTries to execute a lambda in a transaction, retrying it if an ONeedRetryException is thrown.If the DB does not have an active transaction, after the execution you will still be out of tx.
If the DB has an active transaction, then the transaction has to be empty (no operations executed yet) and after the execution you will be in a new transaction.
- Specified by:
executeWithRetryin interfaceODatabase<Object>- Type Parameters:
T- the return type of the lambda- Parameters:
nRetries- the maximum number of retries (> 0)function- a lambda containing application code to execute in a commit/retry loop- Returns:
- The result of the execution of the lambda
- Throws:
IllegalStateException- if there are operations in the current transactionIllegalArgumentException- if nRetries is <= 0ONeedRetryException- if the maximum number of retries is executed and all failed with an ONeedRetryExceptionUnsupportedOperationException- if this type of database does not support automatic commit/retry
-