RE: column name twice error

From: John Poole (john..IXXURESCANADA.com)
Date: Mon Apr 14 2003 - 17:59:11 EDT

  • Next message: Andrus Adamchik: "RE: column name twice error"

    I think I can work around the bug by changing the autogenerated setting
    in mysql or something.
            But as to how it should be done: Is the objectid going to be of
    any use as a reference if I access the database with another
    application? I'm using one machine and (therefore a separate vm) to
    update the database and another to run a tomcat app. I'm also submitting
    data to another website and getting confirmation on a different
    connection. My plan is to use the primary key as the identifier for
    which transaction is being confirmed.

    John

             

    -----Original Message-----
    From: Scott Finnerty [mailto:scot..odefuey.com]
    Sent: April 14, 2003 3:08 PM
    To: cayenne-use..bjectstyle.org
    Subject: Re: column name twice error

    I thought someone pointed the cause out on the list previously, but the
    problem is with using a PK as an object attribute where the PK is also
    auto-generated. The insert builder doesn't recognize the overlap
    (obviously) and puts the column in twice - once for the auto-generated
    PK
    and once for the object attribute.

    The bit in the user guide about meaningful primary keys, etc. hints at
    the issue - if you have a PK that you want to expose as an object
    attribute, e.g., an SSN or the like - its likely not auto-generated and
    specific to the DB. If it is auto-generated and specific to the DB then

    the philosophy is that it doesn't belong in the object model.

    I struggled with this, particularly in a web application context where
    you
    need a unique identifier for an object from request to request and not
    all
    database entities have alternate keys that can be used for this purpose.

    There have been messages on the list talking about using the ObjectId
    instead of exposing the PK as an object attribute. This is pretty tight
    coupling with an ObjectId and the docs warn against this. It works
    though
    and with minimal work you can isolate the tight coupling to a helper
    class.

    Scott

    > John,
    >
    > Similar problem was reported here:
    >
    >
    > http://sourceforge.net/tracker/
    > index.php?func=detail&aid=709799&group_id=48132&atid=452068
    >
    > I could never reproduce this myself, but then insert statement
    > generation has changed significantly since alpha 6. Does it also bomb
    > when upgrading Cayenne to the latest nightly build?
    >
    > Andrus
    >
    > On Monday, April 7, 2003, at 11:00 AM, John Poole wrote:
    >> v1.0a6
    >> Cayenne is generating a statement which names the same column twice.
    >> i.e. INSERT INTO aTable (id, userid, id) values (?, ?, ?)
    params[null,
    >> 100, null];
    >>
    >> I have a table in mySQL that has an auto-generated primary key
    column,
    >> which I need to use as a reference to another website. I've created
    an
    >> object attribute for the "id" column, this seems to adding a second
    >> "id"
    >> to the insert statement. I've done this before with other tables, and
    >> I can't see anything in the datamap that looks "wrong".
    >>
    >> Is there a "better" way to get a unique key for a row?
    >>
    >> John



    This archive was generated by hypermail 2.0.0 : Mon Apr 14 2003 - 18:04:33 EDT