All Implemented Interfaces:
Serializable, Cloneable, CoreSession<ClassDescriptor,Login,Platform,Project,SessionEventManager>, CommandProcessor, Session, UnitOfWork

public class RemoteUnitOfWork extends RepeatableWriteUnitOfWork
Counter part of the unit of work which exists on the client side.
See Also:
  • Field Details

    • newObjectsCache

      protected List newObjectsCache
    • unregisteredNewObjectsCache

      protected List unregisteredNewObjectsCache
    • isOnClient

      protected boolean isOnClient
    • parentSessionController

      protected transient RemoteSessionController parentSessionController
    • isFlush

      protected boolean isFlush
  • Constructor Details

  • Method Details

    • isFlush

      public boolean isFlush()
    • setIsFlush

      public void setIsFlush(boolean isFlush)
    • beginEarlyTransaction

      public void beginEarlyTransaction() throws DatabaseException
      PUBLIC: Tell the unit of work to begin a transaction now. By default the unit of work will begin a transaction at commit time. The default is the recommended approach, however sometimes it is necessary to start the transaction before commit time. When the unit of work commits, this transaction will be committed.
      Specified by:
      beginEarlyTransaction in interface UnitOfWork
      Overrides:
      beginEarlyTransaction in class UnitOfWorkImpl
      Throws:
      DatabaseException
      See Also:
    • acquireUnitOfWork

      public UnitOfWorkImpl acquireUnitOfWork()
      The nested unit of work must also be remote.
      Specified by:
      acquireUnitOfWork in interface Session
      Overrides:
      acquireUnitOfWork in class UnitOfWorkImpl
      See Also:
    • acquireUnitOfWork

      public UnitOfWorkImpl acquireUnitOfWork(ReferenceMode referenceMode)
      The nested unit of work must also be remote.
      Specified by:
      acquireUnitOfWork in interface Session
      Overrides:
      acquireUnitOfWork in class AbstractSession
      Parameters:
      referenceMode - The reference type the UOW should use internally when referencing Working clones. Setting this to WEAK means the UOW will use weak references to reference clones that support active object change tracking and hard references for deferred change tracked objects. Setting to FORCE_WEAK means that all objects will be referenced by weak references and if the application no longer references the clone the clone may be garbage collected. If the clone has uncommitted changes then those changes will be lost.
      See Also:
    • collectNewObjects

      protected List collectNewObjects()
      This is done to maintain correspondence between local new objects and returned new objects from serialization. Object correspondence is maintained by comparing primary keys but for new objects it is possible that primary key value is null as it is still not inserted. The returned new objects from serialization will have primary key value which will be inserted into corresponding local new objects.
    • collectUnregisteredNewObjects

      protected List collectUnregisteredNewObjects()
      This is done to maintain correspondence between local unregistered new objects and returned unregistered new objects from serialization. Object correspondence is maintained by comparing primary keys but for unregistered new objects it is possible that primary key value is null as it is still not inserted. The returned unregistered new objects from serialization will have primary key value which will be inserted into corresponding local new objects.
    • commitIntoRemoteUnitOfWork

      protected void commitIntoRemoteUnitOfWork()
      The remote unit of work returned after its commit on the server is merged with remote unit of work on the remote side.
    • writeChanges

      public void writeChanges()
      Simulate a flush, current just begins a transaction and commits.
      Specified by:
      writeChanges in interface UnitOfWork
      Overrides:
      writeChanges in class RepeatableWriteUnitOfWork
    • commitRootUnitOfWork

      public void commitRootUnitOfWork()
      Starts committing the remote unit of work. This must serialize the unit of work across to the server, commit the unit of work on the server, serialize it back and merge any server-side changes (such as sequence numbers) it into itself, then merge into the parent remote session.
      Overrides:
      commitRootUnitOfWork in class RepeatableWriteUnitOfWork
    • calculateChanges

      public UnitOfWorkChangeSet calculateChanges(Map registeredObjects, UnitOfWorkChangeSet changeSet, boolean assignSequences, boolean shouldCloneMap)
      INTERNAL: Changes are calculated on the client, so avoid recalculating them on the server.
      Overrides:
      calculateChanges in class UnitOfWorkImpl
    • resumeUnitOfWork

      public void resumeUnitOfWork()
      INTERNAL: Resume is not required on the server.
      Overrides:
      resumeUnitOfWork in class UnitOfWorkImpl
    • commitRootUnitOfWorkOnClient

      protected void commitRootUnitOfWorkOnClient()
      Merges remote unit of work to parent remote session.
    • executeQuery

      public Object executeQuery(String queryName) throws DatabaseException
      PUBLIC: Execute the pre-defined query by name and return the result. Queries can be pre-defined and named to allow for their reuse. The named query can be defined on the remote session or the server-side session.
      Specified by:
      executeQuery in interface Session
      Overrides:
      executeQuery in class AbstractSession
      Throws:
      DatabaseException
      See Also:
    • executeQuery

      public Object executeQuery(String queryName, Class<?> domainClass) throws DatabaseException
      PUBLIC: Execute the pre-defined query by name and return the result. Queries can be pre-defined and named to allow for their reuse. The class is the descriptor in which the query was pre-defined. The query is executed on the server-side session.
      Specified by:
      executeQuery in interface Session
      Overrides:
      executeQuery in class AbstractSession
      Throws:
      DatabaseException
      See Also:
    • executeQuery

      public Object executeQuery(String queryName, Class<?> domainClass, Vector argumentValues) throws DatabaseException
      PUBLIC: Execute the pre-defined query by name and return the result. Queries can be pre-defined and named to allow for their reuse. The class is the descriptor in which the query was pre-defined.
      Overrides:
      executeQuery in class AbstractSession
      Throws:
      DatabaseException
      See Also:
    • executeQuery

      public Object executeQuery(String queryName, Vector argumentValues) throws DatabaseException
      PUBLIC: Execute the pre-defined query by name and return the result. Queries can be pre-defined and named to allow for their reuse.
      Overrides:
      executeQuery in class AbstractSession
      Throws:
      DatabaseException
      See Also:
    • getDescriptor

      public ClassDescriptor getDescriptor(Class<?> domainClass)
      Return the table descriptor specified for the class.
      Specified by:
      getDescriptor in interface CoreSession<ClassDescriptor,Login,Platform,Project,SessionEventManager>
      Specified by:
      getDescriptor in interface Session
      Overrides:
      getDescriptor in class AbstractSession
    • getDescriptorForAlias

      public ClassDescriptor getDescriptorForAlias(String alias)
      Return the table descriptor specified for the class.
      Specified by:
      getDescriptorForAlias in interface Session
      Overrides:
      getDescriptorForAlias in class AbstractSession
      Parameters:
      alias - The descriptor alias.
      Returns:
      The descriptor for the alias or null if no descriptor was found.
    • getNewObjectsCache

      public List getNewObjectsCache()
      Returns a new object cache
    • getParentSessionController

      public RemoteSessionController getParentSessionController()
      INTERNAL: Method returns the parent RemoteSessionController for this Remote UnitOfWork Used to retrieve Valueholders that were used on the client
    • getPlatform

      public DatabasePlatform getPlatform()
      INTERNAL: Return the database platform currently connected to. The platform is used for database specific behavior.
      Specified by:
      getPlatform in interface Session
      Overrides:
      getPlatform in class AbstractSession
    • getDatasourcePlatform

      public Platform getDatasourcePlatform()
      INTERNAL: Return the database platform currently connected to. The platform is used for database specific behavior.
      Specified by:
      getDatasourcePlatform in interface CoreSession<ClassDescriptor,Login,Platform,Project,SessionEventManager>
      Specified by:
      getDatasourcePlatform in interface Session
      Overrides:
      getDatasourcePlatform in class AbstractSession
    • getUnregisteredNewObjectsCache

      public List getUnregisteredNewObjectsCache()
      Returns an unregistered new object cache
    • internalExecuteQuery

      public Object internalExecuteQuery(DatabaseQuery query, AbstractRecord Record) throws DatabaseException, QueryException
      INTERNAL: Return the results from exeucting the database query. the arguments should be a database row with raw data values.
      Overrides:
      internalExecuteQuery in class UnitOfWorkImpl
      Throws:
      DatabaseException
      QueryException
    • isOnClient

      protected boolean isOnClient()
    • isRemoteUnitOfWork

      public boolean isRemoteUnitOfWork()
      Return if this session is a unit of work.
      Specified by:
      isRemoteUnitOfWork in interface Session
      Overrides:
      isRemoteUnitOfWork in class AbstractSession
    • prepareForMergeIntoRemoteUnitOfWork

      protected void prepareForMergeIntoRemoteUnitOfWork()
      The returned remote unit of work from the server is prepared to merge with local remote unit of work.
    • reinitializeForSession

      public void reinitializeForSession(AbstractSession session, RemoteSessionController parentSessionController)
      INTERNAL: Re-initialize for the server-side session. This is done when the uow is passed back to the server for committing.
    • fixRemoteChangeSet

      protected void fixRemoteChangeSet(UnitOfWorkChangeSet uowChangeSet, Map cloneMap, AbstractSession session)
      INTERNAL: Fix the transient fields in the serialized change set.
    • setIsOnClient

      protected void setIsOnClient(boolean isOnClient)
    • setNewObjectsCache

      protected void setNewObjectsCache(List newObjectsCache)
      Set a new object cache
    • setParentSessionController

      public void setParentSessionController(RemoteSessionController parentSessionController)
      INTERNAL: Sets the parent RemoteSessionController for this Remote UnitOfWork Used to retrieve Valueholders that were used on the client
    • setUnregisteredNewObjectsCache

      protected void setUnregisteredNewObjectsCache(List unregisteredNewObjectsCache)
      Set unregistered new object cache
    • toString

      public String toString()
      Avoid the toString printing the accessor and platform.
      Overrides:
      toString in class AbstractSession
    • verifyDelete

      public boolean verifyDelete(Object domainObject)
      TESTING: This is used by testing code to ensure that a deletion was successful.
      Overrides:
      verifyDelete in class AbstractSession