public class OObjectDatabaseTx extends ODatabaseWrapperAbstract<ODatabaseDocumentInternal,Object> implements ODatabaseObject
ODatabaseDocumentTx
ODatabase.ATTRIBUTES, ODatabase.OPERATION_MODE, ODatabase.STATUS
Modifier and Type | Field and Description |
---|---|
protected boolean |
automaticSchemaGeneration |
protected ODictionary<Object> |
dictionary |
protected OEntityManager |
entityManager |
protected boolean |
lazyLoading |
protected OMetadataObject |
metadata |
protected boolean |
saveOnlyDirty |
static String |
TYPE |
databaseOwner, underlying
Constructor and Description |
---|
OObjectDatabaseTx(ODatabaseDocumentInternal iDatabase)
Constructor to wrap an existing database connect for object connections
|
OObjectDatabaseTx(String iURL) |
Modifier and Type | Method and Description |
---|---|
int |
addBlobCluster(String iClusterName,
Object... iParameters)
Adds a new cluster for store blobs.
|
void |
attach(Object iPojo) |
<RET> RET |
attachAndSave(Object iPojo) |
OObjectDatabaseTx |
begin()
Begins a new transaction.
|
OObjectDatabaseTx |
begin(OTransaction.TXTYPE iType)
Begins a new transaction specifying the transaction type.
|
OObjectDatabaseTx |
begin(OTransaction iTx)
Attaches a transaction as current.
|
<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.
|
ORecordHook.RESULT |
callbackHooks(ORecordHook.TYPE iType,
OIdentifiable iObject) |
<DBTYPE extends ODatabase> |
checkSecurity(ORule.ResourceGeneric iResource,
int iOperation,
Object... iResourcesSpecific) |
<DBTYPE extends ODatabase> |
checkSecurity(ORule.ResourceGeneric iResource,
int iOperation,
Object iResourceSpecific) |
<DBTYPE extends ODatabase> |
checkSecurity(ORule.ResourceGeneric resourceGeneric,
String resourceSpecific,
byte iOperation) |
<RET extends OCommandRequest> |
command(OCommandRequest iCommand)
Returns a wrapped OCommandRequest instance to catch the result-set by converting it before to
return to the user application.
|
OResultSet |
command(String query,
Map args)
Executes a generic (idempotent or non idempotent) command.
|
OResultSet |
command(String query,
Object... args)
Executes a generic (idempotent or non idempotent) command.
|
OObjectDatabaseTx |
commit()
Commits the current transaction.
|
OObjectDatabaseTx |
commit(boolean force) |
protected Object |
convertParameter(Object iParameter)
Convert a parameter: if a POJO is used, then replace it with its record id.
|
protected void |
convertParameters(Object... iArgs)
Converts an array of parameters: if a POJO is used, then replace it with its record id.
|
long |
countClass(Class<?> iClass) |
long |
countClass(String iClassName)
Counts the entities contained in the specified class and sub classes (polymorphic).
|
long |
countClass(String iClassName,
boolean iPolymorphic)
Counts the entities contained in the specified class.
|
ODatabaseObject |
delete(Object iPojo)
Deletes an entity from the database in synchronous mode.
|
ODatabaseObject |
delete(ORecord iRecord) |
ODatabaseObject |
delete(ORID iRID)
Deletes the entity with the received RID from the database.
|
ODatabaseObject |
delete(ORID iRID,
int iVersion)
Deletes the entity with the received RID from the database.
|
protected void |
deleteCascade(ODocument record) |
protected void |
deleteOrphans(OObjectProxyMethodHandler handler) |
void |
deregisterClassMethodFilter(Class<?> iClass) |
<RET> RET |
detach(Object iPojo)
Method that detaches all fields contained in the document to the given object.
|
<RET> RET |
detach(Object iPojo,
boolean returnNonProxiedInstance)
Method that detaches all fields contained in the document to the given object.
|
<RET> RET |
detachAll(Object iPojo,
boolean returnNonProxiedInstance)
Method that detaches all fields contained in the document to the given object and recursively
all object tree.
|
protected <RET> RET |
detachAll(Object iPojo,
boolean returnNonProxiedInstance,
Map<Object,Object> alreadyDetached,
Map<Object,Object> lazyObjects) |
OResultSet |
execute(String language,
String script,
Map<String,?> args)
Execute a script of a specified query language The result set has to be closed after usage
Sample usage: |
OResultSet |
execute(String language,
String script,
Object... args)
Execute a script in a specified query language.
|
<T> T |
executeWithRetry(int nRetries,
Function<ODatabaseSession,T> function)
Tries to execute a lambda in a transaction, retrying it if an ONeedRetryException is thrown.
|
boolean |
existsUserObjectByRID(ORID iRID)
Tells if e user object exists for a certain RecordId.
|
Set<Integer> |
getBlobClusterIds()
Retrieve the set of defined blob cluster.
|
ORecordConflictStrategy |
getConflictStrategy()
Returns the current record conflict strategy.
|
ODictionary<Object> |
getDictionary()
Deprecated.
|
OEntityManager |
getEntityManager()
Returns the entity manager that handle the binding from ODocuments and POJOs.
|
Map<ORecordHook,ORecordHook.HOOK_POSITION> |
getHooks()
Retrieves all the registered hooks.
|
ORID |
getIdentity(Object iPojo)
Returns the object unique identity.
|
Iterable<ODatabaseListener> |
getListeners()
Retrieves all the registered listeners.
|
OMetadataObject |
getMetadata()
Return the OMetadata instance.
|
ODocument |
getRecordByUserObject(Object iPojo,
boolean iCreateIfNotAvailable)
Returns the record associated to a user object.
|
OSharedContext |
getSharedContext() |
OStorageInfo |
getStorageInfo() |
OTransaction |
getTransaction()
Return active transaction.
|
String |
getType() |
ODatabaseDocumentInternal |
getUnderlying()
Return the underlying database.
|
OSecurityUser |
getUser()
Returns the current user logged into the database.
|
Object |
getUserObjectByRecord(OIdentifiable iRecord,
String iFetchPlan)
Returns the user object associated to a record.
|
Object |
getUserObjectByRecord(OIdentifiable iRecord,
String iFetchPlan,
boolean iCreate) |
int |
getVersion(Object iPojo)
Returns the version number of the object.
|
String |
incrementalBackup(String path)
Performs incremental backup of database content to the selected folder.
|
protected void |
init() |
boolean |
isAutomaticSchemaGeneration() |
boolean |
isLazyLoading() |
boolean |
isManaged(Object iEntity) |
boolean |
isMVCC()
Deprecated.
|
boolean |
isRetainObjects()
Deprecated.
|
boolean |
isSaveOnlyDirty() |
OLiveQueryMonitor |
live(String query,
OLiveQueryResultListener listener,
Map<String,?> args)
Subscribe a query as a live query for future create/update event with the referred conditions
|
OLiveQueryMonitor |
live(String query,
OLiveQueryResultListener listener,
Object... args)
Subscribe a query as a live query for future create/update event with the referred conditions
|
<RET> RET |
load(Object iPojo)
Loads the entity and return it.
|
<RET> RET |
load(Object iPojo,
String iFetchPlan)
Loads a record using a fetch plan.
|
<RET> RET |
load(Object iPojo,
String iFetchPlan,
boolean iIgnoreCache)
Loads a record using a fetch plan.
|
<RET> RET |
load(ORID recordId)
Loads the entity by the Record ID.
|
<RET> RET |
load(ORID iRecordId,
String iFetchPlan)
Loads the entity by the Record ID using a fetch plan.
|
<RET> RET |
load(ORID iRecordId,
String iFetchPlan,
boolean iIgnoreCache)
Loads the entity by the Record ID using a fetch plan and specifying if the cache must be
ignored.
|
<RET> RET |
lock(ORID recordId)
Pessimistic lock a record.
|
<RET> RET |
lock(ORID recordId,
long timeout,
TimeUnit timeoutUnit)
Pessimistic lock a record.
|
Object |
newInstance()
Creates a new entity instance.
|
<T> T |
newInstance(Class<T> iType)
Creates a new entity of the specified class.
|
<T> T |
newInstance(Class<T> iType,
Object... iArgs) |
<RET> RET |
newInstance(String iClassName)
Creates a new entity instance.
|
<RET> RET |
newInstance(String iClassName,
Object iEnclosingClass,
Object... iArgs)
Create a new POJO by its class name.
|
<RET> RET |
newInstance(String iClassName,
Object iEnclosingClass,
ODocument iDocument,
Object... iArgs)
Create a new POJO by its class name.
|
<RET extends List<?>> |
objectCommand(String iCommand,
Map<String,Object> iArgs) |
<RET extends List<?>> |
objectCommand(String iCommand,
Object... iArgs) |
<RET extends List<?>> |
objectQuery(String iCommand,
Map<String,Object> iArgs) |
<RET extends List<?>> |
objectQuery(String iCommand,
Object... iArgs) |
<THISDB extends ODatabase> |
open(OToken iToken)
Opens a database using an authentication token received as an argument.
|
<THISDB extends ODatabase> |
open(String iUserName,
String iUserPassword)
Opens a database using the user and password received as arguments.
|
ODocument |
pojo2Stream(Object iPojo,
ODocument iRecord) |
<RET extends List<?>> |
query(OQuery<?> iCommand,
Object... iArgs)
Execute a query against the database.
|
OResultSet |
query(String query,
Map args)
Executes an SQL query (idempotent).
|
OResultSet |
query(String query,
Object... args)
Executes an SQL query.
|
void |
registerClassMethodFilter(Class<?> iClass,
OObjectMethodFilter iMethodFilter) |
<DBTYPE extends ODatabase<?>> |
registerHook(ORecordHook iHookImpl)
Registers a hook to listen all events for Records.
|
<DBTYPE extends ODatabase<?>> |
registerHook(ORecordHook iHookImpl,
ORecordHook.HOOK_POSITION iPosition) |
void |
registerUserObject(Object iObject,
ORecord iRecord)
Registers the association between a user object and a record.
|
void |
registerUserObjectAfterLinkSave(ORecord iRecord)
Registers the saved linked record.
|
<RET> RET |
reload(Object iPojo) |
<RET> RET |
reload(Object iPojo,
boolean iIgnoreCache) |
<RET> RET |
reload(Object iPojo,
String iFetchPlan,
boolean iIgnoreCache)
Force the reloading of the entity.
|
<RET> RET |
reload(Object iObject,
String iFetchPlan,
boolean iIgnoreCache,
boolean force)
Force the reloading of the entity.
|
void |
resetInitialization() |
OObjectDatabaseTx |
rollback()
Aborts the current running transaction.
|
OObjectDatabaseTx |
rollback(boolean force) |
<RET> RET |
save(Object iContent)
Saves an object to the databasein synchronous mode .
|
<RET> RET |
save(Object iContent,
ODatabase.OPERATION_MODE iMode,
boolean iForceCreate,
ORecordCallback<? extends Number> iRecordCreatedCallback,
ORecordCallback<Integer> iRecordUpdatedCallback)
Saves an object to the database specifying the mode.
|
<RET> RET |
save(Object iPojo,
String iClusterName)
Saves an object in synchronous mode to the database forcing a record cluster where to store it.
|
<RET> RET |
save(Object iPojo,
String iClusterName,
ODatabase.OPERATION_MODE iMode,
boolean iForceCreate,
ORecordCallback<? extends Number> iRecordCreatedCallback,
ORecordCallback<Integer> iRecordUpdatedCallback)
Saves an object to the database forcing a record cluster where to store it.
|
void |
setAutomaticSchemaGeneration(boolean automaticSchemaGeneration) |
OObjectDatabaseTx |
setConflictStrategy(ORecordConflictStrategy iResolver)
Overrides record conflict strategy.
|
OObjectDatabaseTx |
setConflictStrategy(String iStrategyName)
Overrides record conflict strategy selecting the strategy by name.
|
void |
setDirty(Object iPojo)
Sets as dirty a POJO.
|
void |
setInternal(ODatabase.ATTRIBUTES attribute,
Object iValue)
Internal method.
|
void |
setLazyLoading(boolean lazyLoading) |
<DBTYPE extends ODatabase<?>> |
setMVCC(boolean iMvcc)
Deprecated.
|
OObjectDatabaseTx |
setRetainObjects(boolean iValue)
Deprecated.
|
void |
setSaveOnlyDirty(boolean saveOnlyDirty) |
void |
setUser(OSecurityUser user)
Set user for current database instance.
|
Object |
stream2pojo(ODocument iRecord,
Object iPojo,
String iFetchPlan) |
Object |
stream2pojo(ODocument iRecord,
Object iPojo,
String iFetchPlan,
boolean iReload) |
void |
unlock(ORID recordId)
Pessimistic unlock
|
<DBTYPE extends ODatabase<?>> |
unregisterHook(ORecordHook iHookImpl)
Unregisters a previously registered hook.
|
void |
unregisterPojo(Object iObject,
ODocument iRecord) |
void |
unsetDirty(Object iPojo)
Sets as not dirty a POJO.
|
activateOnCurrentThread, addCluster, addCluster, backup, checkOpenness, close, countClusterElements, countClusterElements, countClusterElements, countClusterElements, countClusterElements, create, create, create, declareIntent, drop, dropCluster, dropCluster, equals, exists, existsCluster, freeze, freeze, get, getActiveIntent, getClusterIdByName, getClusterNameById, getClusterNames, getClusterRecordSizeById, getClusterRecordSizeByName, getClusters, getConfiguration, getDatabaseOwner, getDefaultClusterId, getLocalCache, getMicroOrRegularTransaction, getName, getProperties, getProperty, getRecordMetadata, getSize, getStatus, getStorage, getURL, isActiveOnCurrentThread, isClosed, registerListener, release, reload, replaceStorage, restore, set, setDatabaseOwner, setProperty, setStatus, toString, truncateCluster, unregisterListener
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
detachAll
activateOnCurrentThread, addCluster, addCluster, close, countClusterElements, countClusterElements, countClusterElements, countClusterElements, countClusterElements, create, create, create, createClass, declareIntent, drop, dropCluster, dropCluster, exists, existsCluster, freeze, freeze, get, getActiveIntent, 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, unregisterListener
backup, restore
getActiveClusterMap, getActiveDataCenterMap, getEnterpriseEndpoint, getLocalNodeName, isSharded
public static final String TYPE
protected ODictionary<Object> dictionary
protected OEntityManager entityManager
protected boolean saveOnlyDirty
protected boolean lazyLoading
protected boolean automaticSchemaGeneration
protected OMetadataObject metadata
public OObjectDatabaseTx(String iURL)
public OObjectDatabaseTx(ODatabaseDocumentInternal iDatabase)
iDatabase
- an open database connectionpublic <T> T newInstance(Class<T> iType)
ODatabaseObject
newInstance
in interface ODatabaseObject
iType
- Class name where to originate the instancepublic <RET> RET newInstance(String iClassName)
ODatabaseObject
newInstance
in interface ODatabaseObject
public <THISDB extends ODatabase> THISDB open(String iUserName, String iUserPassword)
ODatabase
open
in interface ODatabase<Object>
open
in class ODatabaseWrapperAbstract<ODatabaseDocumentInternal,Object>
iUserName
- Username to loginiUserPassword
- Password associated to the userpublic <THISDB extends ODatabase> THISDB open(OToken iToken)
ODatabaseInternal
open
in interface ODatabaseInternal<Object>
open
in class ODatabaseWrapperAbstract<ODatabaseDocumentInternal,Object>
iToken
- Authentication tokenpublic OSecurityUser getUser()
ODatabase
public void setUser(OSecurityUser user)
ODatabaseInternal
setUser
in interface ODatabaseInternal<Object>
public OMetadataObject getMetadata()
ODatabase
getMetadata
in interface ODatabaseObject
getMetadata
in interface ODatabase<Object>
public void setInternal(ODatabase.ATTRIBUTES attribute, Object iValue)
ODatabaseInternal
setInternal
in interface ODatabaseInternal<Object>
public Iterable<ODatabaseListener> getListeners()
ODatabase
getListeners
in interface ODatabase<Object>
public <DBTYPE extends ODatabase<?>> DBTYPE registerHook(ORecordHook iHookImpl)
ODatabase
registerHook
in interface ODatabase<Object>
iHookImpl
- ORecordHook implementationpublic <DBTYPE extends ODatabase<?>> DBTYPE registerHook(ORecordHook iHookImpl, ORecordHook.HOOK_POSITION iPosition)
registerHook
in interface ODatabase<Object>
public ORecordHook.RESULT callbackHooks(ORecordHook.TYPE iType, OIdentifiable iObject)
public Map<ORecordHook,ORecordHook.HOOK_POSITION> getHooks()
ODatabase
public <DBTYPE extends ODatabase<?>> DBTYPE unregisterHook(ORecordHook iHookImpl)
ODatabase
unregisterHook
in interface ODatabase<Object>
iHookImpl
- ORecordHook implementationpublic <RET> RET newInstance(String iClassName, Object iEnclosingClass, Object... iArgs)
public <RET> RET newInstance(String iClassName, Object iEnclosingClass, ODocument iDocument, Object... iArgs)
public <RET> OObjectIteratorClass<RET> browseClass(Class<RET> iClusterClass)
ODatabaseObject
browseClass
in interface ODatabaseObject
iClusterClass
- Class name to iteratepublic <RET> OObjectIteratorClass<RET> browseClass(Class<RET> iClusterClass, boolean iPolymorphic)
public <RET> OObjectIteratorClass<RET> browseClass(String iClassName)
public <RET> OObjectIteratorClass<RET> browseClass(String iClassName, boolean iPolymorphic)
public <RET> OObjectIteratorCluster<RET> browseCluster(String iClusterName)
ODatabaseObject
browseCluster
in interface ODatabaseObject
iClusterName
- Cluster name to iteratepublic <RET> RET load(Object iPojo)
ODatabase
public <RET> RET reload(Object iPojo)
public <RET> RET reload(Object iPojo, boolean iIgnoreCache)
public <RET> RET reload(Object iPojo, String iFetchPlan, boolean iIgnoreCache)
ODatabase
public <RET> RET reload(Object iObject, String iFetchPlan, boolean iIgnoreCache, boolean force)
ODatabase
reload
in interface ODatabase<Object>
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.public <RET> RET load(Object iPojo, String iFetchPlan)
ODatabase
public void attach(Object iPojo)
public <RET> RET attachAndSave(Object iPojo)
public <RET> RET detach(Object iPojo)
detach
in interface ODatabaseObject
iPojo
- :- the object to detachpublic <RET> RET detach(Object iPojo, boolean returnNonProxiedInstance)
detach
in interface ODatabaseObject
RET
- 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 replicationpublic <RET> RET detachAll(Object iPojo, boolean returnNonProxiedInstance)
StackOverflowError
with big objects tree. To avoid it
set the stack size with -Xss java optiondetachAll
in interface ODatabaseObject
RET
- 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 replicationpublic <RET> RET load(Object iPojo, String iFetchPlan, boolean iIgnoreCache)
ODatabase
public <RET> RET lock(ORID recordId) throws OLockException
ODatabase
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.
lock
in interface ODatabase<Object>
recordId
- the id of the record that need to be lockedOLockException
- In case of deadlock detectedpublic <RET> RET lock(ORID recordId, long timeout, TimeUnit timeoutUnit) throws OLockException
ODatabase
lock
in interface ODatabase<Object>
recordId
- the id of the record that need to be lockedtimeout
- for the record lockingtimeoutUnit
- relative for the timeoutOLockException
- In case of deadlock detectedpublic void unlock(ORID recordId) throws OLockException
ODatabase
unlock
in interface ODatabase<Object>
recordId
- the id of the record to unlockOLockException
- if the record is not locked.public <RET> RET load(ORID recordId)
ODatabase
public <RET> RET load(ORID iRecordId, String iFetchPlan)
ODatabase
public <RET> RET load(ORID iRecordId, String iFetchPlan, boolean iIgnoreCache)
ODatabase
public <RET> RET save(Object iContent)
public <RET> RET save(Object iContent, ODatabase.OPERATION_MODE iMode, boolean iForceCreate, ORecordCallback<? extends Number> iRecordCreatedCallback, ORecordCallback<Integer> iRecordUpdatedCallback)
public <RET> RET save(Object iPojo, String iClusterName)
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
in interface ODatabase<Object>
iPojo
- The entity to saveiClusterName
- Name of the cluster where to saveODocument.validate()
public <RET> RET save(Object iPojo, String iClusterName, ODatabase.OPERATION_MODE iMode, boolean iForceCreate, ORecordCallback<? extends Number> iRecordCreatedCallback, ORecordCallback<Integer> iRecordUpdatedCallback)
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
in interface ODatabase<Object>
iPojo
- The entity to saveiClusterName
- Name of the cluster where to saveiMode
- Mode of save: synchronous (default) or asynchronousiForceCreate
- Flag that indicates that record should be created. If record with current
rid already exists, exception is thrownODocument.validate()
public ODatabaseObject delete(Object iPojo)
ODatabase
public ODatabaseObject delete(ORID iRID)
ODatabase
public ODatabaseObject delete(ORID iRID, int iVersion)
ODatabase
public ODatabaseObject delete(ORecord iRecord)
public long countClass(String iClassName)
ODatabaseObject
countClass
in interface ODatabaseObject
iClassName
- Class namepublic long countClass(String iClassName, boolean iPolymorphic)
ODatabaseObject
countClass
in interface ODatabaseObject
iClassName
- Class nameiPolymorphic
- True if consider also the sub classes, otherwise falsepublic long countClass(Class<?> iClass)
@Deprecated public ODictionary<Object> getDictionary()
getDictionary
in interface ODatabase<Object>
public OTransaction getTransaction()
ODatabase
getTransaction
in interface ODatabase<Object>
public OObjectDatabaseTx begin()
ODatabase
ODatabase.commit()
or ODatabase.rollback()
.public OObjectDatabaseTx begin(OTransaction.TXTYPE iType)
ODatabase
ODatabase.commit()
or ODatabase.rollback()
.public OObjectDatabaseTx begin(OTransaction iTx)
ODatabase
public OObjectDatabaseTx commit()
ODatabase
public OObjectDatabaseTx commit(boolean force) throws OTransactionException
commit
in interface ODatabase<Object>
OTransactionException
public OObjectDatabaseTx rollback()
ODatabase
public OObjectDatabaseTx rollback(boolean force) throws OTransactionException
rollback
in interface ODatabase<Object>
OTransactionException
public OEntityManager getEntityManager()
ODatabaseObject
getEntityManager
in interface ODatabaseObject
public ODatabaseDocumentInternal getUnderlying()
ODatabaseInternal
getUnderlying
in interface ODatabaseInternal<Object>
getUnderlying
in class ODatabaseWrapperAbstract<ODatabaseDocumentInternal,Object>
public int getVersion(Object iPojo)
iPojo
- User objectpublic ORID getIdentity(Object iPojo)
iPojo
- User objectpublic boolean isSaveOnlyDirty()
public void setSaveOnlyDirty(boolean saveOnlyDirty)
public boolean isAutomaticSchemaGeneration()
public void setAutomaticSchemaGeneration(boolean automaticSchemaGeneration)
public Object newInstance()
ODatabase
newInstance
in interface ODatabase<Object>
public <DBTYPE extends ODatabase> DBTYPE checkSecurity(ORule.ResourceGeneric resourceGeneric, String resourceSpecific, byte iOperation)
public <DBTYPE extends ODatabase> DBTYPE checkSecurity(ORule.ResourceGeneric iResource, int iOperation, Object iResourceSpecific)
public <DBTYPE extends ODatabase> DBTYPE checkSecurity(ORule.ResourceGeneric iResource, int iOperation, Object... iResourcesSpecific)
public ODocument pojo2Stream(Object iPojo, ODocument iRecord)
pojo2Stream
in interface ODatabaseObject
public Object stream2pojo(ODocument iRecord, Object iPojo, String iFetchPlan)
stream2pojo
in interface ODatabaseObject
public Object stream2pojo(ODocument iRecord, Object iPojo, String iFetchPlan, boolean iReload)
public boolean isLazyLoading()
isLazyLoading
in interface ODatabaseObject
public void setLazyLoading(boolean lazyLoading)
setLazyLoading
in interface ODatabaseObject
public ORecordConflictStrategy getConflictStrategy()
ODatabase
getConflictStrategy
in interface ODatabase<Object>
public OObjectDatabaseTx setConflictStrategy(ORecordConflictStrategy iResolver)
ODatabase
setConflictStrategy
in interface ODatabase<Object>
iResolver
- ORecordConflictStrategy implementationpublic OObjectDatabaseTx setConflictStrategy(String iStrategyName)
ODatabase
setConflictStrategy
in interface ODatabase<Object>
iStrategyName
- ORecordConflictStrategy strategy namepublic ODocument getRecordByUserObject(Object iPojo, boolean iCreateIfNotAvailable)
OUserObject2RecordHandler
getRecordByUserObject
in interface OUserObject2RecordHandler
iPojo
- User objectiCreateIfNotAvailable
- Create the record if not availablepublic Object getUserObjectByRecord(OIdentifiable iRecord, String iFetchPlan)
OUserObject2RecordHandler
getUserObjectByRecord
in interface OUserObject2RecordHandler
iRecord
- RecordiFetchPlan
- If the record is not loaded yet, use this as fetch planpublic Object getUserObjectByRecord(OIdentifiable iRecord, String iFetchPlan, boolean iCreate)
public void registerUserObject(Object iObject, ORecord iRecord)
OUserObject2RecordHandler
registerUserObject
in interface OUserObject2RecordHandler
iObject
- User objectiRecord
- recordpublic void registerUserObjectAfterLinkSave(ORecord iRecord)
OUserObject2RecordHandler
registerUserObjectAfterLinkSave
in interface OUserObject2RecordHandler
iRecord
- recordpublic boolean existsUserObjectByRID(ORID iRID)
OUserObject2RecordHandler
existsUserObjectByRID
in interface OUserObject2RecordHandler
public boolean isManaged(Object iEntity)
public void registerClassMethodFilter(Class<?> iClass, OObjectMethodFilter iMethodFilter)
public void deregisterClassMethodFilter(Class<?> iClass)
public String incrementalBackup(String path)
ODatabase
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.
incrementalBackup
in interface ODatabase<Object>
path
- Path to backup folder.public void resetInitialization()
resetInitialization
in interface ODatabaseInternal<Object>
protected <RET> RET detachAll(Object iPojo, boolean returnNonProxiedInstance, Map<Object,Object> alreadyDetached, Map<Object,Object> lazyObjects)
protected void deleteCascade(ODocument record)
protected void init()
protected void deleteOrphans(OObjectProxyMethodHandler handler)
public int addBlobCluster(String iClusterName, Object... iParameters)
ODatabase
addBlobCluster
in interface ODatabase<Object>
iClusterName
- Cluster nameiParameters
- Additional parameters to pass to the factoriespublic Set<Integer> getBlobClusterIds()
ODatabase
getBlobClusterIds
in interface ODatabase<Object>
public OSharedContext getSharedContext()
getSharedContext
in interface ODatabaseInternal<Object>
public <RET extends OCommandRequest> RET command(OCommandRequest iCommand)
public <RET extends List<?>> RET query(OQuery<?> iCommand, Object... iArgs)
ODatabase
protected void convertParameters(Object... iArgs)
iArgs
- Array of parameters as ObjectconvertParameter(Object)
public void setDirty(Object iPojo)
setDirty
in interface ODatabaseObject
iPojo
- User objectpublic void unsetDirty(Object iPojo)
unsetDirty
in interface ODatabaseObject
iPojo
- User objectprotected Object convertParameter(Object iParameter)
iParameter
- Parameter to convert, if applicableconvertParameters(Object...)
@Deprecated public boolean isMVCC()
ODatabase
isMVCC
in interface ODatabase<Object>
deprecated since 2.2
@Deprecated public <DBTYPE extends ODatabase<?>> DBTYPE setMVCC(boolean iMvcc)
ODatabase
setMVCC
in interface ODatabase<Object>
ODatabase.isMVCC()
@Deprecated public boolean isRetainObjects()
isRetainObjects
in interface ODatabaseObject
setRetainObjects(boolean)
@Deprecated public OObjectDatabaseTx setRetainObjects(boolean iValue)
setRetainObjects
in interface ODatabaseObject
iValue
- True to enable, false to disable it.isRetainObjects()
public OLiveQueryMonitor live(String query, OLiveQueryResultListener listener, Object... args)
ODatabase
public OLiveQueryMonitor live(String query, OLiveQueryResultListener listener, Map<String,?> args)
ODatabase
public OResultSet query(String query, Object... args) throws OCommandSQLParsingException, OCommandExecutionException
ODatabase
OResultSet rs = db.query("SELECT FROM V where name = ?", "John"); while(rs.hasNext()){ OResult item = rs.next(); ... }
rs.close();
query
in interface ODatabase<Object>
query
- the query stringargs
- query parameters (positional)OCommandSQLParsingException
OCommandExecutionException
public OResultSet query(String query, Map args) throws OCommandSQLParsingException, OCommandExecutionException
ODatabase
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();
query
in interface ODatabase<Object>
query
- the query stringargs
- query parameters (named)OCommandSQLParsingException
OCommandExecutionException
public OResultSet command(String query, Object... args) throws OCommandSQLParsingException, OCommandExecutionException
ODatabase
OResultSet rs = db.command("INSERT INTO Person SET name = ?", "John"); ... rs.close();
command
in interface ODatabase<Object>
args
- query argumentsOCommandSQLParsingException
OCommandExecutionException
public <RET extends List<?>> RET objectQuery(String iCommand, Object... iArgs)
objectQuery
in interface ODatabaseObject
public <RET extends List<?>> RET objectQuery(String iCommand, Map<String,Object> iArgs)
objectQuery
in interface ODatabaseObject
public <RET extends List<?>> RET objectCommand(String iCommand, Object... iArgs)
objectCommand
in interface ODatabaseObject
public <RET extends List<?>> RET objectCommand(String iCommand, Map<String,Object> iArgs)
objectCommand
in interface ODatabaseObject
public OResultSet command(String query, Map args) throws OCommandSQLParsingException, OCommandExecutionException
ODatabase
Map<String, Object> params = new HashMapMap<>(); params.put("name", "John"); OResultSet rs = db.query("INSERT
INTO Person SET name = :name", params); ... rs.close();
command
in interface ODatabase<Object>
OCommandSQLParsingException
OCommandExecutionException
public OResultSet execute(String language, String script, Object... args) throws OCommandExecutionException, OCommandScriptException
ODatabase
OResultSet rs = db.execute("sql", script, "Surname1", "Surname2", "Surname3"); ... rs.close();
String script = "INSERT INTO Person SET name = 'foo', surname = ?;"+ "INSERT INTO Person SET name = 'bar', surname =
?;"+ "INSERT INTO Person SET name = 'baz', surname = ?;";
execute
in interface ODatabase<Object>
OCommandExecutionException
OCommandScriptException
public OResultSet execute(String language, String script, Map<String,?> args) throws OCommandExecutionException, OCommandScriptException
ODatabase
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();
Map<String, Object> params = new HashMapMap<>(); params.put("surname1", "Jones"); params.put("surname2",
"May"); params.put("surname3", "Ali");
execute
in interface ODatabase<Object>
OCommandExecutionException
OCommandScriptException
public <T> T executeWithRetry(int nRetries, Function<ODatabaseSession,T> function) throws IllegalStateException, IllegalArgumentException, ONeedRetryException, UnsupportedOperationException
ODatabase
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.
executeWithRetry
in interface ODatabaseObject
executeWithRetry
in interface ODatabase<Object>
T
- the return type of the lambdanRetries
- the maximum number of retries (> 0)function
- a lambda containing application code to execute in a commit/retry loopIllegalStateException
- 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/retrypublic OStorageInfo getStorageInfo()
getStorageInfo
in interface ODatabaseInternal<Object>
Copyright © 2009–2020 OrientDB. All rights reserved.