Class DetachedStateManager

    • Field Detail

      • dblval

        protected double dblval
      • longval

        protected long longval
      • objval

        protected java.lang.Object objval
      • field

        protected int field
    • Constructor Detail

      • DetachedStateManager

        public DetachedStateManager​(PersistenceCapable pc,
                                    OpenJPAStateManager sm,
                                    java.util.BitSet load,
                                    boolean access,
                                    boolean multithreaded)
        Constructor.
        Parameters:
        pc - the managed instance
        sm - the instance's state manager
        load - the set of detached field indexes
        access - whether to allow access to unloaded fields
        multithreaded - whether the instance will be used concurrently by multiple threads
    • Method Detail

      • attach

        public java.lang.Object attach​(AttachManager manager,
                                       java.lang.Object toAttach,
                                       ClassMetaData meta,
                                       PersistenceCapable into,
                                       OpenJPAStateManager owner,
                                       ValueMetaData ownerMeta,
                                       boolean explicit)
        Attach.
        Parameters:
        manager - manager holding cache of attached instances
        toAttach - detached instance
        meta - metadata for the instance being attached
        into - instance we're attaching into
        owner - state manager for into
        ownerMeta - field we traversed to find toAttach
        explicit - whether to make new instances explicitly persistent
      • getDetachedObjectId

        protected java.lang.Object getDetachedObjectId​(AttachManager manager,
                                                       java.lang.Object toAttach)
        Return the identity of the given detached instance.
      • provideField

        protected void provideField​(java.lang.Object toAttach,
                                    StateManagerImpl sm,
                                    int field)
        Provide the given field into this field manager.
      • ignoreLoaded

        protected static boolean ignoreLoaded​(FieldMetaData fmd)
        Ignore if the field is not dirty but loaded
      • getPCPrimaryKey

        public java.lang.Object getPCPrimaryKey​(java.lang.Object oid,
                                                int field)
        Description copied from interface: StateManager
        Return the persistence-capable primary key object by extracting the identity value of the related instance stored in the given field from the given object id.
        Specified by:
        getPCPrimaryKey in interface StateManager
      • setVersion

        public void setVersion​(java.lang.Object version)
        Description copied from interface: OpenJPAStateManager
        Set the version indicator for this instance, as loaded from the data store. This method is used by the StoreManager when loading instance data. On rollback, the version will be rolled back to this value. Version objects should be serializable and should not require vendor-specific classes, because they are transferred to detached objects.
        Specified by:
        setVersion in interface OpenJPAStateManager
      • isDirty

        public boolean isDirty()
        Description copied from interface: StateManager
        Whether the instance has been modified in this transaction.
        Specified by:
        isDirty in interface StateManager
      • isTransactional

        public boolean isTransactional()
        Description copied from interface: StateManager
        Whether the instance is transactional.
        Specified by:
        isTransactional in interface StateManager
      • isPersistent

        public boolean isPersistent()
        Description copied from interface: StateManager
        Whether the instance is persistent.
        Specified by:
        isPersistent in interface StateManager
      • isNew

        public boolean isNew()
        Description copied from interface: StateManager
        Whether the instance is newly-persisted in this transaction.
        Specified by:
        isNew in interface StateManager
      • isDeleted

        public boolean isDeleted()
        Description copied from interface: StateManager
        Whether the instance is deleted in this transaction.
        Specified by:
        isDeleted in interface StateManager
      • isDetached

        public boolean isDetached()
        Description copied from interface: StateManager
        Whether the instance is detached (i.e. this manager is a detached state manager)
        Specified by:
        isDetached in interface StateManager
      • dirty

        public void dirty​(java.lang.String field)
        Description copied from interface: StateManager
        Make named field dirty.
        Specified by:
        dirty in interface StateManager
      • fetchObjectId

        public java.lang.Object fetchObjectId()
        Description copied from interface: StateManager
        Return the object id, assigning it if necessary.
        Specified by:
        fetchObjectId in interface StateManager
      • serializing

        public boolean serializing()
        Description copied from interface: StateManager
        Callback to prepare instance for serialization.
        Specified by:
        serializing in interface StateManager
        Returns:
        true to null detached state after serialize
      • writeDetached

        public boolean writeDetached​(java.io.ObjectOutput out)
                              throws java.io.IOException
        Description copied from interface: StateManager
        Write detached state object and detached state manager to the given stream.
        Specified by:
        writeDetached in interface StateManager
        Returns:
        true if managed fields also written to stream
        Throws:
        java.io.IOException
      • proxyDetachedDeserialized

        public void proxyDetachedDeserialized​(int idx)
        Description copied from interface: StateManager
        Proxy the given detached field after deserialization.
        Specified by:
        proxyDetachedDeserialized in interface StateManager
      • initialize

        public void initialize​(java.lang.Class forType,
                               PCState state)
        Description copied from interface: OpenJPAStateManager
        Initialize the state manager with a new instance of the given persistence capable type and the proper lifecycle state. Invoking this method may change the object id and metadata for the state manager, as the concrete type specified in the parameter may be a subclass of the expected type.
        Specified by:
        initialize in interface OpenJPAStateManager
        Parameters:
        forType - the type for which to create a new instance
        state - the initial state to which to set the instance
      • isFlushed

        public boolean isFlushed()
        Description copied from interface: OpenJPAStateManager
        Return whether this object has been flushed to the datastore in this transaction.
        Specified by:
        isFlushed in interface OpenJPAStateManager
      • getUseDSFForUnproxy

        public boolean getUseDSFForUnproxy()
        Should DetachedStateField be used by Proxies to determine when to remove $proxy wrappers during serialization.
        Since:
        2.0.0
      • getFlushed

        public java.util.BitSet getFlushed()
        Description copied from interface: OpenJPAStateManager
        Return a read-only mask of the indexes of all fields that have been flushed since they were last changed.
        Specified by:
        getFlushed in interface OpenJPAStateManager
      • getUnloaded

        public java.util.BitSet getUnloaded​(FetchConfiguration fetch)
        Description copied from interface: OpenJPAStateManager
        Return a mutable mask of the unloaded fields that need loading based on the given fetch configuration. Pass in null to retrieve all unloaded fields.
        Specified by:
        getUnloaded in interface OpenJPAStateManager
      • getObjectId

        public java.lang.Object getObjectId()
        Description copied from interface: OpenJPAStateManager
        Return the instance's object id. This method will return null if no oid has been assigned. Oids are assigned to newly-persisted instances when the user first asks for it, or on flush.
        Specified by:
        getObjectId in interface OpenJPAStateManager
      • setObjectId

        public void setObjectId​(java.lang.Object oid)
        Description copied from interface: OpenJPAStateManager
        Set the object id for the managed instance. Some back ends may not be able to assign a permanent oid until flush. Do not call this method on application identity instances; changing the primary key fields of application identity objects through the storeXXXField methods will automatically change the oid.
        Specified by:
        setObjectId in interface OpenJPAStateManager
      • assignObjectId

        public boolean assignObjectId​(boolean flush)
        Description copied from interface: OpenJPAStateManager
        Ask the store manager to assign a permanent oid to this new instance.
        Specified by:
        assignObjectId in interface OpenJPAStateManager
        Parameters:
        flush - if true, flush if necessary to get a permanent oid; if false, the oid may be left unassigned
        Returns:
        true if an oid assigned, false otherwise
      • getId

        public java.lang.Object getId()
        Description copied from interface: OpenJPAStateManager
        Return the identifier for this state manager. This may return a temporary identifier for new unflushed instances that have not been assigned an object id, or for non-persistent or embedded instances. For all other instances this method is the same as OpenJPAStateManager.getObjectId().
        Specified by:
        getId in interface OpenJPAStateManager
      • getLock

        public java.lang.Object getLock()
        Description copied from interface: OpenJPAStateManager
        The lock object set for this instance. This object is generally managed by the system lock manager.
        Specified by:
        getLock in interface OpenJPAStateManager
      • setLock

        public void setLock​(java.lang.Object lock)
        Description copied from interface: OpenJPAStateManager
        The lock object set for this instance. This object is generally managed by the system lock manager.
        Specified by:
        setLock in interface OpenJPAStateManager
      • getImplData

        public java.lang.Object getImplData()
        Description copied from interface: OpenJPAStateManager
        An object that concrete back ends can associate with each instance. This object is not used or modified in any way by the generic persistence layer.
        Specified by:
        getImplData in interface OpenJPAStateManager
      • setImplData

        public java.lang.Object setImplData​(java.lang.Object data,
                                            boolean cacheable)
        Description copied from interface: OpenJPAStateManager
        An object that concrete back ends can associate with each instance. This object is not used or modified in any way by the generic persistence layer.
        Specified by:
        setImplData in interface OpenJPAStateManager
        cacheable - whether the impl data can be shared among instances in different contexts if L2 caching is enabled
        Returns:
        the previous impl data value, if any
      • isImplDataCacheable

        public boolean isImplDataCacheable()
        Description copied from interface: OpenJPAStateManager
        Whether the instance-level impl data can be shared among instances in different contexts if L2 caching is enabled.
        Specified by:
        isImplDataCacheable in interface OpenJPAStateManager
      • getImplData

        public java.lang.Object getImplData​(int field)
        Description copied from interface: OpenJPAStateManager
        Field-level impl data. Field-level data only applies to loaded fields, and is cleared when the field is cleared.
        Specified by:
        getImplData in interface OpenJPAStateManager
      • setImplData

        public java.lang.Object setImplData​(int field,
                                            java.lang.Object data)
        Description copied from interface: OpenJPAStateManager
        Field-level impl data. Field-level data only applies to loaded fields, and is cleared when the field is cleared. Whether the data is cached across instances depends on the corresponding field metadata's response to FieldMetaData.usesImplData().
        Specified by:
        setImplData in interface OpenJPAStateManager
        Returns:
        the previous impl data value, if any
      • isImplDataCacheable

        public boolean isImplDataCacheable​(int field)
        Description copied from interface: OpenJPAStateManager
        Whether the field's impl data is loaded and can be shared among instances in different contexts if L2 caching is enabled.
        Specified by:
        isImplDataCacheable in interface OpenJPAStateManager
      • getIntermediate

        public java.lang.Object getIntermediate​(int field)
        Description copied from interface: OpenJPAStateManager
        Use intermediate field data to store intermediate information that might be available before the field is fully loaded. The system will automatically clear this data when the field gets loaded. This data should be cacheable; the datastore cache will attempt to cache it if the field value is not available.
        Specified by:
        getIntermediate in interface OpenJPAStateManager
      • setIntermediate

        public void setIntermediate​(int field,
                                    java.lang.Object data)
        Description copied from interface: OpenJPAStateManager
        Use intermediate field data to store intermediate information that might be available before the field is fully loaded. The system will automatically clear this data when the field gets loaded. This data should be cacheable; the datastore cache will attempt to cache it if the field value is not available.
        Specified by:
        setIntermediate in interface OpenJPAStateManager
      • removed

        public void removed​(int field,
                            java.lang.Object removed,
                            boolean key)
        Description copied from interface: OpenJPAStateManager
        Notification that an element has been removed from the given field.
        Specified by:
        removed in interface OpenJPAStateManager
      • storeByte

        public void storeByte​(int field,
                              byte extVal)
        Description copied from interface: OpenJPAStateManager
        Set the given external value back into the given field.
        Specified by:
        storeByte in interface OpenJPAStateManager
      • storeChar

        public void storeChar​(int field,
                              char extVal)
        Description copied from interface: OpenJPAStateManager
        Set the given external value back into the given field.
        Specified by:
        storeChar in interface OpenJPAStateManager
      • storeInt

        public void storeInt​(int field,
                             int extVal)
        Description copied from interface: OpenJPAStateManager
        Set the given external value back into the given field.
        Specified by:
        storeInt in interface OpenJPAStateManager
      • storeLong

        public void storeLong​(int field,
                              long extVal)
        Description copied from interface: OpenJPAStateManager
        Set the given external value back into the given field.
        Specified by:
        storeLong in interface OpenJPAStateManager
      • storeString

        public void storeString​(int field,
                                java.lang.String extVal)
        Description copied from interface: OpenJPAStateManager
        Set the given external value back into the given field.
        Specified by:
        storeString in interface OpenJPAStateManager
      • storeObject

        public void storeObject​(int field,
                                java.lang.Object extVal)
        Description copied from interface: OpenJPAStateManager
        Set the given external value back into the given field.
        Specified by:
        storeObject in interface OpenJPAStateManager
      • storeField

        public void storeField​(int field,
                               java.lang.Object value)
        Description copied from interface: OpenJPAStateManager
        Set the value of the field with the given index as an object.
        Specified by:
        storeField in interface OpenJPAStateManager
      • fetchField

        public java.lang.Object fetchField​(int field,
                                           boolean transitions)
        Description copied from interface: OpenJPAStateManager
        Return the value of the field with the given index as an object.
        Specified by:
        fetchField in interface OpenJPAStateManager
        transitions - if true, this method will cause state transitions to occur as if the field were accessed normally
      • fetchInitialField

        public java.lang.Object fetchInitialField​(int field)
        Description copied from interface: OpenJPAStateManager
        Return the value of the field at the specified index as of the beginning of the transaction.
        Specified by:
        fetchInitialField in interface OpenJPAStateManager
      • setRemote

        public void setRemote​(int field,
                              java.lang.Object value)
        Description copied from interface: OpenJPAStateManager
        Set the given field to the given value. Make the field dirty as if user code set it. Do not delete dependent objects in the field's current value. This method is invoked by the remote package to synch a server-side state manager with remote changes. We do not need to delete dependent instances because they will have been deleted when the field changed on the client side, and those client-side deletes will be transmitted independently.
        Specified by:
        setRemote in interface OpenJPAStateManager
      • lock

        public void lock()
      • unlock

        public void unlock()
      • isDelayed

        public boolean isDelayed​(int field)
        Description copied from interface: OpenJPAStateManager
        Some field types (collection proxies) support delayed loading. Delayed loading is a step beyond lazy loading. Delayed load allows an instance of a field to be returned without actually loading it.
        Specified by:
        isDelayed in interface OpenJPAStateManager
        Returns:
        true if the field is setup for delayed access
      • setDelayed

        public void setDelayed​(int field,
                               boolean delay)
        Description copied from interface: OpenJPAStateManager
        Some field types (collection proxies) support delayed loading. Delayed loading is a step beyond lazy loading. Delayed load allows an instance of a field to be returned without actually loading it.
        Specified by:
        setDelayed in interface OpenJPAStateManager
      • loadDelayedField

        public void loadDelayedField​(int field)
        Description copied from interface: OpenJPAStateManager
        If a field was marked delayed in a previous load operation this method can be used to load the field.
        Specified by:
        loadDelayedField in interface OpenJPAStateManager
      • attachField

        protected boolean attachField​(AttachManager manager,
                                      java.lang.Object toAttach,
                                      StateManagerImpl sm,
                                      FieldMetaData fmd,
                                      boolean nullLoaded)
        Attach the given field into the given instance.
        Parameters:
        toAttach - the detached persistent instance
        sm - state manager for the managed instance we're copying into; toAttach also uses this state manager
        fmd - metadata on the field we're copying
        nullLoaded - if false, nulls will be considered unloaded and will not be attached
      • getReference

        protected java.lang.Object getReference​(AttachManager manager,
                                                java.lang.Object toAttach,
                                                OpenJPAStateManager sm,
                                                ValueMetaData vmd)
        Return a managed, possibly hollow reference for the given detached object.
      • attachCollection

        protected java.util.Collection attachCollection​(AttachManager manager,
                                                        java.util.Collection orig,
                                                        OpenJPAStateManager sm,
                                                        FieldMetaData fmd)
        Return a new collection with the attached contents of the given one.
      • fetchBooleanField

        public boolean fetchBooleanField​(int field)
        Description copied from interface: FieldSupplier
        Return the value of the given field.
        Specified by:
        fetchBooleanField in interface FieldSupplier
      • fetchByteField

        public byte fetchByteField​(int field)
        Description copied from interface: FieldSupplier
        Return the value of the given field.
        Specified by:
        fetchByteField in interface FieldSupplier
      • fetchCharField

        public char fetchCharField​(int field)
        Description copied from interface: FieldSupplier
        Return the value of the given field.
        Specified by:
        fetchCharField in interface FieldSupplier
      • fetchDoubleField

        public double fetchDoubleField​(int field)
        Description copied from interface: FieldSupplier
        Return the value of the given field.
        Specified by:
        fetchDoubleField in interface FieldSupplier
      • fetchFloatField

        public float fetchFloatField​(int field)
        Description copied from interface: FieldSupplier
        Return the value of the given field.
        Specified by:
        fetchFloatField in interface FieldSupplier
      • fetchIntField

        public int fetchIntField​(int field)
        Description copied from interface: FieldSupplier
        Return the value of the given field.
        Specified by:
        fetchIntField in interface FieldSupplier
      • fetchLongField

        public long fetchLongField​(int field)
        Description copied from interface: FieldSupplier
        Return the value of the given field.
        Specified by:
        fetchLongField in interface FieldSupplier
      • fetchObjectField

        public java.lang.Object fetchObjectField​(int field)
        Description copied from interface: FieldSupplier
        Return the value of the given field.
        Specified by:
        fetchObjectField in interface FieldSupplier
      • fetchShortField

        public short fetchShortField​(int field)
        Description copied from interface: FieldSupplier
        Return the value of the given field.
        Specified by:
        fetchShortField in interface FieldSupplier
      • fetchStringField

        public java.lang.String fetchStringField​(int field)
        Description copied from interface: FieldSupplier
        Return the value of the given field.
        Specified by:
        fetchStringField in interface FieldSupplier
      • storeBooleanField

        public void storeBooleanField​(int field,
                                      boolean curVal)
        Description copied from interface: FieldConsumer
        Set the value of the given field.
        Specified by:
        storeBooleanField in interface FieldConsumer
      • storeByteField

        public void storeByteField​(int field,
                                   byte curVal)
        Description copied from interface: FieldConsumer
        Set the value of the given field.
        Specified by:
        storeByteField in interface FieldConsumer
      • storeCharField

        public void storeCharField​(int field,
                                   char curVal)
        Description copied from interface: FieldConsumer
        Set the value of the given field.
        Specified by:
        storeCharField in interface FieldConsumer
      • storeDoubleField

        public void storeDoubleField​(int field,
                                     double curVal)
        Description copied from interface: FieldConsumer
        Set the value of the given field.
        Specified by:
        storeDoubleField in interface FieldConsumer
      • storeFloatField

        public void storeFloatField​(int field,
                                    float curVal)
        Description copied from interface: FieldConsumer
        Set the value of the given field.
        Specified by:
        storeFloatField in interface FieldConsumer
      • storeIntField

        public void storeIntField​(int field,
                                  int curVal)
        Description copied from interface: FieldConsumer
        Set the value of the given field.
        Specified by:
        storeIntField in interface FieldConsumer
      • storeLongField

        public void storeLongField​(int field,
                                   long curVal)
        Description copied from interface: FieldConsumer
        Set the value of the given field.
        Specified by:
        storeLongField in interface FieldConsumer
      • storeObjectField

        public void storeObjectField​(int field,
                                     java.lang.Object curVal)
        Description copied from interface: FieldConsumer
        Set the value of the given field.
        Specified by:
        storeObjectField in interface FieldConsumer
      • storeShortField

        public void storeShortField​(int field,
                                    short curVal)
        Description copied from interface: FieldConsumer
        Set the value of the given field.
        Specified by:
        storeShortField in interface FieldConsumer
      • storeStringField

        public void storeStringField​(int field,
                                     java.lang.String curVal)
        Description copied from interface: FieldConsumer
        Set the value of the given field.
        Specified by:
        storeStringField in interface FieldConsumer
      • clear

        public void clear()
        Clear any held state. Fields are also cleared automatically when fetched.