com.orientechnologies.orient.core.db.document
Class ODatabaseDocumentTx

Package class diagram package ODatabaseDocumentTx
java.lang.Object
  extended by com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract<DB>
      extended by com.orientechnologies.orient.core.db.ODatabaseRecordWrapperAbstract<ODatabaseRecordTx>
          extended by com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx
All Implemented Interfaces:
ODatabaseDocument, ODatabase, ODatabaseComplex<ORecordInternal<?>>, ODatabaseSchemaAware<ORecordInternal<?>>, OUserObject2RecordHandler, ODatabaseRecord
Direct Known Subclasses:
ODatabaseDocumentTxPooled, OGraphDatabase

public class ODatabaseDocumentTx
extends ODatabaseRecordWrapperAbstract<ODatabaseRecordTx>
implements ODatabaseDocument


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.orientechnologies.orient.core.db.ODatabase
ODatabase.ATTRIBUTES, ODatabase.OPTIONS, ODatabase.STATUS
 
Constructor Summary
ODatabaseDocumentTx(java.lang.String iURL)
           
 
Method Summary
 ORecordIteratorClass<ODocument> browseClass(java.lang.String iClassName)
          Browses all the records of the specified class and also all the subclasses.
 ORecordIteratorClass<ODocument> browseClass(java.lang.String iClassName, boolean iPolymorphic)
          Browses all the records of the specified class and if iPolymorphic is true also all the subclasses.
 ORecordIteratorCluster<ODocument> browseCluster(java.lang.String iClusterName)
          Browses all the records of the specified cluster.
 ODatabaseComplex<ORecordInternal<?>> commit()
          Commits the current transaction.
 long countClass(java.lang.String iClassName)
          Returns the number of the records of the class iClassName.
 ODatabaseDocumentTx delete(ODocument iContent)
          Deletes a document.
 ODocument newInstance()
          Creates a new entity instance.
 ODocument newInstance(java.lang.String iClassName)
          Creates a new entity instance.
 ODatabaseComplex<ORecordInternal<?>> rollback()
          Aborts the current running transaction.
 ODatabaseDocumentTx save(ORecordInternal<?> iRecord)
          Saves a document to the database.
 ODatabaseDocumentTx save(ORecordInternal<?> iContent, java.lang.String iClusterName)
          Saves a document specifying a cluster where to store the record.
 
Methods inherited from class com.orientechnologies.orient.core.db.ODatabaseRecordWrapperAbstract
addCluster, addDataSegment, addLogicalCluster, addPhysicalCluster, addPhysicalCluster, begin, begin, begin, browseCluster, callbackHooks, checkSecurity, checkSecurity, checkSecurity, command, create, delete, delete, dropCluster, dropCluster, existsUserObjectByRID, getDictionary, getHooks, getMetadata, getRecord, getRecordByUserObject, getRecordType, getTransaction, getUser, getUserObjectByRecord, isMVCC, isRetainRecords, isValidationEnabled, load, load, load, load, load, load, query, registerHook, registerUserObject, reload, reload, setInternal, setMVCC, setRetainRecords, setValidationEnabled, unregisterHook
 
Methods inherited from class com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract
callInLock, close, countClusterElements, countClusterElements, countClusterElements, declareIntent, equals, exists, finalize, get, getClusterIdByName, getClusterNameById, getClusterNames, getClusterRecordSizeById, getClusterRecordSizeByName, getClusters, getClusterType, getDatabaseOwner, getDefaultClusterId, getLevel1Cache, getLevel2Cache, getName, getProperties, getProperty, getStatus, getStorage, getUnderlying, getURL, isClosed, open, registerListener, reload, set, setDatabaseOwner, setProperty, setStatus, toString, unregisterListener
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.orientechnologies.orient.core.db.record.ODatabaseRecord
browseCluster, checkSecurity, checkSecurity, checkSecurity, getRecord, getRecordType, isRetainRecords, isValidationEnabled, setRetainRecords, setValidationEnabled
 
