Class OObjectDatabaseTx
- All Implemented Interfaces:
ODatabaseObject,ODatabase<Object>,ODatabaseInternal<Object>,OUserObject2RecordHandler,OBackupable,Closeable,AutoCloseable
- Author:
- Luca Molino
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.orientechnologies.orient.core.db.ODatabase
ODatabase.ATTRIBUTES, ODatabase.STATUS -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected ODictionary<Object>protected OEntityManagerprotected booleanprotected OMetadataObjectprotected booleanstatic final StringFields inherited from class com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract
databaseOwner, underlying -
Constructor Summary
ConstructorsConstructorDescriptionOObjectDatabaseTx(ODatabaseDocumentInternal iDatabase) Constructor to wrap an existing database connect for object connections -
Method Summary
Modifier and TypeMethodDescriptionintaddBlobCluster(String iClusterName, Object... iParameters) Adds a new cluster for store blobs.void<RET> RETattachAndSave(Object iPojo) begin()Begins a new transaction.begin(OTransaction.TXTYPE iType) Begins a new transaction specifying the transaction type.<RET> OObjectIteratorClass<RET>browseClass(Class<RET> iClusterClass) Browses all the records of the specified class.<RET> OObjectIteratorClass<RET>browseClass(Class<RET> iClusterClass, boolean iPolymorphic) <RET> OObjectIteratorClass<RET>browseClass(String iClassName) <RET> OObjectIteratorClass<RET>browseClass(String iClassName, boolean iPolymorphic) <RET> OObjectIteratorCluster<RET>browseCluster(String iClusterName) Browses all the records of the specified cluster.callbackHooks(ORecordHook.TYPE iType, OIdentifiable iObject) <DBTYPE extends ODatabase>
DBTYPEcheckSecurity(ORule.ResourceGeneric iResource, int iOperation, Object iResourceSpecific) <DBTYPE extends ODatabase>
DBTYPEcheckSecurity(ORule.ResourceGeneric iResource, int iOperation, Object... iResourcesSpecific) <DBTYPE extends ODatabase>
DBTYPEcheckSecurity(ORule.ResourceGeneric resourceGeneric, String resourceSpecific, byte iOperation) Executes a generic (idempotent or non idempotent) command.Executes a generic (idempotent or non idempotent) command.commit()Commits the current transaction.commit(boolean force) protected ObjectconvertParameter(Object iParameter) Convert a parameter: if a POJO is used, then replace it with its record id.protected voidconvertParameters(Object... iArgs) Converts an array of parameters: if a POJO is used, then replace it with its record id.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.Deletes the entity with the received RID from the database.Deletes the entity with the received RID from the database.Deletes an entity from the database in synchronous mode.protected voiddeleteCascade(ODocument record) protected voiddeleteOrphans(OObjectProxyMethodHandler handler) voidderegisterClassMethodFilter(Class<?> iClass) <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.<RET> RETMethod that detaches all fields contained in the document to the given object and recursively all object tree.protected <RET> RETdetachAll(Object iPojo, boolean returnNonProxiedInstance, Map<Object, Object> alreadyDetached, Map<Object, Object> lazyObjects) Execute a script in a specified query language.Execute a script of a specified query language The result set has to be closed after usage
Sample usage:<T> TexecuteWithRetry(int nRetries, Function<ODatabaseSession, T> function) Tries to execute a lambda in a transaction, retrying it if an ONeedRetryException is thrown.booleanexistsUserObjectByRID(ORID iRID) Tells if e user object exists for a certain RecordId.Retrieve the set of defined blob cluster.Returns the current record conflict strategy.Deprecated.Returns the entity manager that handle the binding from ODocuments and POJOs.getHooks()Retrieves all the registered hooks.getIdentity(Object iPojo) Returns the object unique identity.Retrieves all the registered listeners.Return the OMetadata instance.getRecordByUserObject(Object iPojo, boolean iCreateIfNotAvailable) Returns the record associated to a user object.Return active transaction.getType()Return the underlying database.getUser()Returns the current user logged into the database.getUserObjectByRecord(OIdentifiable iRecord, String iFetchPlan) Returns the user object associated to a record.getUserObjectByRecord(OIdentifiable iRecord, String iFetchPlan, boolean iCreate) intgetVersion(Object iPojo) Returns the version number of the object.incrementalBackup(String path) Performs incremental backup of database content to the selected folder.protected voidinit()booleanbooleanbooleanlive(String query, OLiveQueryResultListener listener, Object... args) Subscribe a query as a live query for future create/update event with the referred conditionslive(String query, OLiveQueryResultListener listener, Map<String, ?> args) Subscribe a query as a live query for future create/update event with the referred conditions<RET> RETLoads the entity by the Record ID.<RET> RETLoads the entity by the Record ID using a fetch plan.<RET> RETLoads the entity by the Record ID using a fetch plan and specifying if the cache must be ignored.<RET> RETLoads the entity and return it.<RET> RETLoads a record using a fetch plan.<RET> RETLoads a record using a fetch plan.<RET> RETPessimistic lock a record.<RET> RETPessimistic lock a record.Creates a new entity instance.<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> RETnewInstance(String iClassName, Object iEnclosingClass, ODocument iDocument, Object... iArgs) Create a new POJO by its class name.<RET> RETnewInstance(String iClassName, Object iEnclosingClass, Object... iArgs) Create a new POJO by its class name.<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) Executes an SQL query.Executes an SQL query (idempotent).voidregisterClassMethodFilter(Class<?> iClass, OObjectMethodFilter iMethodFilter) <DBTYPE extends ODatabase<?>>
DBTYPEregisterHook(ORecordHook iHookImpl) Registers a hook to listen all events for Records.<DBTYPE extends ODatabase<?>>
DBTYPEregisterHook(ORecordHook iHookImpl, ORecordHook.HOOK_POSITION iPosition) voidregisterUserObject(Object iObject, ORecord iRecord) Registers the association between a user object and a record.voidregisterUserObjectAfterLinkSave(ORecord iRecord) Registers the saved linked record.<RET> RET<RET> RET<RET> RETForce the reloading of the entity.<RET> RETForce the reloading of the entity.voidrollback()Aborts the current running transaction.rollback(boolean force) <RET> RETSaves an object to the databasein synchronous mode .<RET> RETSaves an object in synchronous mode to the database forcing a record cluster where to store it.<RET> RETSaves an object to the database forcing a record cluster where to store it.voidsetAutomaticSchemaGeneration(boolean automaticSchemaGeneration) setConflictStrategy(ORecordConflictStrategy iResolver) Overrides record conflict strategy.setConflictStrategy(String iStrategyName) Overrides record conflict strategy selecting the strategy by name.voidSets as dirty a POJO.voidsetInternal(ODatabase.ATTRIBUTES attribute, Object iValue) Internal method.voidsetLazyLoading(boolean lazyLoading) voidsetSaveOnlyDirty(boolean saveOnlyDirty) voidsetUser(OSecurityUser user) Set user for current database instance.stream2pojo(ODocument iRecord, Object iPojo, String iFetchPlan) stream2pojo(ODocument iRecord, Object iPojo, String iFetchPlan, boolean iReload) voidPessimistic unlock<DBTYPE extends ODatabase<?>>
DBTYPEunregisterHook(ORecordHook iHookImpl) Unregisters a previously registered hook.voidunregisterPojo(Object iObject, ODocument iRecord) voidunsetDirty(Object iPojo) Sets as not dirty a POJO.Methods inherited from class com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract
activateOnCurrentThread, addCluster, addCluster, backup, checkOpenness, close, countClusterElements, countClusterElements, countClusterElements, dropCluster, dropCluster, equals, existsCluster, freeze, freeze, get, getClusterIdByName, getClusterNameById, getClusterNames, getClusterRecordSizeById, getClusterRecordSizeByName, getClusters, getConfiguration, getDatabaseOwner, getDefaultClusterId, getLocalCache, getName, getProperties, getProperty, getRecordMetadata, getSize, getStatus, getStorage, getURL, isActiveOnCurrentThread, isClosed, registerListener, release, reload, replaceStorage, restore, set, setDatabaseOwner, setProperty, setStatus, toString, truncateCluster, unregisterListenerMethods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.orientechnologies.orient.core.util.OBackupable
backup, restoreMethods inherited from interface com.orientechnologies.orient.core.db.ODatabase
activateOnCurrentThread, addCluster, addCluster, close, countClusterElements, countClusterElements, countClusterElements, createClass, dropCluster, dropCluster, existsCluster, freeze, freeze, get, getClass, getClusterIdByName, getClusterNameById, getClusterNames, getClusterRecordSizeById, getClusterRecordSizeByName, getClusters, getConfiguration, getDefaultClusterId, getLocalCache, getName, getProperties, getProperty, getRecordMetadata, getSize, getStatus, getURL, isActiveOnCurrentThread, isClosed, registerListener, release, reload, set, setProperty, setStatus, truncateCluster, unregisterListenerMethods inherited from interface com.orientechnologies.orient.core.db.ODatabaseInternal
addRidbagPrefetchStats, createInterruptTimerTask, getActiveDataCenterMap, getEnterpriseEndpoint, getLocalNodeName, getStats, isSharded, resetRecordLoadStatsMethods inherited from interface com.orientechnologies.orient.core.db.object.ODatabaseObject
detachAll
-
Field Details
-
TYPE
- See Also:
-
dictionary
-
entityManager
-
saveOnlyDirty
protected boolean saveOnlyDirty -
lazyLoading
protected boolean lazyLoading -
automaticSchemaGeneration
protected boolean automaticSchemaGeneration -
metadata
-
-
Constructor Details
-
OObjectDatabaseTx
Constructor to wrap an existing database connect for object connections- Parameters:
iDatabase- an open database connection
-
-
Method Details
-
newInstance
Description copied from interface:ODatabaseObjectCreates a new entity of the specified class.- Specified by:
newInstancein interfaceODatabaseObject- Parameters:
iType- Class name where to originate the instance- Returns:
- New instance
-
newInstance
- Specified by:
newInstancein interfaceODatabaseObject
-
newInstance
Description copied from interface:ODatabaseObjectCreates a new entity instance. Each database implementation will return the right type.- Specified by:
newInstancein interfaceODatabaseObject- Returns:
- The new instance.
-
getUser
Description copied from interface:ODatabaseReturns the current user logged into the database. -
setUser
Description copied from interface:ODatabaseInternalSet user for current database instance.- Specified by:
setUserin interfaceODatabaseInternal<Object>
-
getMetadata
Description copied from interface:ODatabaseReturn the OMetadata instance. Cannot be null.- Specified by:
getMetadatain interfaceODatabase<Object>- Specified by:
getMetadatain interfaceODatabaseObject- Returns:
- The OMetadata instance.
-
setInternal
Description copied from interface:ODatabaseInternalInternal method. Don't call it directly unless you're building an internal component.- Specified by:
setInternalin interfaceODatabaseInternal<Object>
-
getListeners
Description copied from interface:ODatabaseRetrieves all the registered listeners.- Specified by:
getListenersin interfaceODatabase<Object>- Returns:
- An iterable of ODatabaseListener instances.
-
registerHook
Description copied from interface:ODatabaseRegisters a hook to listen all events for Records.- Specified by:
registerHookin interfaceODatabase<Object>- Parameters:
iHookImpl- ORecordHook implementation- Returns:
- The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
-
registerHook
public <DBTYPE extends ODatabase<?>> DBTYPE registerHook(ORecordHook iHookImpl, ORecordHook.HOOK_POSITION iPosition) - Specified by:
registerHookin interfaceODatabase<Object>
-
callbackHooks
-
getHooks
Description copied from interface:ODatabaseRetrieves all the registered hooks. -
unregisterHook
Description copied from interface:ODatabaseUnregisters a previously registered hook.- Specified by:
unregisterHookin interfaceODatabase<Object>- Parameters:
iHookImpl- ORecordHook implementation- Returns:
- The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain. deprecated since 2.2
-
newInstance
Create a new POJO by its class name. Assure to have called the registerEntityClasses() declaring the packages that are part of entity classes. -
newInstance
public <RET> RET newInstance(String iClassName, Object iEnclosingClass, ODocument iDocument, Object... iArgs) Create a new POJO by its class name. Assure to have called the registerEntityClasses() declaring the packages that are part of entity classes. -
browseClass
Description copied from interface:ODatabaseObjectBrowses all the records of the specified class.- Specified by:
browseClassin interfaceODatabaseObject- Parameters:
iClusterClass- Class name to iterate- Returns:
- Iterator of Object instances
-
browseClass
-
browseClass
- Specified by:
browseClassin interfaceODatabaseObject
-
browseClass
- Specified by:
browseClassin interfaceODatabaseObject
-
browseCluster
Description copied from interface:ODatabaseObjectBrowses all the records of the specified cluster.- Specified by:
browseClusterin interfaceODatabaseObject- Parameters:
iClusterName- Cluster name to iterate- Returns:
- Iterator of Object instances
-
load
Description copied from interface:ODatabaseLoads the entity and return it. -
reload
- Specified by:
reloadin interfaceODatabaseObject
-
reload
- Specified by:
reloadin interfaceODatabaseObject
-
reload
Description copied from interface:ODatabaseForce the reloading of the entity.- Specified by:
reloadin interfaceODatabase<Object>- Specified by:
reloadin interfaceODatabaseObject- Parameters:
iPojo- 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 it- Returns:
- The loaded entity
-
reload
Description copied from interface:ODatabaseForce the reloading of the entity.- Specified by:
reloadin interfaceODatabase<Object>- Specified by:
reloadin interfaceODatabaseObject- 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
-
load
Description copied from interface:ODatabaseLoads a record using a fetch plan. -
attach
- Specified by:
attachin interfaceODatabaseObject
-
attachAndSave
- Specified by:
attachAndSavein interfaceODatabaseObject
-
detach
Method that detaches all fields contained in the document to the given object. It returns by default a proxied instance.- Specified by:
detachin interfaceODatabaseObject- Parameters:
iPojo- :- the object to detach- Returns:
- the detached object
-
detach
Method that detaches all fields contained in the document to the given object.- Specified by:
detachin interfaceODatabaseObject- 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- Specified by:
detachAllin interfaceODatabaseObject- 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
-
load
Description copied from interface:ODatabaseLoads a record using a fetch plan. -
lock
Description copied from interface:ODatabasePessimistic lock a record.In case of lock inside the transaction the lock will be release by the commit operation, In case of lock outside a transaction unlock need to be call manually.
- Specified by:
lockin interfaceODatabase<Object>- Parameters:
recordId- the id of the record that need to be locked- Returns:
- the record updated to the last state after the lock.
- Throws:
OLockException- In case of deadlock detected
-
lock
Description copied from interface:ODatabasePessimistic lock a record.- Specified by:
lockin interfaceODatabase<Object>- Parameters:
recordId- the id of the record that need to be lockedtimeout- for the record lockingtimeoutUnit- relative for the timeout- Returns:
- the record updated to the last state after the lock.
- Throws:
OLockException- In case of deadlock detected
-
unlock
Description copied from interface:ODatabasePessimistic unlock- Specified by:
unlockin interfaceODatabase<Object>- Parameters:
recordId- the id of the record to unlock- Throws:
OLockException- if the record is not locked.
-
load
Description copied from interface:ODatabaseLoads the entity by the Record ID. -
load
Description copied from interface:ODatabaseLoads the entity by the Record ID using a fetch plan. -
load
Description copied from interface:ODatabaseLoads the entity by the Record ID using a fetch plan and specifying if the cache must be ignored. -
save
Saves an object to the databasein synchronous mode . First checks if the object is new or not. In case it's new a new ODocument is created and bound to the object, otherwise the ODocument is retrieved and updated. The object is introspected using the Java Reflection to extract the field values.
If a multi value (array, collection or map of objects) is passed, then each single object is stored separately. -
save
Saves an object in synchronous mode to the database forcing a record cluster where to store it. First checks if the object is new or not. In case it's new a new ODocument is created and bound to the object, otherwise the ODocument is retrieved and updated. The object is introspected using the Java Reflection to extract the field values.
If a multi value (array, collection or map of objects) is passed, then each single object is stored separately.Before to use the specified cluster a check is made to know if is allowed and figures in the configured and the record is valid following the constraints declared in the schema.
-
save
Saves an object to the database forcing a record cluster where to store it. First checks if the object is new or not. In case it's new a new ODocument is created and bound to the object, otherwise the ODocument is retrieved and updated. The object is introspected using the Java Reflection to extract the field values.
If a multi value (array, collection or map of objects) is passed, then each single object is stored separately.Before to use the specified cluster a check is made to know if is allowed and figures in the configured and the record is valid following the constraints declared in the schema.
- Specified by:
savein interfaceODatabaseInternal<Object>- Parameters:
iPojo- The entity to saveiClusterName- Name of the cluster where to save- See Also:
-
delete
Description copied from interface:ODatabaseDeletes an entity from the database in synchronous mode. -
delete
Description copied from interface:ODatabaseDeletes the entity with the received RID from the database. -
delete
Description copied from interface:ODatabaseDeletes the entity with the received RID from the database. -
delete
-
countClass
Description copied from interface:ODatabaseObjectCounts the entities contained in the specified class and sub classes (polymorphic).- Specified by:
countClassin interfaceODatabaseObject- Parameters:
iClassName- Class name- Returns:
- Total entities
-
countClass
Description copied from interface:ODatabaseObjectCounts the entities contained in the specified class.- Specified by:
countClassin interfaceODatabaseObject- Parameters:
iClassName- Class nameiPolymorphic- True if consider also the sub classes, otherwise false- Returns:
- Total entities
-
countClass
- Specified by:
countClassin interfaceODatabaseObject
-
getDictionary
Deprecated.Returns the Dictionary manual index.- Specified by:
getDictionaryin interfaceODatabase<Object>- Returns:
- ODictionary instance
-
getTransaction
Description copied from interface:ODatabaseReturn active transaction. Cannot be null. If no transaction is active, then a OTransactionNoTx instance is returned.- Specified by:
getTransactionin interfaceODatabase<Object>- Returns:
- OTransaction implementation
-
begin
Description copied from interface:ODatabaseBegins a new transaction. By default the type is OPTIMISTIC. If a previous transaction is running a nested call counter is incremented. A transaction once begun has to be closed by calling theODatabase.commit()orODatabase.rollback(). -
begin
Description copied from interface:ODatabaseBegins a new transaction specifying the transaction type. If a previous transaction is running a nested call counter is incremented. A transaction once begun has to be closed by calling theODatabase.commit()orODatabase.rollback(). -
commit
Description copied from interface:ODatabaseCommits the current transaction. The approach is all or nothing. All changes will be permanent following the storage type. If the operation succeed all the entities changed inside the transaction context will be effective. If the operation fails, all the changed entities will be restored in the data store. -
commit
- Specified by:
commitin interfaceODatabase<Object>- Throws:
OTransactionException
-
rollback
Description copied from interface:ODatabaseAborts the current running transaction. All the pending changed entities will be restored in the data store. -
rollback
- Specified by:
rollbackin interfaceODatabase<Object>- Throws:
OTransactionException
-
getEntityManager
Description copied from interface:ODatabaseObjectReturns the entity manager that handle the binding from ODocuments and POJOs.- Specified by:
getEntityManagerin interfaceODatabaseObject- Returns:
-
getUnderlying
Description copied from interface:ODatabaseInternalReturn the underlying database. Used in wrapper instances to know the down level ODatabase instance.- Specified by:
getUnderlyingin interfaceODatabaseInternal<Object>- Specified by:
getUnderlyingin interfaceODatabaseObject- Overrides:
getUnderlyingin classODatabaseWrapperAbstract<ODatabaseDocumentInternal,Object> - Returns:
- The underlying ODatabase implementation.
-
getVersion
Returns the version number of the object. Version starts from 0 assigned on creation.- Parameters:
iPojo- User object
-
getIdentity
Returns the object unique identity.- Specified by:
getIdentityin interfaceODatabaseObject- Parameters:
iPojo- User object
-
isSaveOnlyDirty
public boolean isSaveOnlyDirty() -
setSaveOnlyDirty
public void setSaveOnlyDirty(boolean saveOnlyDirty) -
isAutomaticSchemaGeneration
public boolean isAutomaticSchemaGeneration() -
setAutomaticSchemaGeneration
public void setAutomaticSchemaGeneration(boolean automaticSchemaGeneration) - Specified by:
setAutomaticSchemaGenerationin interfaceODatabaseObject
-
newInstance
Description copied from interface:ODatabaseCreates a new entity instance.- Specified by:
newInstancein interfaceODatabase<Object>- Returns:
- The new instance.
-
checkSecurity
public <DBTYPE extends ODatabase> DBTYPE checkSecurity(ORule.ResourceGeneric resourceGeneric, String resourceSpecific, byte iOperation) -
checkSecurity
public <DBTYPE extends ODatabase> DBTYPE checkSecurity(ORule.ResourceGeneric iResource, int iOperation, Object iResourceSpecific) -
checkSecurity
public <DBTYPE extends ODatabase> DBTYPE checkSecurity(ORule.ResourceGeneric iResource, int iOperation, Object... iResourcesSpecific) -
pojo2Stream
- Specified by:
pojo2Streamin interfaceODatabaseObject
-
stream2pojo
- Specified by:
stream2pojoin interfaceODatabaseObject
-
stream2pojo
-
isLazyLoading
public boolean isLazyLoading()- Specified by:
isLazyLoadingin interfaceODatabaseObject
-
setLazyLoading
public void setLazyLoading(boolean lazyLoading) - Specified by:
setLazyLoadingin interfaceODatabaseObject
-
getType
-
getConflictStrategy
Description copied from interface:ODatabaseReturns the current record conflict strategy.- Specified by:
getConflictStrategyin interfaceODatabase<Object>
-
setConflictStrategy
Description copied from interface:ODatabaseOverrides record conflict strategy.- Specified by:
setConflictStrategyin interfaceODatabase<Object>- Parameters:
iResolver- ORecordConflictStrategy implementation- Returns:
- The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
-
setConflictStrategy
Description copied from interface:ODatabaseOverrides record conflict strategy selecting the strategy by name.- Specified by:
setConflictStrategyin interfaceODatabase<Object>- Parameters:
iStrategyName- ORecordConflictStrategy strategy name- Returns:
- The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
-
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 interfaceODatabaseObject- Specified by:
getRecordByUserObjectin interfaceOUserObject2RecordHandler- Parameters:
iPojo- User objectiCreateIfNotAvailable- Create the record if not available- Returns:
- The record associated
-
getUserObjectByRecord
Description copied from interface:OUserObject2RecordHandlerReturns the user object associated to a record. If the record is not loaded yet, iFetchPlan will be used as fetch plan.- Specified by:
getUserObjectByRecordin interfaceOUserObject2RecordHandler- Parameters:
iRecord- RecordiFetchPlan- If the record is not loaded yet, use this as fetch plan- Returns:
- The user object associated
-
getUserObjectByRecord
-
registerUserObject
Description copied from interface:OUserObject2RecordHandlerRegisters the association between a user object and a record.- Specified by:
registerUserObjectin interfaceOUserObject2RecordHandler- Parameters:
iObject- User objectiRecord- record
-
registerUserObjectAfterLinkSave
Description copied from interface:OUserObject2RecordHandlerRegisters the saved linked record. Needed only to make the old object database implementation work- Specified by:
registerUserObjectAfterLinkSavein interfaceOUserObject2RecordHandler- Parameters:
iRecord- record
-
unregisterPojo
-
existsUserObjectByRID
Description copied from interface:OUserObject2RecordHandlerTells if e user object exists for a certain RecordId.- Specified by:
existsUserObjectByRIDin interfaceOUserObject2RecordHandler
-
registerClassMethodFilter
-
deregisterClassMethodFilter
-
incrementalBackup
Description copied from interface:ODatabasePerforms incremental backup of database content to the selected folder. This is thread safe operation and can be done in normal operational mode.If it will be first backup of data full content of database will be copied into folder otherwise only changes after last backup in the same folder will be copied.
- Specified by:
incrementalBackupin interfaceODatabase<Object>- Parameters:
path- Path to backup folder.- Returns:
- File name of the backup
-
resetInitialization
public void resetInitialization()- Specified by:
resetInitializationin interfaceODatabaseInternal<Object>
-
detachAll
-
deleteCascade
-
init
protected void init() -
deleteOrphans
-
addBlobCluster
Description copied from interface:ODatabaseAdds a new cluster for store blobs.- Specified by:
addBlobClusterin interfaceODatabase<Object>- Parameters:
iClusterName- Cluster nameiParameters- Additional parameters to pass to the factories- Returns:
- Cluster id
-
getBlobClusterIds
Description copied from interface:ODatabaseRetrieve the set of defined blob cluster.- Specified by:
getBlobClusterIdsin interfaceODatabase<Object>- Returns:
- the set of defined blob cluster ids.
-
convertParameters
Converts an array of parameters: if a POJO is used, then replace it with its record id.- Parameters:
iArgs- Array of parameters as Object- See Also:
-
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.- Specified by:
setDirtyin interfaceODatabaseObject- 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.- Specified by:
unsetDirtyin interfaceODatabaseObject- Parameters:
iPojo- User object
-
convertParameter
Convert a parameter: if a POJO is used, then replace it with its record id.- Parameters:
iParameter- Parameter to convert, if applicable- See Also:
-
live
Description copied from interface:ODatabaseSubscribe a query as a live query for future create/update event with the referred conditions -
live
Description copied from interface:ODatabaseSubscribe a query as a live query for future create/update event with the referred conditions -
query
public OResultSet query(String query, Object... args) throws OCommandSQLParsingException, OCommandExecutionException Description copied from interface:ODatabaseExecutes an SQL query. The result set has to be closed after usage
Sample usage:OResultSet rs = db.query("SELECT FROM V where name = ?", "John"); while(rs.hasNext()){ OResult item = rs.next(); ... } rs.close();- Specified by:
queryin interfaceODatabase<Object>- Parameters:
query- the query stringargs- query parameters (positional)- Returns:
- the query result set
- Throws:
OCommandSQLParsingExceptionOCommandExecutionException
-
query
public OResultSet query(String query, Map args) throws OCommandSQLParsingException, OCommandExecutionException Description copied from interface:ODatabaseExecutes an SQL query (idempotent). The result set has to be closed after usage
Sample usage:Map<String, Object> params = new HashMapMap<>(); params.put("name", "John"); OResultSet rs = db.query("SELECT FROM V where name = :name", params); while(rs.hasNext()){ OResult item = rs.next(); ... } rs.close();- Specified by:
queryin interfaceODatabase<Object>- Parameters:
query- the query stringargs- query parameters (named)- Returns:
- Throws:
OCommandSQLParsingExceptionOCommandExecutionException
-
command
public OResultSet command(String query, Object... args) throws OCommandSQLParsingException, OCommandExecutionException Description copied from interface:ODatabaseExecutes a generic (idempotent or non idempotent) command. The result set has to be closed after usage
Sample usage:OResultSet rs = db.command("INSERT INTO Person SET name = ?", "John"); ... rs.close();- Specified by:
commandin interfaceODatabase<Object>args- query arguments- Returns:
- Throws:
OCommandSQLParsingExceptionOCommandExecutionException
-
objectQuery
- Specified by:
objectQueryin interfaceODatabaseObject
-
objectQuery
- Specified by:
objectQueryin interfaceODatabaseObject
-
objectCommand
- Specified by:
objectCommandin interfaceODatabaseObject
-
objectCommand
- Specified by:
objectCommandin interfaceODatabaseObject
-
command
public OResultSet command(String query, Map args) throws OCommandSQLParsingException, OCommandExecutionException Description copied from interface:ODatabaseExecutes a generic (idempotent or non idempotent) command. The result set has to be closed after usage
Sample usage:Map<String, Object> params = new HashMapMap<>(); params.put("name", "John"); OResultSet rs = db.query("INSERT INTO Person SET name = :name", params); ... rs.close();- Specified by:
commandin interfaceODatabase<Object>- Returns:
- Throws:
OCommandSQLParsingExceptionOCommandExecutionException
-
execute
public OResultSet execute(String language, String script, Object... args) throws OCommandExecutionException, OCommandScriptException Description copied from interface:ODatabaseExecute a script in a specified query language. The result set has to be closed after usage
Sample usage:String script = "INSERT INTO Person SET name = 'foo', surname = ?;"+ "INSERT INTO Person SET name = 'bar', surname = ?;"+ "INSERT INTO Person SET name = 'baz', surname = ?;";OResultSet rs = db.execute("sql", script, "Surname1", "Surname2", "Surname3"); ... rs.close();
- Specified by:
executein interfaceODatabase<Object>- Returns:
- Throws:
OCommandExecutionExceptionOCommandScriptException
-
execute
public OResultSet execute(String language, String script, Map<String, ?> args) throws OCommandExecutionException, OCommandScriptExceptionDescription copied from interface:ODatabaseExecute a script of a specified query language The result set has to be closed after usage
Sample usage:Map<String, Object> params = new HashMapMap<>(); params.put("surname1", "Jones"); params.put("surname2", "May"); params.put("surname3", "Ali");String script = "INSERT INTO Person SET name = 'foo', surname = :surname1;"+ "INSERT INTO Person SET name = 'bar', surname = :surname2;"+ "INSERT INTO Person SET name = 'baz', surname = :surname3;";
OResultSet rs = db.execute("sql", script, params); ... rs.close();
- Specified by:
executein interfaceODatabase<Object>- Returns:
- Throws:
OCommandExecutionExceptionOCommandScriptException
-
executeWithRetry
public <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>- Specified by:
executeWithRetryin interfaceODatabaseObject- 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
-
getStorageInfo
- Specified by:
getStorageInfoin interfaceODatabaseInternal<Object>
-