Help with PK field accessible by web app

From: Michael Amster (mamste..ebeasy.com)
Date: Mon May 26 2003 - 20:51:52 EDT

  • Next message: Andrus Adamchik: "Re: Help with PK field accessible by web app"

    Hi:

    I am relatively new to Cayenne. I have read the archives concerning PKs
    and how to use them in the framework. I am in the position of having a
    simple object with String fields name, gender. Neither of these are
    unique but together they are. I wanted to leverage the AUTO_PK support
    in the framework by defining a DBEntity with an integer PK field (in
    mysql) and be able to reference this field from the ObjectEntity without
    losing the autogenerate funcitonality.

    This case comes up when I create links with edit?id=something unique in
    Struts/Jsp pages. I know I could put in something like
    edit?name=name&gender=gender to create a unique identifier, but I wanted
    to leverage what was there.

    I would love to have some type of ObjectId that I could print to string
    and then from a string do a

    Category = ctxt.loadObjectById(Category.class, objectIdString);

    Are there any hints how to achieve what I want without losing the
    autogenerate PK? I would be willing to add another column, but I did
    not want to worry about generating values for this myself. I like the
    abstraction of just worrying about the objects and not the underlying db
    with this one exception.

    Maybe I should change the way I think about writing this type of
    Add/Edit/Delete stuff for Cayenne.

    -MA



    This archive was generated by hypermail 2.0.0 : Mon May 26 2003 - 20:54:54 EDT