Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 288E2200B62 for ; Fri, 29 Jul 2016 01:48:09 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 27233160A94; Thu, 28 Jul 2016 23:48:09 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 46044160A85 for ; Fri, 29 Jul 2016 01:48:08 +0200 (CEST) Received: (qmail 53247 invoked by uid 500); 28 Jul 2016 23:48:07 -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 53236 invoked by uid 99); 28 Jul 2016 23:48:07 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Jul 2016 23:48:07 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id B69F8C7E0C for ; Thu, 28 Jul 2016 23:48:06 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.713 X-Spam-Level: * X-Spam-Status: No, score=1.713 tagged_above=-999 required=6.31 tests=[HTML_MESSAGE=2, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-1.287] autolearn=disabled Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id t4gTkdy2SZdB for ; Thu, 28 Jul 2016 23:48:03 +0000 (UTC) Received: from mail.swarmbox.com (mail.swarmbox.com [50.112.163.34]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with ESMTPS id 080195F19B for ; Thu, 28 Jul 2016 23:48:02 +0000 (UTC) Received: from [192.168.100.24] (roach.swarmbox.com [192.168.100.24]) by mail.swarmbox.com (Postfix) with ESMTPSA id CEFF419B8 for ; Thu, 28 Jul 2016 16:47:53 -0700 (PDT) From: Dougan Stuart Content-Type: multipart/alternative; boundary="Apple-Mail=_BA195894-1D8D-4EA0-8CDB-85B1F7DC7861" Message-Id: Mime-Version: 1.0 (Mac OS X Mail 9.2 \(3112\)) Subject: Re: Extended class issues Date: Thu, 28 Jul 2016 16:47:52 -0700 References: <79F43058-6FF3-4C1C-A25F-37F55EF0FE1D@swarmbox.com> <2421E2FE-3B24-4D82-AAC5-D4B2E0D6E5B1@objectstyle.org> To: user@cayenne.apache.org In-Reply-To: <2421E2FE-3B24-4D82-AAC5-D4B2E0D6E5B1@objectstyle.org> X-Mailer: Apple Mail (2.3112) archived-at: Thu, 28 Jul 2016 23:48:09 -0000 --Apple-Mail=_BA195894-1D8D-4EA0-8CDB-85B1F7DC7861 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Sure, here=E2=80=99s the relevant parts: =E2=80=A8 =E2=80=A8 =E2=80=A8= =E2=80=A8 =E2=80=A8 =E2=80=A8 =E2=80=A8 = =E2=80=A8 =E2=80=A8 =E2=80=A8 =E2=80=A8 =E2=80=A8 =E2=80=A8 =E2=80=A8 =E2=80=A8 =E2=80=A8 =E2=80= =A8 =E2=80=A8 =E2=80=A8 =E2=80=A8 =E2=80=A8 =E2=80=A8=E2=80=A8 =E2=80=A8 =E2=80=A8 =E2=80=A8=E2=80=A8 I=E2=80=99ve created a fix for this issue in = DataDomainDBDiffBuilder.appendForeignKeys on line 133 (within the nested = loop): String joinSourceName =3D join.getSourceName(); if (dbDiff.get(joinSourceName) =3D=3D null && = dbEntity.getAttribute(joinSourceName) !=3D null) { dbDiff.put(joinSourceName, value); } The only change is that I=E2=80=99m checking if the dbEntity actually = has the attribute it=E2=80=99s trying to add from the join. If it = doesn=E2=80=99t have the attribute, then it doesn=E2=80=99t make sense = to put it on the dbDiff. In DataDomainUpdateBucket.updatedAttribtues = (mentioned in my prior message), it expects everything in the dbDiff to = be an attribute that exists on the dbEntity. The fix passed Cayenne=E2=80=99= s tests and didn=E2=80=99t appear to cause any side effects. Of course, = this is all moot if I just botched the data map. Let me know what you = think. Thanks, Doug > On Jul 28, 2016, at 3:47 AM, Andrus Adamchik = wrote: >=20 > Would you mind posting a relevant part of your DataMap XML? >=20 > Andrus >=20 >> On Jul 13, 2016, at 8:40 PM, Dougan Stuart wrote: >>=20 >> I have a class Company with a one-to-many relationship to other = Companies (parentCompany <- subCompanies). I=E2=80=99m able to set a = Company=E2=80=99s parent when creating one, but upon update I=E2=80=99m = getting a NullPointerException in DefaultQuotingStrategy.quotedName = because it=E2=80=99s been sent a null attribute. Company extends the = abstract class Entity; on the DB side Entity and Company have a = one-to-one relationship, and Entity has a parentEntity reference (which = is modeled as parentCompany). The obj-relationship parentCompany is set = up with the target Company and path parentEntity. >>=20 >> The null attribute is being added in = org.apache.cayenne.access.DataDomainUpdateBucket.updatedAttributes. The = method is called first with the dbEntity Entity and the an = updatedSnapshot containing parentEntity, which is what I would expect. = However, after this updatedAttributes is called with Company and an = updatedSnapshot containing parentEntity, so the following line >>=20 >> attributes.add(entityAttributes.get(name)) >>=20 >> will return a null attribute when trying to get the name = =E2=80=9CparentEntity=E2=80=9D off Company=E2=80=99s attributes; that = attribute only exists on Entity. I=E2=80=99d appreciate any help on = preventing it from trying to add invalid attributes. >>=20 >> I=E2=80=99m not sure if this is the root cause, but = DataDomainUpdateBucket.appendQueriesInternal calls updatedAttributes = based off the bucket=E2=80=99s dbEntities, which in this case are set in = DataDomainSyncBucket.groupObjEntitiesBySpannedDbEntities; this method is = only adding Company as a =E2=80=9Csecondary DbEntity=E2=80=9D (as = referred to in the comments) because Company has a flattened attribute = =E2=80=9Cname" that does not exist on the Entity. >>=20 >> Here=E2=80=99s the stack trace: >>=20 >> java.lang.NullPointerException >> at = org.apache.cayenne.dba.DefaultQuotingStrategy.quotedName(DefaultQuotingStr= ategy.java:62) >> at = org.apache.cayenne.access.translator.batch.UpdateBatchTranslator.createSql= (UpdateBatchTranslator.java:60) >> at = org.apache.cayenne.access.translator.batch.DefaultBatchTranslator.ensureTr= anslated(DefaultBatchTranslator.java:52) >> at = org.apache.cayenne.access.translator.batch.DefaultBatchTranslator.getSql(D= efaultBatchTranslator.java:64) >> at = org.apache.cayenne.access.jdbc.BatchAction.runAsBatch(BatchAction.java:103= ) >> at = org.apache.cayenne.access.jdbc.BatchAction.performAction(BatchAction.java:= 90) >> at = org.apache.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryAction= .java:97) >> at = org.apache.cayenne.access.DataNode.performQueries(DataNode.java:293) >> at = org.apache.cayenne.access.DataDomainFlushAction.runQueries(DataDomainFlush= Action.java:233) >> at = org.apache.cayenne.access.DataDomainFlushAction.flush(DataDomainFlushActio= n.java:154) >> at = org.apache.cayenne.access.DataDomain.onSyncFlush(DataDomain.java:693) >> at = org.apache.cayenne.access.DataDomain$2.transform(DataDomain.java:659) >> at = org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:720)= >> at = org.apache.cayenne.access.DataDomain.onSyncNoFilters(DataDomain.java:655) >> at = org.apache.cayenne.access.DataDomain$DataDomainSyncFilterChain.onSync(Data= Domain.java:863) >> at = org.apache.cayenne.access.DataDomain.onSync(DataDomain.java:636) >> at = org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:727) >> at = org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:676) >>=20 >> Thanks, >> Doug >>=20 >=20 --Apple-Mail=_BA195894-1D8D-4EA0-8CDB-85B1F7DC7861--