Return-Path: X-Original-To: apmail-cayenne-dev-archive@www.apache.org Delivered-To: apmail-cayenne-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5A4A410BD5 for ; Thu, 2 Jan 2014 13:48:55 +0000 (UTC) Received: (qmail 18516 invoked by uid 500); 2 Jan 2014 13:48:52 -0000 Delivered-To: apmail-cayenne-dev-archive@cayenne.apache.org Received: (qmail 18484 invoked by uid 500); 2 Jan 2014 13:48:47 -0000 Mailing-List: contact dev-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cayenne.apache.org Delivered-To: mailing list dev@cayenne.apache.org Received: (qmail 18468 invoked by uid 99); 2 Jan 2014 13:48:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Jan 2014 13:48:43 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of mkienenb@gmail.com designates 209.85.128.47 as permitted sender) Received: from [209.85.128.47] (HELO mail-qe0-f47.google.com) (209.85.128.47) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Jan 2014 13:48:39 +0000 Received: by mail-qe0-f47.google.com with SMTP id t7so14099941qeb.20 for ; Thu, 02 Jan 2014 05:48:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=T6pZnslMD1OnQNl1YJigWXQKxN36wXKnZVERzo5CFG8=; b=uv4x8fN38+fyIRAIaCBzla6WUsuss5eYtrM4BNfdHeQACwJvJpnID0zGmFTRWwdsM/ Sm6cNSkbuFd822+FGnA4YOZ/tX5nY3DwZFsU0Aa+1ikp3yVCV6pH+vsygulDqJwU73lv 5UxHRbw/MyP9GQfujVJBtMTKXss4e1RcCwTyg346KsD6MD6xyWt3j/oJvyxFgph7DwRv 2qaNE+I2pjLgYuoSj07RVMOpAUfUEx6ZD2Pk4VxB4ztF192Aq200eg2l9PmKwrsoF21K hQ9v7ZeN34qRqN7IJIWgcz4wqwlGOW0GqSCaSMMR2td4X8kUbADgNxu5EvyMbQlXocfu artw== X-Received: by 10.49.53.66 with SMTP id z2mr142193309qeo.45.1388670498272; Thu, 02 Jan 2014 05:48:18 -0800 (PST) MIME-Version: 1.0 Received: by 10.96.115.98 with HTTP; Thu, 2 Jan 2014 05:47:58 -0800 (PST) In-Reply-To: <41FC4493-C054-45DA-8548-6BF475ACE831@objectstyle.org> References: <41FC4493-C054-45DA-8548-6BF475ACE831@objectstyle.org> From: Mike Kienenberger Date: Thu, 2 Jan 2014 08:47:58 -0500 Message-ID: Subject: Re: Changes (probably between 1.1 and 1.2) in how Cayenne handles fetching relationships (overzealous now) To: dev@cayenne.apache.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org I'll take a look at upgrading to trunk. But even without the runtime relationships, we still have a over-zealous fetching algorithm. If I get a chance, I'll try looking into it again to see what is triggering it. It'll be awhile as I have a lot of velocity templates to upgrade from pre-1.2 to now since I've made massive changes to my database model, and a lot of code to remove. On Thu, Jan 2, 2014 at 5:14 AM, Andrus Adamchik wr= ote: > One source of constant trouble introduced in 3.0 is =93runtime=94 relatio= nships. We finally got rid of them on trunk (CAY-1861). Perhaps you may try= it with a trunk build and see if that helps? > > Andrus > > > On Jan 1, 2014, at 6:36 PM, Mike Kienenberger wrote: > >> In the old days (1.1), a relationship to a table that didn't exist in >> the current database and wasn't referenced explicitly by the java code >> wasn't an issue. But after my upgrade to 1.2/2.0/3.0 ending at 3.1, I >> noticed that cayenne would generate relationship queries for these >> items even when they were not necessary. >> >> For awhile, I was able to deal with this by explicitly checking for >> known "bad" relationships by detecting them and returning null. >> >> public Query willPerformQuery(DataContext dataContext, Query query) { >> >> if (query instanceof RelationshipQuery) { >> RelationshipQuery relationshipQuery =3D (RelationshipQuery)qu= ery; >> if (we_know_the_relationships_are_not_used_by_this_deployment= ) { >> if >> ("Account".equals(relationshipQuery.getObjectId().getEntityName())) { >> if >> ("accountBadRelationshipNameForThisDeployment".equals(relationshipQuery.= getRelationshipName())) >> { >> // do nothing >> return null; >> } >> } >> >> But then I started to hit them for relationships being internally >> generated by Cayenne, which is even more frustrating as these are now >> relationships not used by any of my code in any situation, and I can't >> detect them and ignore them any more. >> >> It seems rather odd to me that we are executing database queries >> against relationships which the end-user doesn't even define as an >> ObjRelationship. >> >> I am probably going to just create a separate datamap for each >> deployment type (there are currently only two) rather than fight this >> any more. The timing is somewhat right as the application originally >> ran at two divisions of the same company, and those have now split >> into two separate companies and there is a desire to maintain the code >> separately. But it still seems as if this is a problem that Cayenne >> should not be creating and has performance and efficiency issues. >> >> >> Ebpp DEBUG [btpool0-14 01-01 10:09:28] >> RestrictingQualifierDataContextDelegate: in >> RestrictingQualifierDataContextDelegate.willPerformQuery(DataContext, >> Query) >> Ebpp DEBUG [btpool0-14 01-01 10:09:28] >> RestrictingQualifierDataContextDelegate: >> relationshipQuery.getRelationshipName()=3DruntimeRelationship2 >> Ebpp DEBUG [btpool0-14 01-01 10:09:28] >> RestrictingQualifierDataContextDelegate: >> relationshipQuery.getObjectId().getEntityName()=3DAccount >> Ebpp INFO [btpool0-14 01-01 10:09:28] CommonsJdbcEventLogger: --- >> transaction started. >> >> Ebpp INFO [btpool0-14 01-01 10:09:28] CommonsJdbcEventLogger: SELECT >> DISTINCT t0.ALTITUDE AS c0, t0.DOOR_HANGER_NUMBER AS c1, >> t0.INVALIDATED AS c2, t0.INVALIDATED_DATE AS c3, >> t0.IS_ADDED_TO_MAP_DATABASE AS c4, t0.LATITUDE AS c5, t0.LONGITUDE AS >> c6, t0.ID AS c7, t0.SERVICE_ADDRESS_ID AS c8, t0.TAX_DISTRICT_ID AS c9 >> FROM PREMISE t0 JOIN ACCOUNT_THISTABLEDOESNOTEXIST t1 ON (t0.ID =3D >> t1.PREMISE_ID) WHERE t1.ID =3D ? [bind: 1:58401] >> Ebpp INFO [btpool0-14 01-01 10:09:28] CommonsJdbcEventLogger: *** error= . >> java.sql.SQLException: ORA-00942: table or view does not exist >> [...] >> at org.apache.cayenne.access.jdbc.SelectAction.performAction(SelectAc= tion.java:75) >> at org.apache.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQue= ryAction.java:87) >> at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:28= 0) >> at org.apache.cayenne.access.DataDomainQueryAction.runQuery(DataDomai= nQueryAction.java:442) >> at org.apache.cayenne.access.DataDomainQueryAction.access$000(DataDom= ainQueryAction.java:70) >> at org.apache.cayenne.access.DataDomainQueryAction$2.transform(DataDo= mainQueryAction.java:415) >> at org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.j= ava:877) >> at org.apache.cayenne.access.DataDomainQueryAction.runQueryInTransact= ion(DataDomainQueryAction.java:412) >> at org.apache.cayenne.access.DataDomainQueryAction.execute(DataDomain= QueryAction.java:122) >> at org.apache.cayenne.access.DataDomain.onQueryNoFilters(DataDomain.j= ava:758) >> at org.apache.cayenne.access.DataDomain$DataDomainQueryFilterChain.on= Query(DataDomain.java:1009) >> at org.apache.cayenne.access.DataDomain.onQuery(DataDomain.java:748) >> at org.apache.cayenne.util.ObjectContextQueryAction.runQuery(ObjectCo= ntextQueryAction.java:350) >> at org.apache.cayenne.util.ObjectContextQueryAction.executePostCache(= ObjectContextQueryAction.java:106) >> at org.apache.cayenne.util.ObjectContextQueryAction.execute(ObjectCon= textQueryAction.java:93) >> at org.apache.cayenne.access.DataContext.onQuery(DataContext.java:989= ) >> at org.apache.cayenne.access.DataContext.performQuery(DataContext.jav= a:978) >> at org.apache.cayenne.access.ToOneFault.doResolveFault(ToOneFault.jav= a:81) >> at org.apache.cayenne.access.ToOneFault.resolveFault(ToOneFault.java:= 54) >> at org.apache.cayenne.CayenneDataObject.readProperty(CayenneDataObjec= t.java:186) >> at org.apache.cayenne.reflect.generic.DataObjectBaseProperty.readProp= erty(DataObjectBaseProperty.java:43) >> at org.apache.cayenne.access.ObjectDiff$1.visitToOne(ObjectDiff.java:= 106) >> at org.apache.cayenne.reflect.generic.DataObjectToOneProperty.visit(D= ataObjectToOneProperty.java:87) >> at org.apache.cayenne.reflect.PersistentDescriptor.visitProperties(Pe= rsistentDescriptor.java:411) >> at org.apache.cayenne.reflect.LazyClassDescriptorDecorator.visitPrope= rties(LazyClassDescriptorDecorator.java:174) >> at org.apache.cayenne.access.ObjectDiff.(ObjectDiff.java:92) >> at org.apache.cayenne.access.ObjectStore.registerDiff(ObjectStore.jav= a:224) >> at org.apache.cayenne.access.ObjectStore.arcCreated(ObjectStore.java:= 983) >> at org.apache.cayenne.util.ObjectContextGraphAction.handleArcProperty= Change(ObjectContextGraphAction.java:88) >> at org.apache.cayenne.util.ObjectContextGraphAction.handlePropertyCha= nge(ObjectContextGraphAction.java:65) >> at org.apache.cayenne.BaseContext.propertyChanged(BaseContext.java:47= 7) >> at org.apache.cayenne.CayenneDataObject.addToManyTarget(CayenneDataOb= ject.java:251) >> at org.apache.cayenne.CayenneDataObject.setReverseRelationship(Cayenn= eDataObject.java:337) >> at org.apache.cayenne.CayenneDataObject.setToOneTarget(CayenneDataObj= ect.java:288) >> at com.xyz.cayenne.ebpp.entity.generated._ScheduledPayment.setAccount= (_ScheduledPayment.java:736) >> >