RE: [JIRA] Created: (CAY-538) Relationship not refreshed before committing the context.

From: Gentry, Michael \(Contractor\) ("Gentry,)
Date: Tue May 02 2006 - 09:21:52 EDT

  • Next message: Philip Copeland (JIRA): "[JIRA] Created: (CAY-539) Auto PK Support does does not support DB Schema names"

    Marcin,

    I'm not certain this is a Cayenne bug. I think it is more of a
    misunderstanding. When you do:

                    logger.info("(here relationship is modified)");
                    temproom.setSite(tempsite2);

    You point the room's site to site2, but you never unlinked the
    relationship from site1->room. Therefore, when you then do:

                    logger.info("site 1 rooms");
                    rooms = tempsite1.getRooms();
                    for (int i=0; i<rooms.size();i++) {
                            logger.info("\troom "+i+" :
    "+((CRoom)rooms.get(i)).getName());
                    }

    tempsite1 will still print the room out because the room is still it
    site1's rooms relationship. Try:

                    logger.info("(here relationship is modified)");
                    tempsite1.removeFromRooms(temproom);
                    temproom.setSite(tempsite2);

    And see if it helps.

    /dev/mrg

    -----Original Message-----
    From: Marcin Skladaniec (JIRA) [mailto:jir..pache.org]
    Sent: Monday, May 01, 2006 9:53 PM
    To: cayenne-de..ncubator.apache.org
    Subject: [JIRA] Created: (CAY-538) Relationship not refreshed before
    committing the context.

    Relationship not refreshed before committing the context.
    ----------------------------------------------------------

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

      Components: Cayenne Core Library
        Versions: 1.2 [BETA]
     Environment: I think any platform, but tested on os x and freebsd.
    Cayenne 3t
        Reporter: Marcin Skladaniec

    I have two sites : site1 and site2 and a room linked to site1
    If I change the relationship so the room links to site2, than before I
    commit the changes both sites are linked to the room.

    The code

    {
                    Expression expression =
    ExpressionFactory.matchExp(CSite.NAME_PROPERTY, "site1");
                    SelectQuery query = new SelectQuery(CSite.class,
    expression);
                    List list = context2.performQuery(query);
                    CSite tempsite1 = (CSite)list.get(0);
                    
                    expression =
    ExpressionFactory.matchExp(CSite.NAME_PROPERTY, "site2");
                    query = new SelectQuery(CSite.class, expression);
                    list = context2.performQuery(query);
                    CSite tempsite2 = (CSite)list.get(0);
                    
                    
                    expression =
    ExpressionFactory.matchExp(CRoom.NAME_PROPERTY, "room");
                    query = new SelectQuery(CRoom.class, expression);
                    list = context2.performQuery(query);
                    CRoom temproom = (CRoom)list.get(0);
                    
                    
                    logger.info("site 1 rooms");
                    List rooms = tempsite1.getRooms();
                    for (int i=0; i<rooms.size();i++) {
                            logger.info("\troom "+i+" :
    "+((CRoom)rooms.get(i)).getName());
                    }
                    
                    logger.info("site 2 rooms");
                    rooms = tempsite2.getRooms();
                    for (int i=0; i<rooms.size();i++) {
                            logger.info("\troom "+i+" :
    "+((CRoom)rooms.get(i)).getName());
                    }
                    logger.info("(here relationship is modified)");
                    temproom.setSite(tempsite2);
                    
                    logger.info("site 1 rooms");
                    rooms = tempsite1.getRooms();
                    for (int i=0; i<rooms.size();i++) {
                            logger.info("\troom "+i+" :
    "+((CRoom)rooms.get(i)).getName());
                    }
                    
                    logger.info("site 2 rooms");
                    rooms = tempsite2.getRooms();
                    for (int i=0; i<rooms.size();i++) {
                            logger.info("\troom "+i+" :
    "+((CRoom)rooms.get(i)).getName());
                    }
    }

    produces output :
    site 1 rooms
            room 0 : room
    site 2 rooms
    (here relationship is modified)
    site 1 rooms
            room 0 : room
    site 2 rooms
            room 0 : room

    I can publish a small project reproducing this bug.

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



    This archive was generated by hypermail 2.0.0 : Tue May 02 2006 - 09:22:23 EDT