Changes to flattened relationships not getting persisted

From: David Benoff (dbenof..ovad.net)
Date: Sun Jun 22 2003 - 20:38:54 EDT

  • Next message: Scott Finnerty: "RE: Changes to flattened relationships not getting persisted"

    I’m having trouble with a flattened relationship in Cayenne. I’ve
    flattened an object relationship as outlined in the user guide, but
    updates are not getting saved to disk. I’ve been able to
    create/update/delete other types of objects, but not n:m relationships.
    Within the session, the association is created, but doesn’t get saved to
    disk. SQL logging shows no INSERT statements getting generated. I get
    no exceptions from Cayenne. Here’s the code:
     
            Expression teamqual = ExpressionFactory.matchExp("teamname",
    teamname);
            SelectQuery teamsquery = new SelectQuery(Teams.class, teamqual);
            List teams = ctxt.performQuery(teamsquery);
     
            Expression userqual = ExpressionFactory.matchExp("username",
    username);
            SelectQuery usersquery = new SelectQuery(Users.class, userqual);
            List users = ctxt.performQuery(usersquery);
            Teams myteam = (Teams)teams.get(0);
            Users myuser = (Users)users.get(0);
            List myteamlist = myteam.getTeamsTOusers();
               if(!myteamlist.contains(myuser)){
                   myteamlist.add(myuser);
                   System.out.println("adding user");
                   ctxt.commitChanges();
               }
     
     
    The user guide says commitChanges() is the only method I need to call to
    persist the association, so I’m a bit puzzled.
    I’m guessing I’ve also got to use registerFlattenedRelationshipInsert(),
    but the API isn’t much help and I can’t seem to feed it the right
    arguments.

    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.488 / Virus Database: 287 - Release Date: 6/5/2003
     
    



    This archive was generated by hypermail 2.0.0 : Sun Jun 22 2003 - 20:35:21 EDT