[question]: Auto PK Generation and Still have the PK available in ObjectModel

From: Laszlo Spoor (lspoor_cayenn..otmail.com)
Date: Wed Oct 15 2003 - 03:11:00 EDT

  • Next message: Bill Fan: "RE: [question]: Auto PK Generation and Still have the PK available in ObjectModel"

    Cayenne 1.0.1
    MySQL 4.0.4

    Hi All,

    When you want to use automatic PK generation, one should make the mark the
    primary key of the DatabaseObject as PK and make it mandatory in the
    modeler. Also the primary key should not be mapped in the ObjectEntity. To
    retrieve the primary key of this object, one should use a construction like:

        ObjectId oi = myObject.getObjectId();
        String primaryKey = oi.getValueForAttribute("id");

    However, this is not very handy in web applications (e.g. struts/cayenne),
    because this construction requires that I place java code in my Java
    ServerPage.

    Is is possible that I can query my object (myObject.getId()) and still have
    automatic primary key generation?

    Thanks in advance, Laszlo Spoor

    _________________________________________________________________
    STOP MORE SPAM with the new MSN 8 and get 2 months FREE*
    http://join.msn.com/?page=features/junkmail



    This archive was generated by hypermail 2.0.0 : Wed Oct 15 2003 - 03:11:02 EDT