Retrieving via auto-generated keys

From: Mike Elliott (mr..79.net)
Date: Fri May 28 2004 - 07:46:02 EDT

  • Next message: Michael Schuldt: "DeleteObject will not work"

    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 - 03:46:03 EDT