Re: Error generating PK for entity 'DbEntity:

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Fri Oct 24 2003 - 03:30:29 EDT

  • Next message: Andrus Adamchik: "Re: runtime error - can't find generated class"

    On Thursday, October 23, 2003, at 07:16 PM, Mike Kienenberger wrote:

    > I started to see some odd PK generation errors while doing testing of
    > my
    > struts app today:
    >
    > The root cause appears to be:
    >
    > 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
    > TABLE_NAME =
    > 'LOG'
    > at com.openbase.jdbc.s.executeUpdate(Unknown Source)
    > at
    > org.objectstyle.cayenne.access.DataNode.runUpdate(DataNode.java:435)
    >
    > The error doesn't happen every time I run the application, but
    > approximately
    > every other time.

    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'? 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.

    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.

    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.

    Sorry, this wasn't too helpful..

    Andrus



    This archive was generated by hypermail 2.0.0 : Fri Oct 24 2003 - 03:30:28 EDT