localObject and new objects
---------------------------

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

  Components: Cayenne Core Library  
    Versions: 1.2 [STABLE], 3.0    
 Environment: any
    Reporter: Marcin Skladaniec


This test:

                        CayenneContext context2 = new CayenneContext(channel, 
true, true);
                        CRoom localRoom = 
(CRoom)context2.newObject(CRoom.class);
                        CayenneContext context1 = new CayenneContext(channel, 
true, true);
                        
                        CRoom room = (CRoom)context1.newObject(CRoom.class);
                        context1.commitChanges();
                        
                        logger.warn("before :");
                        logger.warn("\t room " +room);
                        logger.warn("\t localRoom " +localRoom);
                        localRoom = (CRoom) 
context2.localObject(room.getObjectId(), room);
                        logger.warn("after :");
                        logger.warn("\t room " +room);
                        logger.warn("\t localRoom " +localRoom);

gives unexpected results :

before :
        room <[EMAIL PROTECTED], id=<ObjectId:Room, id=461>, state=committed, 
[EMAIL PROTECTED]>
        localRoom <[EMAIL PROTECTED], id=<ObjectId:Room, 
TEMP:000000A541400003>, state=new, [EMAIL PROTECTED]>
after :
        room <[EMAIL PROTECTED], id=<ObjectId:Room, id=461>, state=committed, 
[EMAIL PROTECTED]>
        localRoom <[EMAIL PROTECTED], id=<ObjectId:Room, id=461>, state=new, 
[EMAIL PROTECTED]>

as you can see, after localObject the PersistentState.COMMITED object gets 
PersistentState.NEW state! (while still keeping the right permanent PK)

whether prototype in localObject is set or not, it does not matter.

-- 
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