Re: Constraint handling messed up?

From: Dirk Olmes (dirk.olme..mx.de)
Date: Wed Feb 05 2003 - 21:18:28 EST

  • Next message: Dirk Olmes: "Postgres adaptor"

    Holger Hoffstätte wrote:
    > After finishing the deprecation cleanups I sync'ed with other changes and
    > now get failures in a couple of tests. Most often they are caused by a
    > constraint violation, like e.g. in DOPrefetchTst.testPrefetchToMany on the
    > first insert:
    >
    > <error message="Raising from underlyingQueryEngine exception."
    > type="org.objectstyle.cayenne.CayenneRuntimeException">org.objectstyle.cayenne.CayenneRuntimeException:
    > Raising from underlyingQueryEngine exception.
    > at
    > org.objectstyle.cayenne.access.util.ContextCommitObserver.nextGlobalException(ContextCommitObserver.java:188)
    > at
    > org.objectstyle.cayenne.access.DataNode.performQueries(DataNode.java:335)
    > at
    > org.objectstyle.cayenne.access.DataDomain.performQueries(DataDomain.java:413)
    > at
    > org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.java:842)
    > at
    > org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.java:680)
    > at
    > org.objectstyle.cayenne.DOPrefetchTst.testPrefetchToMany(DOPrefetchTst.java:79)
    >
    > log goes like this:
    > cayenne INFO [main 02-05 19:27:38] QueryLogger: CREATE SEQUENCE
    > pk_delete_rule_test1 START WITH 200 INCREMENT BY 20
    > cayenne INFO [main 02-05 19:27:38] QueryLogger: CREATE SEQUENCE
    > pk_float_test START WITH 200 INCREMENT BY 20
    > cayenne INFO [main 02-05 19:27:38] QueryLogger: --- will run 2 queries.
    > cayenne INFO [main 02-05 19:27:38] QueryLogger: INSERT INTO PAINTING
    > (PAINTING_ID, ESTIMATED_PRICE, ARTIST_ID, PAINTING_TITLE) VALUES (?, ?, ?,
    > ?) [params: 212, NULL, 209, 'painting about nothing']
    > cayenne INFO [main 02-05 19:27:38] QueryLogger: *** error.
    > java.sql.SQLException: ORA-02291: integrity constraint
    > (CAYENNE.SYS_C001945) violated - parent key not found

    Just a quick sidenote from my side on constraints:

    I'm currently working on the postgres adaptor and it makes some progress
    (more in a separate mail). I've stumbled over the constraints also (but
    not related to holger's updates) and my fix was to create the
    constraints as "DEFERRABLE INITIALLY DEFERRED". This way, the
    constraints will not be checked by the time a SQL command is issued but
    at the end of the transaction.

    On my last Oracle project declaring all constraints as deferrable
    initially deferred helped to avoid a lot of troubles and now I wonder if
    this wouldn't be a sensible default for oracle, too.

    Sidenote: I wonder how the unit test passed on oracle but I guess that's
    due to details on the inner workings of constraints between oracle and
    postgresql.

    -dirk



    This archive was generated by hypermail 2.0.0 : Wed Feb 05 2003 - 21:19:58 EST