Return-Path: Delivered-To: apmail-incubator-cayenne-user-archive@locus.apache.org Received: (qmail 32186 invoked from network); 9 Oct 2006 13:44:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 9 Oct 2006 13:44:14 -0000 Received: (qmail 75887 invoked by uid 500); 9 Oct 2006 13:44:13 -0000 Delivered-To: apmail-incubator-cayenne-user-archive@incubator.apache.org Received: (qmail 75873 invoked by uid 500); 9 Oct 2006 13:44:13 -0000 Mailing-List: contact cayenne-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cayenne-user@incubator.apache.org Delivered-To: mailing list cayenne-user@incubator.apache.org Received: (qmail 75864 invoked by uid 99); 9 Oct 2006 13:44:13 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Oct 2006 06:44:13 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of bob@najdi.si designates 193.189.169.107 as permitted sender) Received: from [193.189.169.107] (HELO elfstone.noviforum.si) (193.189.169.107) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Oct 2006 06:44:10 -0700 Received: from localhost (localhost [127.0.0.1]) by elfstone.noviforum.si (ESMTP) with ESMTP id 12CA11B91D for ; Mon, 9 Oct 2006 15:43:48 +0200 (CEST) Message-ID: <452A5213.2060707@najdi.si> Date: Mon, 09 Oct 2006 15:43:47 +0200 From: =?UTF-8?B?Qm9ydXQgQm9sxI1pbmE=?= User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) MIME-Version: 1.0 To: cayenne-user@incubator.apache.org Subject: Re: Parent/Child Insert ordering (was: Caching problem?) References: <446E732D.5040901@pfrog.com> <71E3857E-CC22-456C-9813-DEE96ACC8A6E@gmail.com> <9813CBF2-1A71-4BDF-BC95-C3504631022D@objectstyle.org> In-Reply-To: <9813CBF2-1A71-4BDF-BC95-C3504631022D@objectstyle.org> Content-Type: multipart/alternative; boundary="------------040607080606010301000404" X-Virus-Scanned: by Najdi.si X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --------------040607080606010301000404 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi, in API docs for org.objectstyle.cayenne.map.AshwoodEntitySorter it says: "...Presently it works for acyclic database schemas with possible multi-reflexive tables. The class uses topological sorting from the Ashwood library ." What are multi-reflexive tables? I guess not every reflexive relationship is cyclic. If db row "points" to the same db row then it would be cyclic (for example - someone is his/her own manager), otherwise just reflexive. Is this correct? -Borut On 21.5.2006 19:24, Andrus Adamchik wrote: > Cayenne handles correct ordering of operations automatically, based on > dependencies derived from relationships.The algorithm has a few > limitations though. It can't handle cycles (when Entity A depends on > Entity B, but also Entity B depends on Entity A). This probably also > includes entities that have relationships to the same entity (I assume > this is the case the original post was referring to). > > There are few solutions: > > 1. (a workaround, rather than a solution) Do commit in two steps. > 2. Define FK constraints in question as DEFERRABLE and INITIALLY > DEFERRED (supported by Postgres 8.*) > 3. Set a custom org.objectstyle.cayenne.map.EntitySorter on the DataNode. > > Andrus > > > On May 20, 2006, at 3:00 AM, Marcin Skladaniec wrote: > >> Hm. Strange. I do really complex commits, sometimes 7 or more related >> records (I mean 7 levels of relationship, not seven entities), >> related by many-to-many many-to-one relationships and never get those >> problems. And it doesn't matter if the records are new or old. Could >> you describe how you are creating objects and how do you commit them ? >> >> Regards >> Marcin >> >> On 20/05/2006, at 4:31 PM, Tomi NA wrote: >> >>> On 5/20/06, Jeff de Vries wrote: >>>> I don't know if it is related or not, but I've also had problems in >>>> the >>>> past when I try to create a new parent and several child objects >>>> related >>>> to that parent all at once and then try to commit. The problem looks >>>> like Cayenne is INSERTing the child records into the database first, >>>> before the parent record, and the database complains that the children >>>> have an invalid foreign key (and, yes, I have the ON UPDATE and ON >>>> DELETE rules for the foreign key set to DO NOTHING and I still get the >>>> error from PostgreSQL). To get around it I just committed the parent >>>> first, then committed all the children. >>> >>> I had the same problem, IIRC: I was very surprised that cayenne >>> couldn't handle such a commit, although truth be told, I can't imagine >>> everything that's going on under the hood of the operation that would >>> make implementing this feature difficult. >>> I would certainly love to see this fixed (if at all possible) as I >>> wasn't to happy to have to commit in the middle of what had to be an >>> atomic transaction. It'd also make the framework a lot more flexible, >>> e.g. enabling the user to have long inter-commit sessions with complex >>> data updates, if the user so desires. >>> >>> t.n.a. >> >> > -- bLOG -- Naključna *izjava tedna* iz tednika Mladina: --------------040607080606010301000404 Content-Type: multipart/related; boundary="------------050403060707070007050100" --------------050403060707070007050100 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit Hi,

in API docs for org.objectstyle.cayenne.map.AshwoodEntitySorter it says:
"...Presently it works for acyclic database schemas with possible multi-reflexive tables. The class uses topological sorting from the Ashwood library."
What are multi-reflexive tables? I guess not every reflexive relationship is cyclic. If db row "points" to the same db row then it would be cyclic (for example - someone is his/her own manager), otherwise just reflexive. Is this correct?

-Borut

