Deleting new objects leaves null object in context.
---------------------------------------------------

         Key: CAY-547
         URL: http://issues.apache.org/cayenne/browse/CAY-547
     Project: Cayenne
        Type: Bug

  Components: Cayenne Core Library  
    Versions: 1.2 [BETA]    
 Environment: Cayenne 3t.
    Reporter: Marcin Skladaniec
    Priority: Minor


to reproduce this bug:

Persistent someObject = (Persistent) context.newObject(someClass);
context.deleteObject(someObject);
Collection collection = context.uncommittedObjects();

collection will contain a null object.

The reason of that is that there are two references to (persistent) objects in 
context kept at all times. One is in GraphMap, and second is in GraphMap 
subclass CayenneContextGraphManager in stateLog field. 
I have not found that GraphMap is used to keep reference to all 
PersistentObjects in context as a whole objects. 
CayenneContextGraphManager is used rather for keeping atomic changes, and later 
for sending only those to the server. From what I found it looks like there is 
no mechanism for removing those atomic changes from stateLog. It is very 
simple, when object is created/modified/deleted it has to affect the database, 
so after any operation objectId is added to dirtyNodes.  But there is one case 
when this behaviour is not right, that is when reverting some changes, like 
deleting a new object.



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/cayenne/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to