cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marcin Skladaniec (JIRA)" <>
Subject [jira] Commented: (CAY-1183) commitToParent() makes object persistence state committed, produces exception when using object in parent context (ROP)
Date Tue, 24 Feb 2009 02:55:45 GMT


Marcin Skladaniec commented on CAY-1183:

I dug around for some answers, and I found that the COMMITTED status is intended after committing
changes to the parent context. This is an excerpt from the test case code:


// * all modified child objects must be in committed state now
// * all modifications should be propagated to the parent
// * no actual commit should occur.

            assertEquals(PersistenceState.COMMITTED, childNew.getPersistenceState());
            assertEquals(PersistenceState.COMMITTED, childModified.getPersistenceState());
            assertEquals(PersistenceState.COMMITTED, childCommitted.getPersistenceState());
            assertEquals(PersistenceState.HOLLOW, childHollow.getPersistenceState());

interestingly all the tests are wrapped in something called "blockQueries", which might be
why the test cases work, while the real life application throws exception on accessing/creating/executing

> commitToParent() makes object persistence state committed, produces exception when using
object in parent context (ROP)
> -----------------------------------------------------------------------------------------------------------------------
>                 Key: CAY-1183
>                 URL:
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Cayenne Core Library
>    Affects Versions: 3.0M5
>         Environment: ROP (maybe also 2t cayenne, I have not tried)
>            Reporter: Marcin Skladaniec
>            Assignee: Andrey Razumovsky
>            Priority: Critical
> This is a bit of pseudocode showing the problem
> Artist artist = parentContext.perfrormQuery(new SelectQuery(Artist.class)).get(0);
> CayenneContext childContext = parentContext.createChildContext();
> Painting painting = childContext.newObject(Painting.class);
> painting.setArtist(artist);
> painting.setBlah...
> childContext.commitToParent();
> for(Painting p : artist.getPaintings()) 
> logger.debug("painting persistence state : "+PersistenceState.persistenceStateName(p.getPersistenceState()));
//all objects are in state COMMITTED
> this causes no problems so far, but if one now decides to 
> p.getSomeRelatiohship();
> an exception will be raised, because the relationship has not been faulted yet:
>  [java] Caused by: java.lang.Exception: [v.3.0-SNAPSHOT ${} ${}]
Can't build a query for relationship 'someRelationship' for temporary id: <ObjectId:Painting,
>      [java] 	at org.apache.cayenne.remote.service.BaseRemoteService.processMessage(
>   ... 25 more

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message