Thx for your answer. To clarify these points:

1- The transaction is really a JDO/datastore exception encapsulated by
Spring (as I am using the transactional components of Spring). To be
sure, I tried to execute these tests with manual transactions instead
of not Spring and the result was the same (except that it was not a
Spring exception but the message was the same).

3- You're right my comment is a bit imprecise:

Sorry for the confusions or imprecisions :D. My problem is when I load
an object A which contains a list of B. Although one B was added to A,
it does not get loaded when I load A. But it is in the object returned
by makePersistent within my DAO:

    public final void testBug3() throws DaoException {
        ...
        // Here I add B to A
        a.addB(b);
        //
        A a2 = _aDao.update(a);
        a = _aDao.loadByKey(a.getKey());
        ...
        // Returns an empty list if I use object "a" but contains one
element if I use a2 instead.
        a.getBList()....
    }

In my DAO (which is not in my previous post, only in my Zip), I set
the fetchDepth to 3 and used defaultFetchGroup to force loading (I
also tried -1). But usually errors returned by JDO in that case are of
the kind "object not detached" and the list still contain the correct
number of elements even if they are not loaded.

However I have just realized that I am getting the persistence manager
through the PersistenceManagerFactoryUtils of Spring several times
(once in getPersistenceManager() and once in getFetchPlan() in my
DAO). Although I think it gives the persistence manager for the
current thread, I should make it sure. I'll give it a try this
evening.



Here is an extract of my DAO:
public class ADao implements IADao
{
    ...
    public final PersistenceManager getPersistenceManager() {
        return PersistenceManagerFactoryUtils.getPersistenceManager
(_persistenceManagerFactory, true);
    }

    public final FetchPlan getFetchPlan() {
        return PersistenceManagerFactoryUtils.getPersistenceManager
(_persistenceManagerFactory, true).getFetchPlan();
    }

    ...

    public final A loadByKey(Key pKey) throws DaoException {
        PersistenceManager lPersistenceManager = getPersistenceManager
();
        try {
            getFetchPlan().setMaxFetchDepth(3);
            A lAggregate = lPersistenceManager.getObjectById(A.class,
pKey);
            return lPersistenceManager.detachCopy(lAggregate);
        }
        catch (JDOObjectNotFoundException eJDOObjectNotFoundException)
        {
            return null;
        }
        catch (Exception eException)
        {
            throw new DaoException(eException);
        }
    }

    @Transactional(readOnly = false, propagation =
Propagation.REQUIRES_NEW)
    public final A update(A pA) throws DaoException {
        PersistenceManager lPersistenceManager = getPersistenceManager
();

        try {
            A lUpdatedAggregate = lPersistenceManager.makePersistent
(pA);
            return lUpdatedAggregate;
        }
        catch (Exception eException)
        {
            throw new DaoException(eException);
        }
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    public A loadByEmail(String email) throws DaoException {
        Query lQuery = getPersistenceManager().newQuery(A.class);
        lQuery.setFilter("_email == emailParam");
        lQuery.declareParameters("String emailParam");
        lQuery.setUnique(true);

        getFetchPlan().setMaxFetchDepth(3);

        return executeUniqueQuery(lQuery, email);
    }
}


On 9 déc, 11:54, datanucleus <[email protected]> wrote:
> 1. Any exception from Spring is of use to one group of people only ...
> Spring. I'd guess it has a nested exception, so that would provide
> more basis for comment.
>
> 3. Perhaps you could define what "my childs are never loaded" means,
> cos I don't see a field called that. JDO loads as per the FetchPlan,
> and the maxFetchDepth of that. Don't set them and you get depth of 1
> only, as per the JDO spec.

--

You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.


Reply via email to