public class ODatabaseDocumentEmbedded extends ODatabaseDocumentAbstract implements OQueryLifecycleListener
ODatabase.ATTRIBUTES, ODatabase.OPERATION_MODE, ODatabase.STATUS
activeQueries, componentsFactory, currentIntent, currentTx, databaseOwner, hooks, hooksByScope, inHook, initialized, localCache, metadata, microTransaction, properties, recordType, retainRecords, serializer, sharedContext, status, unmodifiableHooks, url, user
TYPE
Constructor and Description |
---|
ODatabaseDocumentEmbedded(OStorage storage) |
Modifier and Type | Method and Description |
---|---|
int |
addBlobCluster(String iClusterName,
Object... iParameters)
Adds a new cluster for store blobs.
|
protected void |
afterCommitOperations() |
void |
afterCreateOperations(OIdentifiable id) |
void |
afterDeleteOperations(OIdentifiable id) |
void |
afterReadOperations(OIdentifiable identifiable) |
protected void |
afterRollbackOperations() |
void |
afterUpdateOperations(OIdentifiable id) |
OIdentifiable |
beforeCreateOperations(OIdentifiable id,
String iClusterName) |
void |
beforeDeleteOperations(OIdentifiable id,
String iClusterName) |
boolean |
beforeReadOperations(OIdentifiable identifiable) |
OIdentifiable |
beforeUpdateOperations(OIdentifiable id,
String iClusterName) |
protected OMicroTransaction |
beginMicroTransaction() |
void |
callOnCreateListeners() |
<DB extends ODatabaseDocument> |
checkSecurity(ORule.ResourceGeneric iResourceGeneric,
int iOperation,
Object... iResourcesSpecific)
Checks if the operation against multiple resources is allowed for the current user.
|
<DB extends ODatabaseDocument> |
checkSecurity(ORule.ResourceGeneric iResourceGeneric,
int iOperation,
Object iResourceSpecific)
Checks if the operation on a resource is allowed for the current user.
|
<DB extends ODatabaseDocument> |
checkSecurity(ORule.ResourceGeneric resourceGeneric,
String resourceSpecific,
int iOperation)
Checks if the operation on a resource is allowed for the current user.
|
<DB extends ODatabaseDocument> |
checkSecurity(String iResource,
int iOperation)
Deprecated.
|
<DB extends ODatabaseDocument> |
checkSecurity(String iResourceGeneric,
int iOperation,
Object... iResourcesSpecific)
Deprecated.
|
<DB extends ODatabaseDocument> |
checkSecurity(String iResourceGeneric,
int iOperation,
Object iResourceSpecific)
Deprecated.
|
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.
|
ODatabaseDocumentInternal |
copy()
Returns a copy of current database if it's open.
|
<DB extends ODatabase> |
create()
Creates a new database.
|
<DB extends ODatabase> |
create(Map<OGlobalConfiguration,Object> iInitialSettings)
Creates a new database passing initial settings.
|
<DB extends ODatabase> |
create(String incrementalBackupPath)
Creates new database from database backup.
|
protected void |
createMetadata(OSharedContext shared) |
ODatabaseDocumentAbstract |
delete(ORecord record)
Deletes a document.
|
void |
drop()
Drops a database.
|
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.
|
void |
executeDeleteRecord(OIdentifiable identifiable,
int iVersion,
boolean iRequired,
ODatabase.OPERATION_MODE iMode,
boolean prohibitTombstones)
This method is internal, it can be subject to signature change or be removed, do not
use.
|
<RET extends ORecord> |
executeReadRecord(ORecordId rid,
ORecord iRecord,
int recordVersion,
String fetchPlan,
boolean ignoreCache,
boolean iUpdateCache,
boolean loadTombstones,
OStorage.LOCKING_STRATEGY lockingStrategy,
RecordReader recordReader)
This method is internal, it can be subject to signature change or be removed, do not
use.
|
boolean |
exists()
Checks if the database exists.
|
String |
getClusterName(ORecord record) |
OrientDBConfig |
getConfig() |
OStorage |
getStorage()
Returns the underlying storage implementation.
|
OStorageInfo |
getStorageInfo() |
OView |
getViewFromCluster(int cluster) |
void |
init(OrientDBConfig config,
OSharedContext sharedContext) |
protected void |
installHooksEmbedded() |
void |
internalCreate(OrientDBConfig config,
OSharedContext ctx) |
void |
internalLockRecord(OIdentifiable iRecord,
OStorage.LOCKING_STRATEGY lockingStrategy) |
void |
internalLockRecord(OIdentifiable iRecord,
OStorage.LOCKING_STRATEGY lockingStrategy,
long timeout) |
void |
internalOpen(String iUserName,
String iUserPassword) |
void |
internalOpen(String iUserName,
String iUserPassword,
boolean checkPassword) |
void |
internalUnlockRecord(OIdentifiable iRecord) |
boolean |
isClosed()
Checks if the database is closed.
|
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
|
protected void |
loadMetadata() |
protected void |
loadMetadata(OSharedContext shared) |
<RET extends ORecord> |
lock(ORID recordId)
Pessimistic lock a record.
|
<RET extends ORecord> |
lock(ORID recordId,
long timeout,
TimeUnit timeoutUnit)
Pessimistic lock a record.
|
<DB extends ODatabase> |
open(OToken iToken)
Deprecated.
|
<DB extends ODatabase> |
open(String iUserName,
String iUserPassword)
Opens a database using the user and password received as arguments.
|
OLocalResultSetLifecycleDecorator |
query(OExecutionPlan plan,
Map<Object,Object> params) |
OResultSet |
query(String query,
Map args)
Executes an SQL query (idempotent).
|
OResultSet |
query(String query,
Object[] args)
Executes an SQL query.
|
void |
rebuildIndexes() |
void |
recycle(ORecord record) |
void |
replaceStorage(OStorage iNewStorage)
Internal only: replace the storage with a new one.
|
ORecord |
saveAll(ORecord iRecord,
String iClusterName,
ODatabase.OPERATION_MODE iMode,
boolean iForceCreate,
ORecordCallback<? extends Number> iRecordCreatedCallback,
ORecordCallback<Integer> iRecordUpdatedCallback) |
<T> T |
sendSequenceAction(OSequenceAction action) |
<DB extends ODatabase> |
set(ODatabase.ATTRIBUTES iAttribute,
Object iValue)
Sets a database attribute value
|
<DB extends ODatabase> |
setCustom(String name,
Object iValue) |
void |
syncCommit(OTransactionData data) |
void |
unlock(ORID recordId)
Pessimistic unlock
|
activateOnCurrentThread, addCluster, addCluster, assignAndCheckCluster, backup, beforeCommitOperations, beforeRollbackOperations, begin, begin, begin, browseClass, browseClass, browseCluster, browseCluster, browseCluster, browseCluster, browseCluster, callbackHookFailure, callbackHookFinalize, callbackHooks, callbackHookSuccess, callOnCloseListeners, callOnDropListeners, callOnOpenListeners, checkClusterSecurity, checkForClusterPermissions, checkIfActive, checkOpenness, checkRecordClass, cleanOutRecord, clearDocumentTracking, close, closeActiveQueries, command, commit, commit, countClass, countClass, countClass, countClusterElements, countClusterElements, countClusterElements, countClusterElements, countClusterElements, countView, declareIntent, delete, delete, dropCluster, dropCluster, dropClusterInternal, dropClusterInternal, executeWithRetries, executeWithRetries, executeWithRetries, existsCluster, freeze, freeze, get, getActiveIntent, getActiveQueries, getActiveQuery, getBlobClusterIds, getClusterIdByName, getClusterNameById, getClusterNames, getClusterRecordSizeById, getClusterRecordSizeByName, getClusters, getCollectionsChanges, getConfiguration, getConflictStrategy, getDatabaseOwner, getDefaultClusterId, getDefaultSerializer, getDictionary, getHooks, getListeners, getLocalCache, getMetadata, getMicroOrRegularTransaction, getName, getProperties, getProperty, getRecord, getRecordMetadata, getRecordType, getSbTreeCollectionManager, getSerializer, getSerializerFactory, getSharedContext, getSize, getStatus, getStorageVersions, getTransaction, getType, getUnderlying, getURL, getUser, incrementalBackup, init, internalClose, internalCommit, isActiveOnCurrentThread, isClusterEdge, isClusterVertex, isClusterView, isMVCC, isPooled, isPrefetchRecords, isRetainRecords, isUseLightweightEdges, isValidationEnabled, load, load, load, load, load, load, loadIfVersionIsNotLatest, newBlob, newBlob, newEdge, newEdge, newElement, newElement, newElement, newEmbeddedElement, newEmbeddedElement, newInstance, newInstance, newLightweightEdge, newRegularEdge, newVertex, newVertex, pessimisticLockChecks, query, queryClosed, queryStarted, rawBegin, registerHook, registerHook, release, reload, reload, reload, reload, reload, reloadUser, resetInitialization, restore, rollback, rollback, save, save, save, save, setConflictStrategy, setConflictStrategy, setCurrentDatabaseInThreadLocal, setDatabaseOwner, setDefaultClusterIdInternal, setDefaultSerializer, setDefaultTransactionMode, setInternal, setMVCC, setPrefetchRecords, setProperty, setRetainRecords, setSerializer, setStatus, setStatusInternal, setUseLightweightEdges, setUser, setValidationEnabled, swapTx, truncateCluster, unregisterHook
browseListeners, getListenersCopy, registerListener, resetListeners, unregisterListener
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
queryClosed, queryStarted
getHaStatus, indexQuery, isDistributed, isRemote, queryOnNode, realClose, removeHaServer, reuse, sync
createClassIfNotExist, createEdgeClass, createVertexClass, newEdge, newVertex
createClass, executeWithRetry, getClass, registerListener, unregisterListener
getActiveClusterMap, getActiveDataCenterMap, getEnterpriseEndpoint, getLocalNodeName, isSharded
public ODatabaseDocumentEmbedded(OStorage storage)
public <DB extends ODatabase> DB open(String iUserName, String iUserPassword)
ODatabase
public void init(OrientDBConfig config, OSharedContext sharedContext)
public void internalOpen(String iUserName, String iUserPassword, boolean checkPassword)
@Deprecated public <DB extends ODatabase> DB open(OToken iToken)
open
in interface ODatabaseInternal<ORecord>
iToken
- Authentication tokenpublic <DB extends ODatabase> DB create()
ODatabase
public void internalCreate(OrientDBConfig config, OSharedContext ctx)
public void callOnCreateListeners()
protected void createMetadata(OSharedContext shared)
protected void loadMetadata()
loadMetadata
in class ODatabaseDocumentAbstract
protected void loadMetadata(OSharedContext shared)
loadMetadata
in class ODatabaseDocumentAbstract
public <DB extends ODatabase> DB set(ODatabase.ATTRIBUTES iAttribute, Object iValue)
ODatabase
public <DB extends ODatabase> DB setCustom(String name, Object iValue)
setCustom
in interface ODatabaseDocumentInternal
public <DB extends ODatabase> DB create(String incrementalBackupPath)
public <DB extends ODatabase> DB create(Map<OGlobalConfiguration,Object> iInitialSettings)
ODatabase
public ODatabaseDocumentInternal copy()
copy
in interface ODatabaseDocumentInternal
public boolean exists()
ODatabase
public boolean isClosed()
ODatabase
isClosed
in interface ODatabase<ORecord>
isClosed
in class ODatabaseDocumentAbstract
public void rebuildIndexes()
protected void installHooksEmbedded()
public OStorage getStorage()
ODatabaseInternal
getStorage
in interface ODatabaseInternal<ORecord>
OStorage
public OStorageInfo getStorageInfo()
getStorageInfo
in interface ODatabaseInternal<ORecord>
public void replaceStorage(OStorage iNewStorage)
ODatabaseInternal
replaceStorage
in interface ODatabaseInternal<ORecord>
iNewStorage
- The new storage to use. Usually it's a wrapped instance of the current
cluster.public OResultSet query(String query, Object[] args)
ODatabase
OResultSet rs = db.query("SELECT FROM V where name = ?", "John"); while(rs.hasNext()){ OResult item = rs.next(); ... }
rs.close();
public OResultSet query(String query, Map args)
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();
public OResultSet command(String query, Object[] args)
ODatabase
OResultSet rs = db.command("INSERT INTO Person SET name = ?", "John"); ... rs.close();
public OResultSet command(String query, Map args)
ODatabase
Map<String, Object> params = new HashMapMap<>(); params.put("name", "John"); OResultSet rs = db.query("INSERT
INTO Person SET name = :name", params); ... rs.close();
public OResultSet execute(String language, String script, Object... args)
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 = ?;";
public OResultSet execute(String language, String script, Map<String,?> args)
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");
public OLocalResultSetLifecycleDecorator query(OExecutionPlan plan, Map<Object,Object> params)
public OrientDBConfig getConfig()
public OLiveQueryMonitor live(String query, OLiveQueryResultListener listener, Object... args)
ODatabase
public OLiveQueryMonitor live(String query, OLiveQueryResultListener listener, Map<String,?> args)
ODatabase
public void recycle(ORecord record)
recycle
in interface ODatabaseDocumentInternal
protected OMicroTransaction beginMicroTransaction()
public int addBlobCluster(String iClusterName, Object... iParameters)
ODatabase
addBlobCluster
in interface ODatabaseDocument
addBlobCluster
in interface ODatabase<ORecord>
iClusterName
- Cluster nameiParameters
- Additional parameters to pass to the factoriespublic void executeDeleteRecord(OIdentifiable identifiable, int iVersion, boolean iRequired, ODatabase.OPERATION_MODE iMode, boolean prohibitTombstones)
executeDeleteRecord
in interface ODatabaseDocumentInternal
public OIdentifiable beforeCreateOperations(OIdentifiable id, String iClusterName)
beforeCreateOperations
in interface ODatabaseDocumentInternal
public OIdentifiable beforeUpdateOperations(OIdentifiable id, String iClusterName)
beforeUpdateOperations
in interface ODatabaseDocumentInternal
public ODatabaseDocumentAbstract delete(ORecord record)
If MVCC is enabled and the version of the document is different by the version stored in the
database, then a OConcurrentModificationException
exception is thrown.
public void beforeDeleteOperations(OIdentifiable id, String iClusterName)
beforeDeleteOperations
in interface ODatabaseDocumentInternal
public void afterCreateOperations(OIdentifiable id)
afterCreateOperations
in interface ODatabaseDocumentInternal
public void afterUpdateOperations(OIdentifiable id)
afterUpdateOperations
in interface ODatabaseDocumentInternal
public void afterDeleteOperations(OIdentifiable id)
afterDeleteOperations
in interface ODatabaseDocumentInternal
public void afterReadOperations(OIdentifiable identifiable)
afterReadOperations
in interface ODatabaseDocumentInternal
public boolean beforeReadOperations(OIdentifiable identifiable)
beforeReadOperations
in interface ODatabaseDocumentInternal
protected void afterCommitOperations()
afterCommitOperations
in class ODatabaseDocumentAbstract
protected void afterRollbackOperations()
afterRollbackOperations
in class ODatabaseDocumentAbstract
public ORecord saveAll(ORecord iRecord, String iClusterName, ODatabase.OPERATION_MODE iMode, boolean iForceCreate, ORecordCallback<? extends Number> iRecordCreatedCallback, ORecordCallback<Integer> iRecordUpdatedCallback)
saveAll
in interface ODatabaseDocumentInternal
public String getClusterName(ORecord record)
getClusterName
in interface ODatabaseDocumentInternal
public OView getViewFromCluster(int cluster)
getViewFromCluster
in interface ODatabaseDocumentInternal
getViewFromCluster
in class ODatabaseDocumentAbstract
public <RET extends ORecord> RET executeReadRecord(ORecordId rid, ORecord iRecord, int recordVersion, String fetchPlan, boolean ignoreCache, boolean iUpdateCache, boolean loadTombstones, OStorage.LOCKING_STRATEGY lockingStrategy, RecordReader recordReader)
executeReadRecord
in interface ODatabaseDocumentInternal
executeReadRecord
in class ODatabaseDocumentAbstract
public void internalLockRecord(OIdentifiable iRecord, OStorage.LOCKING_STRATEGY lockingStrategy)
internalLockRecord
in interface ODatabaseDocumentInternal
public void internalLockRecord(OIdentifiable iRecord, OStorage.LOCKING_STRATEGY lockingStrategy, long timeout)
public void internalUnlockRecord(OIdentifiable iRecord)
internalUnlockRecord
in interface ODatabaseDocumentInternal
public <RET extends ORecord> 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<ORecord>
recordId
- the id of the record that need to be lockedOLockException
- In case of deadlock detectedpublic <RET extends ORecord> RET lock(ORID recordId, long timeout, TimeUnit timeoutUnit) throws OLockException
ODatabase
lock
in interface ODatabase<ORecord>
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<ORecord>
recordId
- the id of the record to unlockOLockException
- if the record is not locked.public <T> T sendSequenceAction(OSequenceAction action) throws ExecutionException, InterruptedException
sendSequenceAction
in interface ODatabaseDocumentInternal
ExecutionException
InterruptedException
public <DB extends ODatabaseDocument> DB checkSecurity(ORule.ResourceGeneric resourceGeneric, String resourceSpecific, int iOperation)
checkSecurity
in interface ODatabaseDocument
resourceGeneric
- Generic Resource where to execute the operationiOperation
- Operation to execute against the resourcepublic <DB extends ODatabaseDocument> DB checkSecurity(ORule.ResourceGeneric iResourceGeneric, int iOperation, Object... iResourcesSpecific)
checkSecurity
in interface ODatabaseDocument
iResourceGeneric
- Resource where to execute the operation, i.e.: database.clustersiOperation
- Operation to execute against the resourceiResourcesSpecific
- Target resources as an array of Objects, i.e.: ["employee", 2] to
specify cluster name and id.public <DB extends ODatabaseDocument> DB checkSecurity(ORule.ResourceGeneric iResourceGeneric, int iOperation, Object iResourceSpecific)
checkSecurity
in interface ODatabaseDocument
iResourceGeneric
- Resource where to execute the operation, i.e.: database.clustersiOperation
- Operation to execute against the resourceiResourceSpecific
- Target resource, i.e.: "employee" to specify the cluster name.@Deprecated public <DB extends ODatabaseDocument> DB checkSecurity(String iResource, int iOperation)
ODatabaseDocument
checkSecurity
in interface ODatabaseDocument
iResource
- Resource where to execute the operationiOperation
- Operation to execute against the resource@Deprecated public <DB extends ODatabaseDocument> DB checkSecurity(String iResourceGeneric, int iOperation, Object iResourceSpecific)
ODatabaseDocument
checkSecurity
in interface ODatabaseDocument
iResourceGeneric
- Resource where to execute the operation, i.e.: database.clustersiOperation
- Operation to execute against the resourceiResourceSpecific
- Target resource, i.e.: "employee" to specify the cluster name.@Deprecated public <DB extends ODatabaseDocument> DB checkSecurity(String iResourceGeneric, int iOperation, Object... iResourcesSpecific)
ODatabaseDocument
checkSecurity
in interface ODatabaseDocument
iResourceGeneric
- Resource where to execute the operation, i.e.: database.clustersiOperation
- Operation to execute against the resourceiResourcesSpecific
- Target resources as an array of Objects, i.e.: ["employee", 2] to
specify cluster name and id.public void syncCommit(OTransactionData data)
syncCommit
in interface ODatabaseDocumentInternal
Copyright © 2009–2020 OrientDB. All rights reserved.