Flattened relationships : plz help!

From: bdt (bdtya..ahoo.fr)
Date: Wed Mar 19 2008 - 12:57:42 EDT

  • Next message: Michael Gentry: "Re: Google Summer of Code 2008"

    Hello,
    I'm new to Cayenne and i'm trying to use flattened relationship.
    I have 3 oracle tables :
    PLAYER : PLAYER_ID, PLAYER_NAME
    TOURNAMENT : TOUR_ID, TOUR_NAME
    PARTICIPATE : TOUR_ID, PLAYER_ID

    the PARTICIPATE table is used for the flattened relationship between PLAYER
    and TOURNAMENT.
    I have 2 problems :
    1) I can't create a player, a tournament and the relation at the same time
    like this :

    Player p = (Player) context.newObject(Player.class);
    p.setName("Federer");
    Tournament p = (Tournament) context.newObject(Tournament.class);
    t.setName("Us Open");
    p.addToTournament(t); // the relation
    context.commitChanges();
    I have to commit changes before creating the relation so that it works, why
    ?

    2) Later i want to delete a tournament, but i have a error message :

    INFO QueryLogger: DELETE FROM PARTICIPATE WHERE
    INFO QueryLogger: *** error.
    java.sql.SQLException: ORA-00936: missing expression
            at
    oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    ...

    The code is :
    Tournament t = (Tournament ) DataObjectUtils.objectForPK(context, Tournament
    .class,tour_id);
    //context.deleteObject(t); ==> don't work Oracle foreign key error
    List plist = t.getPlayers();
    for (int i=0;i<plist.size();i++){
            t.removeFromPlayers((Player)plist .get(i)); //==> error message
    }
    context.deleteObject(t);
    context.commitChanges();

    Thank you for you help

    -- 
    View this message in context: http://www.nabble.com/Flattened-relationships-%3A-plz-help%21-tp16146653p16146653.html
    Sent from the Cayenne - User mailing list archive at Nabble.com.
    



    This archive was generated by hypermail 2.0.0 : Wed Mar 19 2008 - 12:58:16 EDT