Methods inherited from interface com.orientechnologies.orient.core.db.ODatabaseComplex
begin, begin, begin, callbackHooks, command, delete, getDatabaseOwner, getDictionary, getHooks, getMetadata, getTransaction, getUnderlying, getUser, isMVCC, load, load, load, load, load, load, query, registerHook, reload, setDatabaseOwner, setInternal, setMVCC, unregisterHook
 
Methods inherited from interface com.orientechnologies.orient.core.db.ODatabase
addCluster, addDataSegment, addLogicalCluster, addPhysicalCluster, callInLock, close, countClusterElements, countClusterElements, countClusterElements, create, declareIntent, delete, dropCluster, dropCluster, exists, get, getClusterIdByName, getClusterNameById, getClusterNames, getClusterRecordSizeById, getClusterRecordSizeByName, getClusters, getClusterType, getDefaultClusterId, getLevel1Cache, getLevel2Cache, getName, getProperties, getProperty, getStatus, getStorage, getURL, isClosed, open, registerListener, reload, set, setProperty, setStatus, unregisterListener
 
Methods inherited from interface com.orientechnologies.orient.core.db.OUserObject2RecordHandler
existsUserObjectByRID, getRecordByUserObject, getUserObjectByRecord, registerUserObject
 

Constructor Detail

ODatabaseDocumentTx

public ODatabaseDocumentTx(java.lang.String iURL)
Method Detail

newInstance

public ODocument newInstance()
Description copied from interface: ODatabaseComplex
Creates a new entity instance.

Specified by:
newInstance in interface ODatabaseComplex<ORecordInternal<?>>
Overrides:
newInstance in class ODatabaseRecordWrapperAbstract<ODatabaseRecordTx>
Returns:
The new instance.

newInstance

public ODocument newInstance(java.lang.String iClassName)
Description copied from interface: ODatabaseSchemaAware
Creates a new entity instance.

Specified by:
newInstance in interface ODatabaseSchemaAware<ORecordInternal<?>>
Returns:
The new instance.

browseClass

public ORecordIteratorClass<ODocument> browseClass(java.lang.String iClassName)
Description copied from interface: ODatabaseDocument
Browses all the records of the specified class and also all the subclasses. If you've a class Vehicle and Car that extends Vehicle then a db.browseClass("Vehicle", true) will return all the instances of Vehicle and Car. The order of the returned instance starts from record id with position 0 until the end. Base classes are worked at first.

Specified by:
browseClass in interface ODatabaseDocument
Parameters:
iClassName - Class name to iterate
Returns:
Iterator of ODocument instances

browseClass

public ORecordIteratorClass<ODocument> browseClass(java.lang.String iClassName,
                                                   boolean iPolymorphic)
Description copied from interface: ODatabaseDocument
Browses all the records of the specified class and if iPolymorphic is true also all the subclasses. If you've a class Vehicle and Car that extends Vehicle then a db.browseClass("Vehicle", true) will return all the instances of Vehicle and Car. The order of the returned instance starts from record id with position 0 until the end. Base classes are worked at first.

Specified by:
browseClass in interface ODatabaseDocument
Parameters:
iClassName - Class name to iterate
iPolymorphic - Consider also the instances of the subclasses or not
Returns:
Iterator of ODocument instances

browseCluster

public ORecordIteratorCluster<ODocument> browseCluster(java.lang.String iClusterName)
Description copied from interface: ODatabaseRecord
Browses all the records of the specified cluster.

Specified by:
browseCluster in interface ODatabaseRecord
Overrides:
browseCluster in class ODatabaseRecordWrapperAbstract<ODatabaseRecordTx>
Parameters:
iClusterName - Cluster name to iterate
Returns:
Iterator of ODocument instances

save

