Interface ODatabaseObject

All Superinterfaces:
AutoCloseable, Closeable, OBackupable, ODatabase<Object>, OUserObject2RecordHandler
All Known Implementing Classes:
OObjectDatabaseTx, OObjectDatabaseTxPooled

public interface ODatabaseObject extends ODatabase<Object>, OUserObject2RecordHandler
Generic interface for object based Database implementations. Binds to/from Document and POJOs.
Author:
Luca Garulli (l.garulli--(at)--orientdb.com)
  • Method Details

    • setDirty

      void setDirty(Object iPojo)
      Sets as dirty a POJO. This is useful when you change the object and need to tell to the engine to treat as dirty.
      Parameters:
      iPojo - User object
    • unsetDirty

      void unsetDirty(Object iPojo)
      Sets as not dirty a POJO. This is useful when you change some other object and need to tell to the engine to treat this one as not dirty.
      Parameters:
      iPojo - User object
    • browseCluster

      <RET> OObjectIteratorClusterInterface<RET> browseCluster(String iClusterName)
      Browses all the records of the specified cluster.
      Parameters:
      iClusterName - Cluster name to iterate
      Returns:
      Iterator of Object instances
    • browseClass

      <RET> OObjectIteratorClassInterface<RET> browseClass(Class<RET> iClusterClass)
      Browses all the records of the specified class.
      Parameters:
      iClusterClass - Class name to iterate
      Returns:
      Iterator of Object instances
    • newInstance

      <RET> RET newInstance(String iClassName)
      Creates a new entity instance. Each database implementation will return the right type.
      Returns:
      The new instance.
    • countClass

      long countClass(String iClassName)
      Counts the entities contained in the specified class and sub classes (polymorphic).
      Parameters:
      iClassName - Class name
      Returns:
      Total entities
    • countClass

      long countClass(String iClassName, boolean iPolymorphic)
      Counts the entities contained in the specified class.
      Parameters:
      iClassName - Class name
      iPolymorphic - True if consider also the sub classes, otherwise false
      Returns:
      Total entities
    • newInstance

      <T> T newInstance(Class<T> iType)
      Creates a new entity of the specified class.
      Parameters:
      iType - Class name where to originate the instance
      Returns:
      New instance
    • getEntityManager

      OEntityManager getEntityManager()
      Returns the entity manager that handle the binding from ODocuments and POJOs.
      Returns:
    • detach

      <RET> RET detach(Object iPojo)
      Method that detaches all fields contained in the document to the given object. It returns by default a proxied instance. To get a detached non proxied instance @see {@link OObjectEntitySerializer.detach(T, ODatabaseObject)}
      Parameters:
      iPojo - :- the object to detach
      Returns:
      the detached object
    • detach

      <RET> RET detach(Object iPojo, boolean returnNonProxiedInstance)
      Method that detaches all fields contained in the document to the given object.
      Type Parameters:
      RET -
      Parameters:
      iPojo - :- the object to detach
      returnNonProxiedInstance - :- 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

      default <RET> RET detachAll(Object iPojo)
      Method that detaches all fields contained in the document to the given object and recursively all object tree. This may throw a StackOverflowError with big objects tree. To avoid it set the stack size with -Xss java option
      Type Parameters:
      RET -
      Parameters:
      iPojo - :- the objects to detach
      Returns:
      the object serialized or with detached data
    • detachAll

      <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. This may throw a StackOverflowError with big objects tree. To avoid it set the stack size with -Xss java option
      Type Parameters:
      RET -
      Parameters:
      iPojo - :- the objects to detach
      returnNonProxiedInstance - :- 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
    • isRetainObjects

      boolean isRetainObjects()
    • setRetainObjects

      ODatabase setRetainObjects(boolean iRetainObjects)
    • stream2pojo

      Object stream2pojo(ODocument iRecord, Object iPojo, String iFetchPlan)
    • pojo2Stream

      ODocument pojo2Stream(Object iPojo, ODocument iRecord)
    • isLazyLoading

      boolean isLazyLoading()
    • setLazyLoading

      void setLazyLoading(boolean lazyLoading)
    • getMetadata

      OMetadataObject getMetadata()
      Description copied from interface: ODatabase
      Return the OMetadata instance. Cannot be null.
      Specified by:
      getMetadata in interface ODatabase<Object>
      Returns:
      The OMetadata instance.
    • objectQuery

      <RET extends List<?>> RET objectQuery(String iCommand, Object... iArgs)
    • objectQuery

      <RET extends List<?>> RET objectQuery(String iCommand, Map<String,Object> iArgs)
    • objectCommand

      <RET extends List<?>> RET objectCommand(String iCommand, Object... iArgs)
    • objectCommand

      <RET extends List<?>> RET objectCommand(String iCommand, Map<String,Object> iArgs)
    • executeWithRetry

      default <T> T executeWithRetry(int nRetries, Function<ODatabaseSession,T> function) throws IllegalStateException, IllegalArgumentException, ONeedRetryException, UnsupportedOperationException
      Description copied from interface: ODatabase
      Tries 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:
      executeWithRetry in interface ODatabase<Object>
      Type Parameters:
      T - the return type of the lambda
      Parameters:
      nRetries - the maximum number of retries (> 0)
      function - a lambda containing application code to execute in a commit/retry loop
      Returns:
      The result of the execution of the lambda
      Throws:
      IllegalStateException - if there are operations in the current transaction
      IllegalArgumentException - if nRetries is <= 0
      ONeedRetryException - if the maximum number of retries is executed and all failed with an ONeedRetryException
      UnsupportedOperationException - if this type of database does not support automatic commit/retry