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

From: Laszlo Spoor (lspoor_cayenn..otmail.com)
Date: Wed Oct 15 2003 - 08:17:46 EDT

  • Next message: Andrus Adamchik: "Re: [question]: Auto PK Generation and Still have the PK available in ObjectMode"

    Hi Bill,

    Thanks for your anwer. Yes, your proposal will work :-). However I was
    thinking more in the struts taglib method, so something like:

    <table>
      <logic:iterate id="usr" name="usrList" >
      <tr>
        <td>
          <bean:write name="usr" property="lastname"/>, <bean:write name="usr"
    property="id"/>
        </td>
      </tr>
      </logic:iterate>
    </table>

    (Don't question the relevance of this business case, it is only for
    illustration, but think more of links that will call other functions like
    edit and delete). There is no Java Code at all here.

    I will fall back to your method if there is no other way, but I would prefer
    a construction that supports the tag libs.

    Thanks again, Laszlo

    >From: "Bill Fan" <bil..anscom.com.au>
    >To: "'Laszlo Spoor'" <lspoor_cayenn..otmail.com>
    >CC: <cayenne-use..bjectstyle.org>
    >Subject: RE: [question]: Auto PK Generation and Still have the PK available
    >in ObjectModel
    >Date: Wed, 15 Oct 2003 20:10:54 +1000
    >
    >
    >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
    >
    >

    _________________________________________________________________
    Protect your PC - get McAfee.com VirusScan Online
    http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963



    This archive was generated by hypermail 2.0.0 : Wed Oct 15 2003 - 08:17:48 EDT