public ODatabaseDocumentTx save(ORecordInternal<?> iRecord)
Saves a document to the database. Behavior depends by the current running transaction if any. If no transaction is running then changes apply immediately. If an Optimistic transaction is running then the record will be changed at commit time. The current transaction will continue to see the record as modified, while others not. If a Pessimistic transaction is running, then an exclusive lock is acquired against the record. Current transaction will continue to see the record as modified, while others can't access to it since it's locked. 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.Before to save the document it must be valid following the constraints declared in the schema if any (can work also in schema-less mode). To validate the document the ORecordSchemaAwareAbstract.validate() is called.

Specified by:
save in interface ODatabaseComplex<ORecordInternal<?>>
Overrides:
save in class ODatabaseRecordWrapperAbstract<ODatabaseRecordTx>
Parameters:
iRecord - Record to save.
Returns:
The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
Throws:
OConcurrentModificationException - if the version of the document is different by the version contained in the database.
OValidationException - if the document breaks some validation constraints defined in the schema
See Also:
#setMVCC(boolean), {@link #isMVCC()}

save

public ODatabaseDocumentTx save(ORecordInternal<?> iContent,
                                java.lang.String iClusterName)
Saves a document specifying a cluster where to store the record. Behavior depends by the current running transaction if any. If no transaction is running then changes apply immediately. If an Optimistic transaction is running then the record will be changed at commit time. The current transaction will continue to see the record as modified, while others not. If a Pessimistic transaction is running, then an exclusive lock is acquired against the record. Current transaction will continue to see the record as modified, while others can't access to it since it's locked. 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. Before to save the document it must be valid following the constraints declared in the schema if any (can work also in schema-less mode). To validate the document the ORecordSchemaAwareAbstract.validate() is called.

Specified by:
save in interface ODatabaseComplex<ORecordInternal<?>>
Overrides:
save in class ODatabaseRecordWrapperAbstract<ODatabaseRecordTx>
Parameters:
iRecord - Record to save
iClusterName - Cluster name where to save the record
Returns:
The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
Throws:
OConcurrentModificationException - if the version of the document is different by the version contained in the database.
OValidationException - if the document breaks some validation constraints defined in the schema
See Also:
#setMVCC(boolean), {@link #isMVCC()}, ORecordSchemaAware#validate()

delete

public ODatabaseDocumentTx delete(ODocument iContent)
Deletes a document. Behavior depends by the current running transaction if any. If no transaction is running then the record is deleted immediately. If an Optimistic transaction is running then the record will be deleted at commit time. The current transaction will continue to see the record as deleted, while others not. If a Pessimistic transaction is running, then an exclusive lock is acquired against the record. Current transaction will continue to see the record as deleted, while others can't access to it since it's locked. 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.

Parameters:
iContent -
Returns:
The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
See Also:
#setMVCC(boolean), {@link #isMVCC()}

countClass

public long countClass(java.lang.String iClassName)
Returns the number of the records of the class iClassName.

Specified by:
countClass in interface ODatabaseSchemaAware<ORecordInternal<?>>
Parameters:
iClassName - Class name
Returns:
Total entities

commit

public ODatabaseComplex<ORecordInternal<?>> commit()
Description copied from interface: ODatabaseComplex
Commits 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 effectives. If the operation fails, all the changed entities will be restored in the datastore. Memory instances are not guaranteed to being restored as well.

Specified by:
commit in interface ODatabaseComplex<ORecordInternal<?>>
Returns:

rollback

public ODatabaseComplex<ORecordInternal<?>> rollback()
Description copied from interface: ODatabaseComplex
Aborts the current running transaction. All the pending changed entities will be restored in the datastore. Memory instances are not guaranteed to being restored as well.

Specified by:
rollback in interface ODatabaseComplex<ORecordInternal<?>>
Returns:


Copyrights 2010-2011 (c) Luca Garulli. All Rights Reserved. This software is released as Open Source using the Apache 2.0 license.