how to store/save not PKs in the join-tables instead of storing the id's

From: Zvonimir Spajic (z.spaji..scensys.de)
Date: Wed Feb 09 2005 - 20:22:56 EST

  • Next message: Pirola Davide: "RE: Cache with StoredProcedure cursor parameter"

    Hello,

    after 5 hours trying I don't see any chance to solve my problem by lucky
    testing.
    I want to use Tomcats JDBC Realm. For this Login-Mechanism it's necessary
    to have specific table-names and table-columns and to define them in the
    server.xml:

    for example:
           <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
                  driverName="org.gjt.mm.mysql.Driver"
               connectionURL="jdbc:mysql://localhost/myDatabase"
              connectionName="My DB Connection" connectionPassword="myPassword"
                   userTable="user" userNameCol="username"
    userCredCol="password"
               userRoleTable="join_user_role" roleNameCol="rolename" />

    I want to use this with cayenne. A user can have many roles. A role can
    belong to many users.
    Because of this I use a Join Table (join_user_role).

    If I do it this way...
            The column "username" is not the PK in the table user. The PK column in
    the table user is "id" (auto_pk_supported).
            The column "rolename" is not the PK in the table role. The PK column in
    the table role is "id" (auto_pk_supported).
            The 3 columns in the join table join_user_role are:
            1)id (auto_pk_supported)
            2)user_id
            3)role_id

            The relationships are:
            user.id <--> join_user_role.user_id
            role.id <--> join_user_role.role_id

    .. then cayenne works fine.

    But if I want to store the username and rolename in the join-table
    join_user_role, like that way
            The relationships are:
            user.username <--> join_user_role.user_name
            role.rolename <--> join_user_role.role_name

    then cayenne gives me an error:
            org.objectstyle.cayenne.CayenneRuntimeException: [v.1.1RC1 October 3
    2004] Cannot set the read-only flattened relationship hasRoles
            ERROR RegistrationAction: Registration failed!

    How I can store/save the username and rolename in the join-table instead
    of storing the id's. I need this for the JDBCRealm.

    Please help me.

    Greetings Zvonimir



    This archive was generated by hypermail 2.0.0 : Wed Feb 09 2005 - 20:23:01 EST