Confusion about writable to-many relationships

From: Scott Ellsworth (scot..lodar.com)
Date: Thu Jan 29 2004 - 19:46:45 EST

  • Next message: Andrus Adamchik: "Re: New objects break FK constraints"

    Hi, all.

    I have a PlayerDBEntity, a SystemDbEntity, and a
    PlayerSystemLinkDbEntity, with toMany relationships going from the Link
    to the Player and System.

    I have a PlayerObjEntity and a SystemObjEntity. They each have toMany
    relationships that use flattening, such as linkPlayers.players.

    When I tried to add a Player to a System using

    StarSystem system = systems[i];
    system.addToPlayers(players[thisPlayer++]);

    I got the error

    Exception in thread "main"
    org.objectstyle.cayenne.CayenneRuntimeException: [v.1.0.6 January 26
    2004] Cannot modify (add to) the read-only relationship players
            at
    org.objectstyle.cayenne.CayenneDataObject.addToManyTarget(CayenneDataObj
    ect.java:298)
            at
    com.alodar.starmap.persist.StarSystem.addToPlayers(StarSystem.java:81)
            at
    com.alodar.starmap.DatabasePopulator.addPlayersToSytem(DatabasePopulator
    .java:176)
            at
    com.alodar.starmap.DatabasePopulator.populateByNumber(DatabasePopulator.
    java:76)
            at com.alodar.starmap.DatabasePopulator.main(DatabasePopulator.java:42)

    The systems and the players are recently created, so this is not a
    prefetch issue like my previous ones.

    I note in the docs that many-many is supposed to work, so I suspect
    that something about my data model makes it not fit the many-many
    requirement. If it would help, I will send the data model about, as it
    is only 2k zipped.

    Scott



    This archive was generated by hypermail 2.0.0 : Thu Jan 29 2004 - 19:46:48 EST