SQLException in M to M relation

From: Dhruti Ramani (dhrutiraman..ahoo.com)
Date: Fri Jul 22 2005 - 09:44:46 EDT

  • Next message: Kevin Menard: "Re: M5 is out"

    Hi,
     
    I am using cayenne1.1 and postgresql7 as databse.
    I have M to M relation between SystemUser and UserRole objects, join table is called UserRole_SystemUser.
     
    Now if I add some SystemUser to UserRole I dont have any problems but when I try to delete the user from UserRole and if i say commitChanges() it throws following exception,
     
    INFO QUERYLOGGER : DELETE FROM UserRole_SystemUser WHERE
    INFO QUERYLOGGER : *** error.
    java.sql.SQLException: ERROR: parse: parse error at end of input

     
    ------------------------------
    I did this remation according to following explaination by Todd O'Brayan.
     
    I'm going to call your two tables role and user and their associated
    classes Role and User. Assume both tables have an id column that
    Cayenne handles for you automatically.

    1. Create a new dbEntity. I usually call mine "userToRole", but you
    can choose anything that indicates it's a join table.
    2. Include two attributes: "roleId" and "userId", both of type
    Integer. That's all.
    3. Create two relationships. I would call them "toRole" and "toUser".
    Target should be "role" and "user", respectively, and source and
    target in the relationships should be "roleId", "id" and "userId",
    "id", respectively. I call the reverse relationships "toUserToRole".

    You now have relationships from each dbEntity to the join table, and
    from the join table to each dbEntity. All you have to do is teach
    Cayenne to follow those relationships and you're set.

    4. Select the Role objEntity and sync it with the dbEntity. You have
    to add an extra relationship to Role that combines the two partial
    relationships. I'd call it "users". Choose "User" as the target.
    5. When you click the Info button to specify the relationship, you'll
    need to select a DbRelatioship. Choose "toUserToRole" which is a
    mapping from "role -> userToRole". When you do that, Cayenne should
    fill in the "toUser" relation from "userToRole -> user". Click done.
    6. Do the same for the User objEntity.
    7. Generate the classes again.
    ---------------------------
     
    Any sugesstions?
     
    Thanks,
    Denna

                    
    ---------------------------------
     Start your day with Yahoo! - make it your home page



    This archive was generated by hypermail 2.0.0 : Fri Jul 22 2005 - 09:44:47 EDT