saving to multiple tables

From: edward pedersson (cpsmadnes..ooglemail.com)
Date: Thu Feb 15 2007 - 11:38:49 EST

  • Next message: Philip Miller: "RE: saving to multiple tables"

    Hi
    I am using Cayenne 2.02 on Oracle and I am issues saving some data
    back to the database. I am simply creating some new persistent objects
    and saving using commit changes. The objects are all related in some
    way or another. How does Cayenne decide which objects to save first?
    Everytime I save the order in which Cayenne updates the database is
    different even though I am saving the same data everytime. I am mostly
    getting this error

    java.sql.SQLException: ORA-02291: integrity constraint (..._FK)
    violated - parent key not found

    and this is because it is batch saving to one particular table but it
    needs to save to another table first. It seems to not be able to work
    out the relationships (or maybe I have complicated them as some are
    cyclical?)

    In addition, I am also getting this error

    java.sql.SQLException: ORA-00001: unique constraint (PK_....) violated

    and this is from the logs

    9775 [main] INFO org.apache.cayenne.access.QueryLogger - INSERT INTO
    ATABLE (foreignKey, ID) VALUES (?, ?)
    9785 [main] INFO org.apache.cayenne.access.QueryLogger - [batch
    bind: 5843, 46470]
    9785 [main] INFO org.apache.cayenne.access.QueryLogger - [batch
    bind: 5844, 46471]
    9785 [main] INFO org.apache.cayenne.access.QueryLogger - [batch
    bind: 5814, 46472]
    9785 [main] INFO org.apache.cayenne.access.QueryLogger - [batch
    bind: 5846, 46473]
    9785 [main] INFO org.apache.cayenne.access.QueryLogger - [batch
    bind: 5834, 46474]
    9785 [main] INFO org.apache.cayenne.access.QueryLogger - [batch
    bind: 5803, 46475]
    9785 [main] INFO org.apache.cayenne.access.QueryLogger - [batch
    bind: 5847, 46476]
    9785 [main] INFO org.apache.cayenne.access.QueryLogger - [batch
    bind: 5811, 46477]
    9785 [main] INFO org.apache.cayenne.access.QueryLogger - [batch
    bind: 5810, 46478]
    9785 [main] INFO org.apache.cayenne.access.QueryLogger - [batch
    bind: 5805, 46479]
    9785 [main] INFO org.apache.cayenne.access.QueryLogger - [batch
    bind: 5812, 46480]
    9785 [main] INFO org.apache.cayenne.access.QueryLogger - [batch
    bind: 5806, 46481]
    9785 [main] INFO org.apache.cayenne.access.QueryLogger - [batch
    bind: 5845, 46482]
    9785 [main] INFO org.apache.cayenne.access.QueryLogger - [batch
    bind: 5808, 46483]
    9785 [main] INFO org.apache.cayenne.access.QueryLogger - [batch
    bind: 5804, 46484]
    9785 [main] INFO org.apache.cayenne.access.QueryLogger - [batch
    bind: 5833, 46485]
    9785 [main] INFO org.apache.cayenne.access.QueryLogger - [batch
    bind: 5848, 46486]
    9785 [main] INFO org.apache.cayenne.access.QueryLogger - [batch
    bind: 5809, 46487]
    9785 [main] INFO org.apache.cayenne.access.QueryLogger - [batch
    bind: 5807, 46488]
    9785 [main] INFO org.apache.cayenne.access.QueryLogger - [batch
    bind: 5793, 46489]
    9785 [main] INFO org.apache.cayenne.access.QueryLogger - [batch
    bind: 5835, 46472]
    9785 [main] INFO org.apache.cayenne.access.QueryLogger - [batch
    bind: 5813, 46473]

    you will notice the ID's 46472 and 46473 are causing the problem. All
    these objects are new but Cayenne is trying to add two with the same
    key twice?

    Has anyone seen this before. Also any insight on how Cayenne saves to
    the database would be helpful.

    Regards

    -- 
    

    -- e



    This archive was generated by hypermail 2.0.0 : Thu Feb 15 2007 - 11:39:59 EST