RE: column name twice error

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Mon Apr 14 2003 - 18:34:31 EDT

  • Next message: Scott Finnerty: "RE: column name twice error"

    Well, what I was trying to say in my earlier message, is that having a
    meaningful primary key shouldn't be a problem. Though it should be avoided
    in most cases, this should work, and no workarounds should be required.

    Having the same column twice in the INSERT is an indication of a bug in
    Alpha 6. But considering that...

      - Beta 1 is planned to be out in a week, and
      - I can not reproduce this bug under current development code (I have a
    few unit tests having meaningful primary keys - all pass just fine)

    .... I urge everybody having this problem to upgrade to the latest nightly
    build:

       http://objectstyle.org/downloads/cayenne/nightly/?M=D

    If the upgrade does not work, we will treat it as a bug and work on fixing
    it.

    Andrus

    > 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:34:32 EDT