RE: Changes to flattened relationships not getting persisted

From: Scott Finnerty (scot..odefuey.com)
Date: Sun Jun 22 2003 - 22:08:09 EDT

  • Next message: Heiko Wenzel: "Firebird Adaptor"

    Did you mark one of ObjEntities in this relationship as read-only in the
    Modeller? I think I had a similar problem and had to uncheck the
    read-only setting. I traced the problem in the cayenne code, but didn't
    (and don't) have time to work out the solution. Of course that was
    weeks (and betas) ago. You could be experiencing something completely
    different.
     
    Scott Finnerty
     
    -----Original Message-----
    From: David Benoff [mailto:dbenof..ovad.net]
    Sent: Sunday, June 22, 2003 7:39 PM
    To: cayenne-use..bjectstyle.org
    Subject: 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 - 22:06:24 EDT