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

From: Bill Fan (bil..anscom.com.au)
Date: Wed Oct 15 2003 - 06:10:54 EDT

  • Next message: Laszlo Spoor: "RE: [question]: Auto PK Generation and Still have the PK available in ObjectMode"

    Hi,

    I used something like the following to get the Issue Id from the issue
    object in a jsp page.

    <%=issue.getObjectId().getIdSnapshot().get("IssueId")%>

    Hope it helps ;-)

    Bill

    -----Original Message-----
    From: Laszlo Spoor [mailto:lspoor_cayenn..otmail.com]
    Sent: Wednesday, October 15, 2003 5:11 PM
    To: cayenne-use..bjectstyle.org
    Subject: [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 - 06:11:00 EDT