RE: saving to multiple tables

From: Philip Miller (philip.mille..bc.co.uk)
Date: Thu Feb 15 2007 - 11:46:12 EST

  • Next message: Andrus Adamchik: "Lifecycle callback API changes"

    I've had duplicate primary keys resulting from key caching previously.
    IIRC correctly the default is 20 which corresponds to your symptoms.

    Try setting your primary key caches to 1. Or updating your sequences to
    increment by 20.

    > -----Original Message-----
    > From: edward pedersson [mailto:cpsmadnes..ooglemail.com]
    > Sent: 15 February 2007 16:39
    > To: Cayenne Users
    > Subject: 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
    >

    http://www.bbc.co.uk/
    This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated.
    If you have received it in error, please delete it from your system.
    Do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately.
    Please note that the BBC monitors e-mails sent or received.
    Further communication will signify your consent to this.
                                            



    This archive was generated by hypermail 2.0.0 : Thu Feb 15 2007 - 11:46:56 EST