Interface ODatabaseObject
- All Superinterfaces:
AutoCloseable,Closeable,OBackupable,ODatabase<Object>,OUserObject2RecordHandler
- All Known Implementing Classes:
OObjectDatabaseTx
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.STATUS -
Method Summary
Modifier and TypeMethodDescriptionvoid<RET> RETattachAndSave(Object iPojo) <RET> OObjectIteratorClassInterface<RET>browseClass(Class<RET> iClusterClass) Browses all the records of the specified class.<RET> OObjectIteratorClassInterface<RET>browseClass(String iClassName) <RET> OObjectIteratorClassInterface<RET>browseClass(String iClassName, boolean iPolymorphic) <RET> OObjectIteratorClusterInterface<RET>browseCluster(String iClusterName) Browses all the records of the specified cluster.longcountClass(Class<?> iClass) 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.getIdentity(Object iPojo) Return the OMetadata instance.getRecordByUserObject(Object iPojo, boolean iCreateIfNotAvailable) Returns the record associated to a user object.boolean<T> TnewInstance(Class<T> iType) Creates a new entity of the specified class.<T> TnewInstance(Class<T> iType, Object... iArgs) <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) <RET> RET<RET> RET<RET> RETForce the reloading of the entity.<RET> RETForce the reloading of the entity.voidsetAutomaticSchemaGeneration(boolean automaticSchemaGeneration) voidSets as dirty a POJO.voidsetLazyLoading(boolean lazyLoading) 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, close, command, command, commit, commit, countClusterElements, countClusterElements, countClusterElements, createClass, delete, delete, delete, dropCluster, dropCluster, execute, execute, existsCluster, freeze, freeze, get, 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, live, live, load, load, load, load, load, load, lock, lock, newInstance, query, query, registerHook, registerHook, registerListener, release, reload, rollback, rollback, save, save, set, setConflictStrategy, setConflictStrategy, setProperty, setStatus, truncateCluster, unlock, unregisterHook, unregisterListenerMethods inherited from interface com.orientechnologies.orient.core.db.OUserObject2RecordHandler
existsUserObjectByRID, 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
-
browseClass
-
browseClass
-
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
-
countClass
-
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
-
stream2pojo
-
pojo2Stream
-
isLazyLoading
boolean isLazyLoading() -
setLazyLoading
void setLazyLoading(boolean lazyLoading) -
setAutomaticSchemaGeneration
void setAutomaticSchemaGeneration(boolean automaticSchemaGeneration) -
getIdentity
-
reload
-
reload
-
reload
Description copied from interface:ODatabaseForce the reloading of the entity. -
reload
Description copied from interface:ODatabaseForce the reloading of the entity.- Specified by:
reloadin interfaceODatabase<Object>- Parameters:
iObject- The entity to load. If the entity was already loaded it will be reloaded and all the changes will be lost.iFetchPlan- Fetch plan usediIgnoreCache- Ignore cache or use itforce- Force to reload record even if storage has the same record as reloaded record, it is useful if fetch plan is not null and alongside with root record linked records will be reloaded.- Returns:
- The loaded entity
-
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
-
newInstance
-
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
-
getUnderlying
ODatabaseDocument getUnderlying() -
getRecordByUserObject
Description copied from interface:OUserObject2RecordHandlerReturns the record associated to a user object. If iCreateIfNotAvailable is true, then a new record instance will be created transparently.- Specified by:
getRecordByUserObjectin interfaceOUserObject2RecordHandler- Parameters:
iPojo- User objectiCreateIfNotAvailable- Create the record if not available- Returns:
- The record associated
-
attach
-
attachAndSave
-