Search in sources :

Example 1 with FetchPlanState

use of org.datanucleus.FetchPlanState in project datanucleus-api-jdo by datanucleus.

the class JDOPersistenceManager method makeTransient.

/**
 * Method to make transient an object allowing fetching using the fetch plan.
 * @param pc The object
 * @param useFetchPlan Whether to make transient all objects in the fetch plan
 */
public void makeTransient(Object pc, boolean useFetchPlan) {
    assertIsOpen();
    FetchPlanState state = null;
    if (useFetchPlan) {
        // Create a state object to carry the processing state info
        state = new FetchPlanState();
    }
    jdoMakeTransient(pc, state);
}
Also used : FetchPlanState(org.datanucleus.FetchPlanState)

Example 2 with FetchPlanState

use of org.datanucleus.FetchPlanState in project datanucleus-api-jdo by datanucleus.

the class JDOPersistenceManager method detachCopyAll.

/**
 * Detach the specified objects from the <code>PersistenceManager</code>.
 * @param pcs the instances to detach
 * @return the detached instances
 * @see #detachCopyAll(Object[])
 */
public <T> Collection<T> detachCopyAll(Collection<T> pcs) {
    assertIsOpen();
    assertReadable("detachCopyAll");
    // Detach the objects
    FetchPlanState state = new DetachState(ec.getApiAdapter());
    List detacheds = new ArrayList();
    for (T pc : pcs) {
        if (pc == null) {
            detacheds.add(null);
        } else {
            detacheds.add(jdoDetachCopy(pc, state));
        }
    }
    return detacheds;
}
Also used : DetachState(org.datanucleus.DetachState) ArrayList(java.util.ArrayList) FetchPlanState(org.datanucleus.FetchPlanState) List(java.util.List) ArrayList(java.util.ArrayList)

Example 3 with FetchPlanState

use of org.datanucleus.FetchPlanState in project datanucleus-api-jdo by datanucleus.

the class JDOPersistenceManager method makeTransientAll.

/**
 * Method to make transient a collection of objects.
 * @param pcs The objects
 * @param useFetchPlan Whether to use the fetch plan when making transient
 * @throws JDOUserException thrown if objects could not be made transient.
 */
public void makeTransientAll(Collection pcs, boolean useFetchPlan) {
    assertIsOpen();
    ArrayList failures = new ArrayList();
    Iterator i = pcs.iterator();
    FetchPlanState state = null;
    if (useFetchPlan) {
        // Create a state object to carry the processing state info
        state = new FetchPlanState();
    }
    while (i.hasNext()) {
        try {
            jdoMakeTransient(i.next(), state);
        } catch (RuntimeException e) {
            failures.add(e);
        }
    }
    if (!failures.isEmpty()) {
        throw new JDOUserException(Localiser.msg("010041"), (Exception[]) failures.toArray(new Exception[failures.size()]));
    }
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) FetchPlanState(org.datanucleus.FetchPlanState) JDOUserException(javax.jdo.JDOUserException) JDONullIdentityException(javax.jdo.JDONullIdentityException) TransactionNotActiveException(org.datanucleus.api.jdo.exceptions.TransactionNotActiveException) JDOException(javax.jdo.JDOException) JDOUserException(javax.jdo.JDOUserException) JDOFatalUserException(javax.jdo.JDOFatalUserException) NucleusException(org.datanucleus.exceptions.NucleusException) TransactionActiveOnCloseException(org.datanucleus.exceptions.TransactionActiveOnCloseException) JDOOptimisticVerificationException(javax.jdo.JDOOptimisticVerificationException) NucleusUserException(org.datanucleus.exceptions.NucleusUserException) TransactionNotWritableException(org.datanucleus.api.jdo.exceptions.TransactionNotWritableException) JDOUnsupportedOptionException(javax.jdo.JDOUnsupportedOptionException) ClassNotResolvedException(org.datanucleus.exceptions.ClassNotResolvedException) NucleusOptimisticException(org.datanucleus.exceptions.NucleusOptimisticException)

Aggregations

FetchPlanState (org.datanucleus.FetchPlanState)3 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)1 List (java.util.List)1 JDOException (javax.jdo.JDOException)1 JDOFatalUserException (javax.jdo.JDOFatalUserException)1 JDONullIdentityException (javax.jdo.JDONullIdentityException)1 JDOOptimisticVerificationException (javax.jdo.JDOOptimisticVerificationException)1 JDOUnsupportedOptionException (javax.jdo.JDOUnsupportedOptionException)1 JDOUserException (javax.jdo.JDOUserException)1 DetachState (org.datanucleus.DetachState)1 TransactionNotActiveException (org.datanucleus.api.jdo.exceptions.TransactionNotActiveException)1 TransactionNotWritableException (org.datanucleus.api.jdo.exceptions.TransactionNotWritableException)1 ClassNotResolvedException (org.datanucleus.exceptions.ClassNotResolvedException)1 NucleusException (org.datanucleus.exceptions.NucleusException)1 NucleusOptimisticException (org.datanucleus.exceptions.NucleusOptimisticException)1 NucleusUserException (org.datanucleus.exceptions.NucleusUserException)1 TransactionActiveOnCloseException (org.datanucleus.exceptions.TransactionActiveOnCloseException)1