On 21.5.2006 19:24, Andrus Adamchik wrote:
Cayenne handles correct ordering of operations automatically, based on dependencies derived from relationships.The algorithm has a few limitations though. It can't handle cycles (when Entity A depends on Entity B, but also Entity B depends on Entity A). This probably also includes entities that have relationships to the same entity (I assume this is the case the original post was referring to).

There are few solutions:

1. (a workaround, rather than a solution) Do commit in two steps.
2. Define FK constraints in question as DEFERRABLE and INITIALLY DEFERRED (supported by Postgres 8.*)
3. Set a custom org.objectstyle.cayenne.map.EntitySorter on the DataNode.

Andrus


On May 20, 2006, at 3:00 AM, Marcin Skladaniec wrote:

Hm. Strange. I do really complex commits, sometimes 7 or more related records (I mean 7 levels of relationship, not seven entities), related by many-to-many many-to-one relationships and never get those problems. And it doesn't matter if the records are new or old. Could you describe how you are creating objects and how do you commit them ?

Regards
Marcin

On 20/05/2006, at 4:31 PM, Tomi NA wrote:

On 5/20/06, Jeff de Vries <jdevries@pfrog.com> wrote:
I don't know if it is related or not, but I've also had problems in the
past when I try to create a new parent and several child objects related
to that parent all at once and then try to commit.  The problem looks
like Cayenne is INSERTing the child records into the database first,
before the parent record, and the database complains that the children
have an invalid foreign key (and, yes, I have the ON UPDATE and ON
DELETE rules for the foreign key set to DO NOTHING and I still get the
error from PostgreSQL).  To get around it I just committed the parent
first, then committed all the children.

I had the same problem, IIRC: I was very surprised that cayenne
couldn't handle such a commit, although truth be told, I can't imagine
everything that's going on under the hood of the operation that would
make implementing this feature difficult.
I would certainly love to see this fixed (if at all possible) as I
wasn't to happy to have to commit in the middle of what had to be an
atomic transaction. It'd also make the framework a lot more flexible,
e.g. enabling the user to have long inter-commit sessions with complex
data updates, if the user so desires.

t.n.a.




--
bLOG
--
Naključna izjava tedna iz tednika Mladina:
--------------050403060707070007050100 Content-Type: image/gif; name="blog-logo.gif" Content-Transfer-Encoding: base64 Content-ID: Content-Disposition: inline; filename="blog-logo.gif" R0lGODlhbgASANUAAAAAAI+Pj/aVAE9PT//Ug/+tKTMzM//1z8zMzL+/v//BWP+gDx8fH//k p39/f/+ZAP/83v+xMg8PD5+fnz8/P29vb/+3Qd/f3//uvv/OdP/clf+UAK+vr///7v+oH19f X/+8S//41v/ptf+dCf//5v/GY/+lGf/fnP/xxf+0Ov/rt//Pev/XjP+wMP++U//63P+qIv/m rP+jEv+1Sv/Iaf/DW//////epf/yyv/WewAAAAAAAAAAAAAAAAAAAAAAACH5BAEHADYALAAA AABuABIAAAb/wIdwSCwaj0ikYMlsOp/QqHRKTVqvWKFty+16v+CweDwWZJOb9OaoXhvJ8Lh8 bh7CTMVRq1UYGQsWgTJuQgspICAFR3OMjY11QholRQUYITEyRB4sOB0dEDEWQxYNL544BJlE XRcOrhONCF2uDgEdYA42Ca4JNrlxkA8nkzJ+DwUHHRh4hScdJAcopgcRGymdECjJHSxFXQkM rga/cQHkNgCuAxRgAFsU7DbxcMEaLCsaGtUFOCQqzA9AkPAHY8SKgRoesHjGQk+MAzE8rOKS IF7FLQh62UDQIUEHWbo6fPhwgYu7LScveESJUWOvl7e2JNC4pR4OBRFWiDABo9+//yEESECg kQbGARIYWsToQG3DiAggLAB88C2eORsVGBhgR2HrhHgAEDBgAIvlRnYcJFBgUNJdVgbs3AHo KmGLAQNwuQQ7QUBNjBImfAJkQeKFCyEmMCAFIUIZjAcZVMSIAYLQNwCYJXCUcIsCBwoBdIH1 dQ4zZlgGejmogK4DZxsGLsjtlfoC6w4nbeydJIQFgcD+BqUJOjSNh6MYIiw90GJDBgjPalim GG8Cg4ukKbwc7arLSQQSZMuMi53lSe26HFDIvXfFkBMZgGMosGDBCIEkRBSQkWHgiQcaPPNb CjEUpsB045mEnSvoYedOdyZxod1JFwGAHQe4ofPOTKllWPETESfg0IcFGKRwXGEYiIDBCTI4 QwIKIkBAQggpbGBBCJ+ooMILAx04RFVbcMCADZp1wAAC6InVQQAPshahDReEN0BoU2qoGQIA ZHjeLgP4wh4RLDRwwgkiTAIDBgccEEIIEGDwgAka4CBjCCKAMIQCGMgIQQMNHOACgrqYdqQN aQHAGno2DJCOOwlI4CQ6mcGCgAFz3eLOBBJIAItcG17AgKav6UZEASaYYIEiDzyVwqqsDtGC CzWAsAAhb8JqwQImpDCVI7z2GkYwSLShxhBtsCGsN74m6ysVzDYrhbLQOuLstNRGa60c1Gar 7bbcdhsEADs= --------------050403060707070007050100-- --------------040607080606010301000404--