RE: Retrieving via auto-generated keys

From: Gentry, Michael (michael_gentr..anniemae.com)
Date: Fri May 28 2004 - 10:13:52 EDT

  • Next message: Andrus Adamchik: "Re: DeleteObject will not work"

    If security is an issue at all here, I wouldn't use the primary keys
    encoded in the HTML. All it would take is someone running OmniWeb on OS
    X (like me) to break your security (and there maybe be ways in other
    browsers, too) and view records you didn't intend.

    /dev/mrg

    -----Original Message-----
    From: Mike Elliott [mailto:mr..79.net]
    Sent: Friday, May 28, 2004 7:46 AM
    To: cayenne-use..bjectstyle.org
    Subject: Retrieving via auto-generated keys

    I have a situation where I'm writing a web application. On some pages I
    need
    to display, in a dropdown list, a subset of my users (around 750 total
    users). That is, I need to generate something along the line of:

    <select name="selectedUser">
      <option value="157">Biff Overbyte</option>
      <option value="189">Steve Whotsit</option>
      . . .
    </select>

    What I'm talking about here is specifying as the 'value' attribute, the
    generated integer primary key for the user, as a way of getting to the
    full user record in the database. I can fetch this value from each user

    instance by using the getObjectId() method, and properly generate the
    "value=" portion of the option.

    The problem I have is what should I do in order to fetch the full
    record?
    Basically, how do I go about fetching a row from the database where I
    know
    the Cayenne-generated key value? I don't have a get() method for it (at

    least directly) and it's unclear to me how to builld a query to access a

    CayenneDataObject via its internally generated primary key.

    The overall problem I want to solve is how to display a subset of user
    names
    from my user table as a dropdown list, then be able to fetch the
    corresponding full User object via Cayenne. Maybe I'm going about this
    completely wrong. If so, if anyone else has solved this problem, please
    let
    me know.



    This archive was generated by hypermail 2.0.0 : Fri May 28 2004 - 10:13:59 EDT