Class PersistenceManagerWrapper

    • Method Detail

      • isClosed

        public boolean isClosed()
        A PersistenceManager instance can be used until it is closed.
        Specified by:
        isClosed in interface PersistenceManager
        Returns:
        if this PersistenceManager has been closed
        See Also:
        close()
      • close

        public void close()
        A PersistenceManager instance can be used until it is closed.

        This method closes the PersistenceManager, which if pooled, releases it to the pool of available PersistenceManagers.

        Specified by:
        close in interface PersistenceManager
      • currentTransaction

        public Transaction currentTransaction()
        There is exactly one Transaction associated with a PersistenceManager.
        Specified by:
        currentTransaction in interface PersistenceManager
        Returns:
        the Transaction associated with this PersistenceManager.
      • newQuery

        public Query newQuery()
        Create a new Query with no elements.
        Specified by:
        newQuery in interface PersistenceManager
        Returns:
        a new Query instance with no elements.
      • newQuery

        public Query newQuery​(Object compiled)
        Create a new Query using elements from another Query. The other Query must have been created by the same JDO implementation. It might be active in a different PersistenceManager or might have been serialized and restored.
        Specified by:
        newQuery in interface PersistenceManager
        Parameters:
        compiled - another Query from the same JDO implementation
        Returns:
        the new Query
      • newQuery

        public Query newQuery​(Class cls)
        Create a new Query specifying the Class of the results.
        Specified by:
        newQuery in interface PersistenceManager
        Parameters:
        cls - the Class of the results
        Returns:
        the new Query
      • newQuery

        public Query newQuery​(Class cls,
                              Collection cln)
        Create a new Query with the Class of the results and candidate Collection. specified.
        Specified by:
        newQuery in interface PersistenceManager
        Parameters:
        cls - the Class of results
        cln - the Collection of candidate instances
        Returns:
        the new Query
      • newQuery

        public Query newQuery​(Class cls,
                              String filter)
        Create a new Query with the Class of the results and Filter. specified.
        Specified by:
        newQuery in interface PersistenceManager
        Parameters:
        cls - the Class of results
        filter - the Filter for candidate instances
        Returns:
        the new Query
      • newQuery

        public Query newQuery​(Class cls,
                              Collection cln,
                              String filter)
        Create a new Query with the Class of the results, candidate Collection, and Filter.
        Specified by:
        newQuery in interface PersistenceManager
        Parameters:
        cls - the Class of results
        cln - the Collection of candidate instances
        filter - the Filter for candidate instances
        Returns:
        the new Query
      • getExtent

        public Collection getExtent​(Class persistenceCapableClass,
                                    boolean subclasses)
        The PersistenceManager may manage a collection of instances in the data store based on the class of the instances. This method returns a Collection of instances in the data store that might be iterated or given to a Query as the Collection of candidate instances.
        Specified by:
        getExtent in interface PersistenceManager
        Parameters:
        persistenceCapableClass - Class of instances
        subclasses - whether to include instances of subclasses
        Returns:
        a Collection of instances
        See Also:
        Query
      • getObjectById

        public Object getObjectById​(Object oid)
        This method locates a persistent instance in the cache of instances managed by this PersistenceManager. If an instance with the same ObjectId is found it is returned. Otherwise, a new instance is created and associated with the ObjectId.

        If the instance does not exist in the data store, then this method will not fail. However, a request to access fields of the instance will throw an exception.

        Specified by:
        getObjectById in interface PersistenceManager
        Parameters:
        oid - an ObjectId
        Returns:
        the PersistenceCapable instance with the specified ObjectId
      • getObjectById

        public Object getObjectById​(Object oid,
                                    boolean validate)
        This method locates a persistent instance in the cache of instances managed by this PersistenceManager. The getObjectById method attempts to find an instance in the cache with the specified JDO identity. The oid parameter object might have been returned by an earlier call to getObjectId or might have been constructed by the application.

        If the PersistenceManager is unable to resolve the oid parameter to an ObjectId instance, then it throws a JDOUserException.

        If the validate flag is false, and there is already an instance in the cache with the same JDO identity as the oid parameter, then this method returns it. There is no change made to the state of the returned instance.

        If there is not an instance already in the cache with the same JDO identity as the oid parameter, then this method creates an instance with the specified JDO identity and returns it. If there is no transaction in progress, the returned instance will be hollow or persistent-nontransactional, at the choice of the implementation.

        If there is a transaction in progress, the returned instance will be hollow, persistent-nontransactional, or persistent-clean, at the choice of the implementation.

        Specified by:
        getObjectById in interface PersistenceManager
        Parameters:
        oid - an ObjectId
        validate - if the existence of the instance is to be validated
        Returns:
        the PersistenceCapable instance with the specified ObjectId
        See Also:
        getObjectId(Object pc)
      • getObjectId

        public Object getObjectId​(Object pc)
        The ObjectId returned by this method represents the JDO identity of the instance. The ObjectId is a copy (clone) of the internal state of the instance, and changing it does not affect the JDO identity of the instance.
        Specified by:
        getObjectId in interface PersistenceManager
        Parameters:
        pc - the PersistenceCapable instance
        Returns:
        the ObjectId of the instance
      • getTransactionalInstance

        public Object getTransactionalInstance​(Object pc)
        This method is used to get a PersistenceCapable instance representing the same data store object as the parameter, that is valid for this PersistenceManager.
        Specified by:
        getTransactionalInstance in interface PersistenceManager
        Parameters:
        pc - a PersistenceCapable instance
        Returns:
        the PersistenceCapable instance representing the same data store object
      • makePersistent

        public void makePersistent​(Object pc)
        Make the transient instance persistent in this PersistenceManager. This method must be called in an active transaction. The PersistenceManager assigns an ObjectId to the instance and transitions it to persistent-new. The instance will be managed in the Extent associated with its Class. The instance will be put into the data store at commit.
        Specified by:
        makePersistent in interface PersistenceManager
        Parameters:
        pc - a transient instance of a Class that implements PersistenceCapable
      • deletePersistent

        public void deletePersistent​(Object pc)
        Delete the persistent instance from the data store. This method must be called in an active transaction. The data store object will be removed at commit. Unlike makePersistent, which makes the closure of the instance persistent, the closure of the instance is not deleted from the data store. This method has no effect if the instance is already deleted in the current transaction. This method throws an exception if the instance is transient or is managed by another PersistenceManager.
        Specified by:
        deletePersistent in interface PersistenceManager
        Parameters:
        pc - a persistent instance
      • getPersistenceManagerFactory

        public PersistenceManagerFactory getPersistenceManagerFactory()
        This method returns the PersistenceManagerFactory used to create this PersistenceManager. It returns null if this instance was created via a constructor.
        Specified by:
        getPersistenceManagerFactory in interface PersistenceManager
        Returns:
        the PersistenceManagerFactory that created this PersistenceManager
      • setUserObject

        public void setUserObject​(Object o)
        The application can manage the PersistenceManager instances more easily by having an application object associated with each PersistenceManager instance.
        Specified by:
        setUserObject in interface PersistenceManager
        Parameters:
        o - the user instance to be remembered by the PersistenceManager
        See Also:
        getUserObject()
      • getUserObject

        public Object getUserObject()
        The application can manage the PersistenceManager instances more easily by having an application object associated with each PersistenceManager instance.
        Specified by:
        getUserObject in interface PersistenceManager
        Returns:
        the user object associated with this PersistenceManager
        See Also:
        setUserObject(java.lang.Object)
      • getProperties

        public Properties getProperties()
        The JDO vendor might store certain non-operational properties and make those properties available to applications (for troubleshooting).

        Standard properties include:

      • VendorName
      • VersionNumber
Specified by:
getProperties in interface PersistenceManager
Returns:
the Properties of this PersistenceManager