Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 7195 invoked from network); 1 May 2009 06:48:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 1 May 2009 06:48:52 -0000 Received: (qmail 18031 invoked by uid 500); 1 May 2009 06:48:52 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 17916 invoked by uid 500); 1 May 2009 06:48:51 -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 17904 invoked by uid 99); 1 May 2009 06:48:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 May 2009 06:48:51 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lachlan.deck@gmail.com designates 209.85.198.246 as permitted sender) Received: from [209.85.198.246] (HELO rv-out-0708.google.com) (209.85.198.246) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 May 2009 06:48:43 +0000 Received: by rv-out-0708.google.com with SMTP id c5so127314rvf.4 for ; Thu, 30 Apr 2009 23:48:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:cc:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-mailer; bh=gUcEbCBl1dxHdv6LeeGslEXLuXoP0/YpjGSSd89WdbE=; b=F27wR+Ouzhj0NX2ChGL4Wv8YqVxFoddQBNMqK5EBFRszJxkhNcbfwOBLmcyUQUp4WP bSI2oE6O3++UH2B+ITHbZmxRsTpzBf9dE5OayOavZoiikpsjqaKjr8pjxmrpqjtK6ins /usEUnBuVRYQYA8BbLgX4GSSJFBONVvMcm5lg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=cc:message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-mailer; b=tu3PxUKFRGJP/5eIIug+iBeieKl8vzkH7syXxTCBW0lJ7GpuoYbsLxXtxUhQIXFjIl KRduv5G7pYTdgiAyjWs0c74exDIJtXh/76N6KSQseTmwjo2KaTZ0EW3I0v2lsQLYqvaT JNQE7pVzJIc5TMbd+RZERNeBbvmeHIeC2O8Vk= Received: by 10.114.95.1 with SMTP id s1mr1976500wab.20.1241160502917; Thu, 30 Apr 2009 23:48:22 -0700 (PDT) Received: from ip-144.ish.com.au (ip-144.ish.com.au [203.29.62.144]) by mx.google.com with ESMTPS id l30sm4115445waf.35.2009.04.30.23.48.20 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 30 Apr 2009 23:48:21 -0700 (PDT) Cc: user@cayenne.apache.org Message-Id: From: Lachlan Deck To: Andrus Adamchik In-Reply-To: <80C23D1D-1BFC-4662-8805-E105ED09019C@gmail.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.3) Subject: Re: restricting qualifiers turned off? Date: Fri, 1 May 2009 16:48:16 +1000 References: <076EA6B3-1A21-40B8-9E8D-E9B09A742344@gmail.com> <3219fff70811110400o6c6d4dael4917121a6ecfcc4b@mail.gmail.com> <3219fff70811110415s73f8ab8cx4588b6432c6ad2af@mail.gmail.com> <0D4952ED-ED41-44DB-9812-C011BE09F4F2@objectstyle.org> <3219fff70811110657t174e31b2jea192d8b297b1a48@mail.gmail.com> <80C23D1D-1BFC-4662-8805-E105ED09019C@gmail.com> X-Mailer: Apple Mail (2.930.3) X-Virus-Checked: Checked by ClamAV on apache.org Hi there, any input? On 29/04/2009, at 3:16 PM, Lachlan Deck wrote: > Resurrecting this thread... > > On 12/11/2008, at 1:57 AM, Andrey Razumovsky wrote: > >> Thanks, it works! Here's the snippet: >> >> String cloneName = objEntity.getName() + "_no_qualifier"; >> ObjEntity clone = dataMap.getObjEntity(cloneName); >> if (clone == null) { >> clone = new ObjEntity(cloneName); >> clone.setDbEntity(objEntity.getDbEntity()); >> objEntity.getDataMap().addObjEntity(clone); >> } >> >> Works on every Cayenne > > Isn't there more to it than this? > > What javaClass are you mapping to? I didn't think the cloned > objentity could map to the same java class (given that the map > allows you to look up via javaclass). And what about > relationships .. do you need to recursively re-define relations so > that they also map to a similarly cloned entity? > > I'm about to attempt to do this as listed below[1] .. so any > feedback welcome. > >> 2008/11/11, Andrus Adamchik : >>> On Nov 11, 2008, at 2:15 PM, Andrey Razumovsky wrote: >>> >>> ObjEntity clone = (ObjEntity) SerializationUtils.clone(objEntity); >>>> clone.setDeclaredQualifier(null); >>>> SelectQuery query = new SelectQuery(clone); >>>> >>> >>> In addition you'll need to rename the entity and register it with >>> the >>> DataMap. So you might as well map an alt. entity via the Modeler. >>> >>> Or use a separate stack all together to work with a parallel set of >>> entities without qualifiers. > > Andrus, any clues on how one goes about creating a separate stack? i.e., at runtime... > Is there a simple way of finding the default stack and cloning it so > as to recurse through the entities to turn off the declared qual? > > with regards, > -- > > Lachlan Deck > > [1] any improvements welcome... > > private static synchronized ObjEntity > registeredNonRestrictingForObjEntity(DataMap map, ObjEntity > originalEntity) { > String cloneName = originalEntity.getName() + "_nonRestricting"; > ObjEntity cloneEntity = map.getObjEntity(cloneName); > if (cloneEntity == null) { > cloneEntity = new ObjEntity(cloneName); > cloneEntity.setDbEntity(originalEntity.getDbEntity()); > cloneEntity.setDeclaredQualifier(null); > cloneEntity.setClassName(originalEntity.getClassName() + > "$NonRestricting"); > > // define attributes > cloneEntity.clearAttributes(); > for (Entry attribute : > originalEntity.getAttributeMap().entrySet()) { > ObjAttribute att = (ObjAttribute) > SerializationUtils.clone(attribute.getValue()); > att.setEntity(cloneEntity); > cloneEntity.addAttribute(att); > } > > map.addObjEntity(cloneEntity); > > // define relations > cloneEntity.clearRelationships(); > SortedMap relations = > cloneEntity.getRelationshipMap(); > if (relations != null) { > for (Entry relation : > relations.entrySet()) { > ObjRelationship rel = relation.getValue(); > ObjEntity targetEntity = > registeredNonRestrictingForObjEntity(map, (ObjEntity) > relation.getValue().getTargetEntity()); > > ObjRelationship relationClone = (ObjRelationship) > SerializationUtils.clone(rel); > relationClone.setTargetEntity(targetEntity); > cloneEntity.removeRelationship(relation.getKey()); > cloneEntity.addRelationship(relationClone); > } > } > } > return cloneEntity; > } > with regards, -- Lachlan Deck