Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 96345 invoked from network); 8 Jul 2009 06:45:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 8 Jul 2009 06:45:40 -0000 Received: (qmail 84029 invoked by uid 500); 8 Jul 2009 06:45:50 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 84008 invoked by uid 500); 8 Jul 2009 06:45:50 -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 83997 invoked by uid 99); 8 Jul 2009 06:45:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Jul 2009 06:45:50 +0000 X-ASF-Spam-Status: No, hits=2.8 required=10.0 tests=HTML_FONT_FACE_BAD,HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lawgers@gmail.com designates 209.85.210.194 as permitted sender) Received: from [209.85.210.194] (HELO mail-yx0-f194.google.com) (209.85.210.194) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Jul 2009 06:45:41 +0000 Received: by yxe32 with SMTP id 32so7150239yxe.26 for ; Tue, 07 Jul 2009 23:45:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=388PtMHIacehP6SuhuFjda2EPaBwg6HWu4epNzPPg3w=; b=PJCjo25EY7PHuy+k+8OXDva5UTEAzj/rl/jBFj9a0BUpiKKzTherPWm/AQks5b6iki e7wVhOP98bG7fC3/0B9aQrLOYVWm0/tnWcDJKyH8LsHOMvlntMKog2pNrcrOm0PE6yvm CK0WmW8TJpaWZPQYyP3eEx2ESDgiKA8roqE/Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=JoLB474temLRH/Ocx6A0i2peugjPCSxR49iB6Gr+s6gm3WqRQV99kTQHaX9lY+WbqQ YplSNpuIrpAU+q60gjC2Kgfx7i/qWxamAasoPcMPfRd6Pgdk4DUYl+/BSdY0pDUurHtP 8T7aJG/zF8AhuqLWintjYzI4jXRessfjtija0= MIME-Version: 1.0 Received: by 10.90.25.11 with SMTP id 11mr1031636agy.44.1247035520901; Tue, 07 Jul 2009 23:45:20 -0700 (PDT) In-Reply-To: <47e96cf20906041001y525f56dai93dcc217fa8e7bab@mail.gmail.com> References: <454CEC49-73B5-4820-BB97-A1E70740BBC8@gmail.com> <3219fff70906040421j67aae1c4p565319c9dd22d031@mail.gmail.com> <47e96cf20906041001y525f56dai93dcc217fa8e7bab@mail.gmail.com> Date: Wed, 8 Jul 2009 00:45:20 -0600 Message-ID: <47e96cf20907072345h58e5ae61g5cdadbb614e6776a@mail.gmail.com> Subject: Re: Creating multiple datamaps on the fly From: Lawrence Gerstley To: user@cayenne.apache.org Content-Type: multipart/alternative; boundary=00163630e99f3ee349046e2c1533 X-Virus-Checked: Checked by ClamAV on apache.org --00163630e99f3ee349046e2c1533 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hello, Some time ago, I asked about creating multiple datamaps by cloning an existing one, which worked fine initially, and now I find an odd hiccup when using the cloned datamap for something more involved than a simple SelectQuery. When I try to perform a query with a simple "likeIgnoreCaseExp", I get the following exception: *No reverse relationship exist for org.apache.cayenne.map.DbRelationship@8ddb93 [name=toSourceEntity,toMany=false]* When I debug my cloning code, part of it cycles through the DbEntities with this method: public DbEntity cloneDbEntity(DbEntity originalDbEntity, String newDbEntityName) { DbEntity returnDbEntity = new DbEntity(newDbEntityName); returnDbEntity.setSchema(originalDbEntity.getSchema()); returnDbEntity.setCatalog(originalDbEntity.getCatalog()); for (DbAttribute dbAttribute : originalDbEntity.getAttributes()) { returnDbEntity.addAttribute(dbAttribute); } for (DbRelationship dbRelationship : originalDbEntity.getRelationships()) { returnDbEntity.addRelationship(dbRelationship); } return returnDbEntity; } When I look at the dbRelationships that are iterated through, each have a properly defined reverseRelationship. When I inspect the returnDbEntity that is produced, I get the exception: Entity 'assoc' has no parent MappingNamespace (such as DataMap) This error may be nothing--the map appears to work, but I'm still stymied by the lack of a reverse relationship when I go to execute the SelectQuery. Can anyone tell what I am missing here? Is there a better example of cloning a DataMap? Thanks, Lawrence On Thu, Jun 4, 2009 at 11:01 AM, Lawrence Gerstley wrote: > ---------- Forwarded message ---------- > From: Andrey Razumovsky > Date: Thu, Jun 4, 2009 at 4:21 AM > Subject: Re: Creating multiple datamaps on the fly > To: user@cayenne.apache.org > > > Hi, > > I'm not sure that I correctly understood your problem, but cloning datamap > is definitely possible. Alas, I don't know about any ready methods for > that. > You can either clone DataMap manually (i.e. create new map with new name, > copy properties from original map, put there entities etc. with new names > and then attach it to domain) or clone whole datamap via serialization and > then change names of its "entries". Sort of second way is implemented in > modeler's PasteAction.paste(...). Note that entity names must be unique in > whole DataDomain. > > Andrey > > 2009/6/4 Lawrence Gerstley > > > Hello, > > > > I'm trying to create multiple DataMaps and attach them to my DataDomain > on > > the fly in an application. The DataMap itself that I created with the > > modeler is fine, but I want to be able to create new ones on demand to > point > > to a new table set in my db. So, my DataMap might consist of DbEntities > > whose prefixes all start with "lba1_". I can iterate through the map > > attached to the domain loaded up like so: > > ================================================================ > > for (DbEntity entity : currentMap.getDbEntities()) { > > if (entity.getName().indexOf("_") > 0) { > > entity.setName(entity.getName().replaceFirst(".*_", instancePrefix + > > "_")); > > } > > } > > ================================================================ > > I'd like to clone the DataMap and then iterate through it with the code > > above, and then add that DataMap to the DataDomain. Is that possible? > > > > Thanks, > > > > Lawrence > > > > > > > > -- > ============================ > Lawrence Gerstley, Ph.D. > PSMI Consulting > > Cel: 415.694-0844 > -- ============================ Lawrence Gerstley, Ph.D. PSMI Consulting Cel: 415.694-0844 --00163630e99f3ee349046e2c1533--