Re: Error generating PK for entity 'DbEntity:

From: Mike Kienenberger (mkienen..laska.net)
Date: Fri Oct 24 2003 - 09:56:42 EDT

  • Next message: Rob Witt: "how-to map reflexive relationships?"

    Andrus Adamchik <andru..bjectstyle.org> wrote:
    > > Caused by: java.sql.SQLException: ERROR - Value can not be NULL for
    column 'NEXT_ID'
    > > SQL: UPDATE AUTO_PK_SUPPORT SET NEXT_ID = NEXT_ID + 20 WHERE
    >
    > Hmm... This looks just like what it says - somehow OpenBase thinks that
    > NEXT_ID is NULL. Is it possible that there is more than one row for
    > 'LOG'?

    I'm not entirely certain what you mean by this. If you're asking if
    multiple log rows get inserted in a single transaction, the answer is yes.
    If you're asking if there are multiple LOG rows in the AUTO_PK_SUPPORT
    table, the answer is no.

    > Another problem with generic JdbcAdapter is a race condition,
    > since "SELECT.." and "UPDATE..." are not executed as a single atomic
    > operation. I don't think this applies in your case though.

    No, probably not. Log is an append-only table that only gets INSERT
    operations.
    I suppose it could apply to the AUTO_PK_SUPPORT table. But I still don't
    see where it'd come up with NULL rather than coming up with duplicate
    primary key values.

    > I tried running Cayenne tests on my Mac OS X OpenBase installation,
    > trying to reproduce this problem. But I did not get too far, since
    > JdbcAdapter doesn't have proper metadata mapping to generate the test
    > schema... Looks like we need a new adapter.

    I can probably help with creating a new adaptor. I was trying to avoid
    doing any serious OpenBase support since this project has to eventually
    deploy on Oracle. My primary OpenBase deployment project is using
    WebObjects and probably will continue to do so for the forseeable future.
    I was only using OpenBase for development on this project because it was
    installed and convenient.

    > So I guess you may debug this a bit more, adding logging to
    > JdbcPkGenerator.PkRetrieveProcessor that serves as an observer for PK
    > queries. At least you will know if the null was indeed returned from
    > the DB before the update.

    Yeah, that definitely gives me someplace to start at. I haven't found an
    easy way to reproduce the problem yet either, so I thought I'd ask in case
    it was something more obvious, or in case it indicated a more widespread
    problem.

    > Sorry, this wasn't too helpful..

    Actually it was to the extent that it sounds like it's probably a
    JdbcAdapter issue, and it gave me a place to investigate further.

    Thanks!

    -Mike



    This archive was generated by hypermail 2.0.0 : Fri Oct 24 2003 - 09:55:48 EDT