Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 75461 invoked from network); 17 Aug 2009 06:36:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 17 Aug 2009 06:36:13 -0000 Received: (qmail 65150 invoked by uid 500); 17 Aug 2009 06:36:19 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 65120 invoked by uid 500); 17 Aug 2009 06:36:19 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 65110 invoked by uid 99); 17 Aug 2009 06:36:19 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Aug 2009 06:36:19 +0000 X-ASF-Spam-Status: No, hits=1.8 required=10.0 tests=MIME_QP_LONG_LINE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [213.239.215.103] (HELO tux17.hoststar.ch) (213.239.215.103) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Aug 2009 06:36:09 +0000 Received: from [192.168.0.33] ([194.230.63.144]) (authenticated bits=0) by tux17.hoststar.ch (8.13.6/8.12.11) with ESMTP id n7H6ZlbO000837 for ; Mon, 17 Aug 2009 08:35:48 +0200 Date: Mon, 17 Aug 2009 08:35:47 +0200 From: Jeremias Maerki To: user@cayenne.apache.org Subject: Re: Problem with reverse relationships and inheritance In-Reply-To: <3219fff70908161301o6fa70637w692573b7452ec282@mail.gmail.com> References: <20090814150854.62D0.60BA733C@jeremias-maerki.ch> <3219fff70908161301o6fa70637w692573b7452ec282@mail.gmail.com> Message-Id: <20090817083009.6DF6.60BA733C@jeremias-maerki.ch> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable X-Mailer: Becky! ver. 2.50.02 [en] X-Virus-Checked: Checked by ClamAV on apache.org Thanks, Andrey. I somehow missed that. I'll see if I can allocate time to write a test case. That could help speed things up. On 16.08.2009 22:01:17 Andrey Razumovsky wrote: > Hi Jeremias, >=20 > This is also known as CAY-1009: > http://issues.apache.org/jira/browse/CAY-1009 >=20 > I tried patch from there (and it looks like yours) but there WERE side > effects (I listed them in JIRA). At the moment I was forced to make the > relationship non-mandatory in my project (and validate in different ways).= I > would really like to get it fixed, but I haven't found time for that yet... > Please watch the JIRA to be notified of the updates >=20 > Regards, > Andrey >=20 > 2009/8/14 Jeremias Maerki >=20 > > I think I may have run into an issue that is related to this thread: > > http://markmail.org/message/slm4joyswjp77vzi > > > > - I have an (abstract) entity A and two subentities/subclasses A1 and A= 2. > > - I have an (abstract) entity B with three subentities B1, B2 and B3. > > - There is a 1:n relationship from A to B. > > > > Now, if I create an instance of A1 and use addToB() to add a B1 instanc= e, > > B1 is added to the list. But I get a validation error because upon > > commit the foreign key for the A1 instance is not set on the B1 instanc= e. > > > > Debugging, I found that ObjRelationship.getReverseRelationship() didn't > > look in super entities for the reverse relationship. > > > > Mindlessly changing that method (in Trunk) from: > > > > Entity src =3D this.getSourceEntity(); > > > > Iterator it =3D target.getRelationships().iterator(); > > while (it.hasNext()) { > > ObjRelationship rel =3D (ObjRelationship) it.next(); > > if (rel.getTargetEntity() !=3D src) > > continue; > > > > to: > > > > Entity src =3D this.getSourceEntity(); > > > > Iterator it =3D target.getRelationships().iterator(); > > while (it.hasNext()) { > > ObjRelationship rel =3D (ObjRelationship) it.next(); > > Entity relTarget =3D rel.getTargetEntity(); > > ObjEntity currentSrc =3D (ObjEntity)src; > > while (currentSrc !=3D null) { > > if (relTarget =3D=3D currentSrc) { > > break; > > } > > currentSrc =3D currentSrc.getSuperEntity(); > > } > > if (src =3D=3D null) { > > continue; > > } > > > > ...solves my immediate problem, but I have no idea about any > > side-effects. Am I doing anything wrong? > > > > Thanks, > > Jeremias Maerki > > > > Jeremias Maerki