From edwardbrown@example.com Tue Jan 06 01:57:58 2009 Return-Path: <edwardbrown@example.com> Delivered-To: edwardbrown@example.com Received: (qmail 38917 invoked from network); 6 Jan 2009 01:57:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 6 Jan 2009 01:57:58 -0000 Received: (qmail 10669 invoked by uid 500); 6 Jan 2009 01:57:57 -0000 Delivered-To: edwardbrown@example.com Received: (qmail 10656 invoked by uid 500); 6 Jan 2009 01:57:57 -0000 Mailing-List: contact edwardbrown@example.com; run by ezmlm Precedence: bulk List-Help: <mailto:edwardbrown@example.com> List-Unsubscribe: <mailto:edwardbrown@example.com> List-Post: <mailto:edwardbrown@example.com> List-Id: <user.cayenne.apache.org> Reply-To: edwardbrown@example.com Delivered-To: mailing list edwardbrown@example.com Received: (qmail 10645 invoked by uid 99); 6 Jan 2009 01:57:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Jan 2009 17:57:57 -0800 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of edwardbrown@example.com designates 83.161.120.155 as permitted sender) Received: from [83.161.120.155] (HELO an-out-0708.google.com) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Jan 2009 01:57:49 +0000 Received: by an-out-0708.google.com with SMTP id c38so3184417ana.37 for <edwardbrown@example.com>; Mon, 05 Jan 2009 17:57:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :content-type:mime-version:subject:date:x-mailer; bh=l+IYRxgIQCAaVAhYoAX+FFC55C0ab16OgNN6ojiDE14=; b=PiDYek3RXFvjKxlQZokyrL8X12paNdwsp31Kf0o8LJ6pJAFnQN1t7tJJbog2h2baau ptRftpFkNSQfgMqmo5yocGempAjdHyQP5yenpI/GFE/wyTbNlzdIn4iaLz3USSrHUHxU 6zMM22pYovonQnxUzP2BzFtdvnDLOrX9BNjkw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:content-type:mime-version:subject:date:x-mailer; b=lTy5HYk8fys6+Jn/RZR2Su1UXxxGL4ezaHQykSL73ceIRUU2uexXD8wr6FLM3yR3qe 8QwIZ7wdWqbJjxdrQps3bkWSrR+YMZ+2xPoCQ8vgVPaicUe3dcah+WVxw4IJQiYLHbpL tPsxHY0UyC3y4cJNaAJ7Fn95vW47TBv4scU4s= Received: by 83.161.120.155 with SMTP id n15mr11729697qba.88.1231207048379; Mon, 05 Jan 2009 17:57:28 -0800 (PST) Received: from ?83.161.120.155? ([83.161.120.155]) by mx.google.com with ESMTPS id 12sm5528685qbw.9.283.161.120.155.57.26 (version=SSLv3 cipher=RC4-MD5); Mon, 05 Jan 2009 17:57:27 -0800 (PST) Message-Id: <edwardbrown@example.com> From: Lawrence Gerstley <edwardbrown@example.com> To: edwardbrown@example.com Content-Type: multipart/alternative; boundary=Apple-Mail-32--503225105 Mime-Version: 1.0 (Apple Message framework v930.3) Subject: Changing database schemas at runtime Date: Mon, 5 Jan 2009 17:57:25 -0800 X-Mailer: Apple Mail (2.930.3) X-Virus-Checked: Checked by ClamAV on apache.org --Apple-Mail-32--503225105 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Hello, I've been using Cayenne and allowing for changing backends at runtime-- representing the same schema in MySQL, Oracle, Apache Derby, and have had success changing the backend with: DataSource dataSource = new PoolManager( jdbcDriverDetails.getDriverClass(), myURL, 1, 5, myUser, myPassword); Configuration config = Configuration.getSharedConfiguration(); DataDomain domain = config.getDomain(); DataNode node = domain.getNode("MyDomain"); node.setDataSource(dataSource); My problem is that I need to also allow a user to select the schema that the datamap should be applied to. For example, in Oracle, the same schema design might be in multiple instances (in my example, KTMI3D, KTMI3M, KTMI3X, etc.). I can change these with the modeler and have it work, but I need to change edwardbrown@example.com. I've tried changing it with: dataMap.setDefaultSchema(schema); But haven't had much luck edwardbrown@example.com. Is there some way to do this with my approach, or is there a better approach to take if you want to switch back-ends multiple time at runtime? Thanks for reading, Lawrence --Apple-Mail-32--503225105-- From edwardbrown@example.com Tue Jan 06 07:12:17 2009 Return-Path: <edwardbrown@example.com> Delivered-To: edwardbrown@example.com Received: (qmail 38058 invoked from network); 6 Jan 2009 07:12:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 6 Jan 2009 07:12:17 -0000 Received: (qmail 50460 invoked by uid 500); 6 Jan 2009 07:12:16 -0000 Delivered-To: edwardbrown@example.com Received: (qmail 50447 invoked by uid 500); 6 Jan 2009 07:12:16 -0000 Mailing-List: contact edwardbrown@example.com; run by ezmlm Precedence: bulk List-Help: <mailto:edwardbrown@example.com> List-Unsubscribe: <mailto:edwardbrown@example.com> List-Post: <mailto:edwardbrown@example.com> List-Id: <user.cayenne.apache.org> Reply-To: edwardbrown@example.com Delivered-To: mailing list edwardbrown@example.com Received: (qmail 50436 invoked by uid 99); 6 Jan 2009 07:12:16 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Jan 2009 23:12:16 -0800 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: local policy) Received: from [83.161.120.155] (HELO vorsha.objectstyle.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 06 Jan 2009 07:12:09 +0000 Received: (qmail 12066 invoked from network); 6 Jan 2009 07:11:48 -0000 Received: from unknown (HELO ?IPv888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4:1?) (83.161.120.155) by localhost with SMTP; 6 Jan 2009 07:11:48 -0000 Message-Id: <edwardbrown@example.com> From: Andrus Adamchik <edwardbrown@example.com> To: edwardbrown@example.com In-Reply-To: <edwardbrown@example.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v929.2) Subject: Re: Changing database schemas at runtime Date: Tue, 6 Jan 2009 09:11:47 +0200 References: <edwardbrown@example.com> X-Mailer: Apple Mail (2.929.2) X-Virus-Checked: Checked by ClamAV on apache.org Hi Lawrence, Yeah, the "default schema" is ignored in runtime, and only per DbEntity schema is consulted. Looking back, it would've been better to use the default if DbEntity schema is not set, and we may change the behavior at some point, but for now "default schema" is only used by the Modeler. So to change schema you would need to iterate through all DbEntities and set it per entity. Andrus On Jan 6, 2009, at 3:57 AM, Lawrence Gerstley wrote: > Hello, > > I've been using Cayenne and allowing for changing backends at > runtime--representing the same schema in MySQL, Oracle, Apache > Derby, and have had success changing the backend with: > > DataSource dataSource = new PoolManager( > jdbcDriverDetails.getDriverClass(), > myURL, > 1, > 5, > myUser, > myPassword); > Configuration config = > Configuration.getSharedConfiguration(); > DataDomain domain = config.getDomain(); > DataNode node = domain.getNode("MyDomain"); > node.setDataSource(dataSource); > > My problem is that I need to also allow a user to select the schema > that the datamap should be applied to. For example, in Oracle, the > same schema design might be in multiple instances (in my example, > KTMI3D, KTMI3M, KTMI3X, etc.). I can change these with the modeler > and have it work, but I need to change edwardbrown@example.com. I've tried > changing it with: > > dataMap.setDefaultSchema(schema); > > But haven't had much luck edwardbrown@example.com. Is there some way to > do this with my approach, or is there a better approach to take if > you want to switch back-ends multiple time at runtime? > > Thanks for reading, > > Lawrence > > From edwardbrown@example.com Tue Jan 06 20:38:12 2009 Return-Path: <edwardbrown@example.com> Delivered-To: edwardbrown@example.com Received: (qmail 15997 invoked from network); 6 Jan 2009 20:38:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 6 Jan 2009 20:38:12 -0000 Received: (qmail 39005 invoked by uid 500); 6 Jan 2009 20:38:12 -0000 Delivered-To: edwardbrown@example.com Received: (qmail 38854 invoked by uid 500); 6 Jan 2009 20:38:11 -0000 Mailing-List: contact edwardbrown@example.com; run by ezmlm Precedence: bulk List-Help: <mailto:edwardbrown@example.com> List-Unsubscribe: <mailto:edwardbrown@example.com> List-Post: <mailto:edwardbrown@example.com> List-Id: <user.cayenne.apache.org> Reply-To: edwardbrown@example.com Delivered-To: mailing list edwardbrown@example.com Received: (qmail 38843 invoked by uid 99); 6 Jan 2009 20:38:10 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Jan 2009 12:38:10 -0800 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of edwardbrown@example.com designates 83.161.120.155 as permitted sender) Received: from [83.161.120.155] (HELO yx-out-1718.google.com) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Jan 2009 20:38:02 +0000 Received: by yx-out-1718.google.com with SMTP id 3so2974813yxi.82 for <edwardbrown@example.com>; Tue, 06 Jan 2009 12:37:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :in-reply-to:content-type:mime-version:subject:date:references :x-mailer; bh=iP/rUBV5kiHiKOdg/pHOKX7TcyFmjAno80rIxNVPiHw=; b=Dq+bAUyOTp3F8x4/4/htsGO/RH6c9MRcLe3HmrmnPL/RQfrWsVodBV2DQYqMwLFewk sTgWAOVXjE0K/Yzzw/vSDFqILkvbqUdy9cNkFa58tyV0+6wFVWda/+ZYX67631VlCv8h m8HxXml25bK94JSONzfQW4jbQCf+BVQjJBB00= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:in-reply-to:content-type:mime-version:subject :date:references:x-mailer; b=IFj2nNxvozxs52yvCr3zvnm8k5sW3Ioxb4uU0SGWGtkHvAzmU2Ud8IDam3jIWc2EQM n/GC6Fu63UstirRBzd0+gVCiD69mDCv8ozaxyDdgVlI6CWFkxlNKgoR4pMVQYsE/unYi UISEdCs/nHRFOKUOlt0++89M2Cxpc71lU1pvQ= Received: by 83.161.120.155 with SMTP id t19mr16651473qbp.61.1231274261409; Tue, 06 Jan 2009 12:37:41 -0800 (PST) Received: from ?83.161.120.155? ([83.161.120.155]) by mx.google.com with ESMTPS id p27sm48206995qbp.12.283.161.120.155.37.39 (version=SSLv3 cipher=RC4-MD5); Tue, 06 Jan 2009 12:37:40 -0800 (PST) Message-Id: <edwardbrown@example.com> From: Lawrence Gerstley <edwardbrown@example.com> To: edwardbrown@example.com In-Reply-To: <edwardbrown@example.com> Content-Type: multipart/alternative; boundary=Apple-Mail-43--436012124 Mime-Version: 1.0 (Apple Message framework v930.3) Subject: Re: Changing database schemas at runtime Date: Tue, 6 Jan 2009 12:37:38 -0800 References: <edwardbrown@example.com> <edwardbrown@example.com> X-Mailer: Apple Mail (2.930.3) X-Virus-Checked: Checked by ClamAV on apache.org --Apple-Mail-43--436012124 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit This worked great. Thanks for the tip. public boolean setDataMapSchema(DataMap dataMap, String schema) { try { for (DbEntity dbEntity : dataMap.getDbEntities()) { dbEntity.setSchema(schema); } } catch (Exception e) { System.out.println(e.toString()); return false; } return true; } Lawrence On Jan 5, 2009, at 11:11 PM, Andrus Adamchik wrote: > Hi Lawrence, > > Yeah, the "default schema" is ignored in runtime, and only per > DbEntity schema is consulted. Looking back, it would've been better > to use the default if DbEntity schema is not set, and we may change > the behavior at some point, but for now "default schema" is only > used by the Modeler. > > So to change schema you would need to iterate through all DbEntities > and set it per entity. > > Andrus > > On Jan 6, 2009, at 3:57 AM, Lawrence Gerstley wrote: > >> Hello, >> >> I've been using Cayenne and allowing for changing backends at >> runtime--representing the same schema in MySQL, Oracle, Apache >> Derby, and have had success changing the backend with: >> >> DataSource dataSource = new PoolManager( >> jdbcDriverDetails.getDriverClass(), >> myURL, >> 1, >> 5, >> myUser, >> myPassword); >> Configuration config = >> Configuration.getSharedConfiguration(); >> DataDomain domain = config.getDomain(); >> DataNode node = domain.getNode("MyDomain"); >> node.setDataSource(dataSource); >> >> My problem is that I need to also allow a user to select the schema >> that the datamap should be applied to. For example, in Oracle, the >> same schema design might be in multiple instances (in my example, >> KTMI3D, KTMI3M, KTMI3X, etc.). I can change these with the modeler >> and have it work, but I need to change edwardbrown@example.com. I've tried >> changing it with: >> >> dataMap.setDefaultSchema(schema); >> >> But haven't had much luck edwardbrown@example.com. Is there some way to >> do this with my approach, or is there a better approach to take if >> you want to switch back-ends multiple time at runtime? >> >> Thanks for reading, >> >> Lawrence >> >> > --Apple-Mail-43--436012124-- From edwardbrown@example.com Wed Jan 07 09:37:31 2009 Return-Path: <edwardbrown@example.com> Delivered-To: edwardbrown@example.com Received: (qmail 864 invoked from network); 7 Jan 2009 09:37:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 7 Jan 2009 09:37:31 -0000 Received: (qmail 11312 invoked by uid 500); 7 Jan 2009 09:37:30 -0000 Delivered-To: edwardbrown@example.com Received: (qmail 11296 invoked by uid 500); 7 Jan 2009 09:37:30 -0000 Mailing-List: contact edwardbrown@example.com; run by ezmlm Precedence: bulk List-Help: <mailto:edwardbrown@example.com> List-Unsubscribe: <mailto:edwardbrown@example.com> List-Post: <mailto:edwardbrown@example.com> List-Id: <user.cayenne.apache.org> Reply-To: edwardbrown@example.com Delivered-To: mailing list edwardbrown@example.com Received: (qmail 11285 invoked by uid 99); 7 Jan 2009 09:37:30 -0000 Received: from nike.apache.org (HELO nike.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jan 2009 01:37:30 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of edwardbrown@example.com designates 83.161.120.155 as permitted sender) Received: from [83.161.120.155] (HELO fish.ish.com.au) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jan 2009 09:37:21 +0000 Received: from ip-211.ish.com.au ([83.161.120.155]:55914 helo=ish.com.au) by fish.ish.com.au with esmtp (Exim 4.69) (envelope-from <edwardbrown@example.com>) id 1LKVQh-00045q-3A for edwardbrown@example.com; Wed, 07 Jan 2009 21:14:27 +1100 Received: from [83.161.120.155] (account edwardbrown@example.com) by ish.com.au (CommuniGate Pro WEBUSER 5.2.11) with HTTP id 4342614 for edwardbrown@example.com; Wed, 07 Jan 2009 20:36:54 +1100 From: "Marcin Skladaniec" <edwardbrown@example.com> Subject: Single table inheritance and field hiding To: edwardbrown@example.com X-Mailer: CommuniGate Pro WebUser v5.2.11 Date: Wed, 07 Jan 2009 19:36:54 +1000 Message-ID: <edwardbrown@example.com> In-Reply-To: <edwardbrown@example.com> References: <edwardbrown@example.com> <edwardbrown@example.com> <edwardbrown@example.com> MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1;format="flowed" Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org Hi I have created a schema with single table inheritance. It looks something like this: 'Product' is the table, database entity, and abstract object entity. There are few subclasses of the Product, each has its own unique attributes and relationships. Product: id name description type (Article, Membership etc.) Article weight Membership: expiryDays since all the attributes are defined in the same DbEntity CayenneModeller by default put them all into Product ObjEntity. I wanted to hide them in the superclass, so I moved to relevant ObjEntities. Cayenne does not complain when creating records. If I then execute a simple paged query it works properly: [java] 07 Jan 2009 19:15:40,619 [btpool0-0 ] INFO org.apache.cayenne.access.QueryLogger :357 - SELECT t0.id FROM Product t0 WHERE (t0.isDeleted IS NULL) OR (t0.isDeleted = ?) OR (t0.type = ?) OR (t0.type = ?) OR (t0.type = ?) ORDER BY t0.name [bind: 1->isDeleted:0, 2->type:1, 3->type:2, 4->type:3] [java] 07 Jan 2009 19:15:40,629 [btpool0-0 ] INFO org.apache.cayenne.access.QueryLogger :401 - === returned 1 row. - took 16 ms. [java] 07 Jan 2009 19:15:40,629 [btpool0-0 ] INFO org.apache.cayenne.access.QueryLogger :434 - +++ transaction committed. but once the record is about to be faulted it fails [java] 07 Jan 2009 19:15:40,635 [btpool0-0 ] INFO org.apache.cayenne.access.QueryLogger :357 - SELECT t0.id, t0.modifiedOn, t0.type, t0.notes, t0.isDeleted, t0.isWebVisible, t0.willowId, t0.incomeAccountId, t0.description, t0.taxId, t0.isOnSale, t0.priceExTax, t0.createdOn, t0.name, t0.SKU, t0.weight, t0.expiryDays, t0.expiryType, t0.value, t0.liabilityAccountId FROM Product t0 WHERE (t0.id = ?) AND ((t0.isDeleted IS NULL) OR (t0.isDeleted = ?) OR (t0.type = ?) OR (t0.type = ?) OR (t0.type = ?)) [bind: 1->id:200, 2->isDeleted:0, 3->type:1, 4->type:2, 5->type:3] [java] 07 Jan 2009 19:15:40,666 [btpool0-0 ] INFO org.apache.cayenne.access.QueryLogger :453 - *** error. [java] java.lang.NullPointerException [java] at org.apache.cayenne.exp.parser.SimpleNode.evaluateChild(SimpleNode.java:315) [java] at org.apache.cayenne.exp.parser.ASTEqual.evaluateNode(ASTEqual.java:61) [java] at org.apache.cayenne.exp.parser.SimpleNode.evaluate(SimpleNode.java:327) [java] at org.apache.cayenne.exp.parser.SimpleNode.evaluateChild(SimpleNode.java:315) [java] at org.apache.cayenne.exp.parser.ASTOr.evaluateNode(ASTOr.java:69) [java] at org.apache.cayenne.exp.parser.SimpleNode.evaluate(SimpleNode.java:327) [java] at org.apache.cayenne.exp.Expression.match(Expression.java:367) [java] at org.apache.cayenne.map.EntityInheritanceTree.entityMatchingRow(EntityInheritanceTree.java:92) [java] at org.apache.cayenne.access.jdbc.DataRowPostProcessor.getOverrides(DataRowPostProcessor.java:147) [java] at org.apache.cayenne.access.jdbc.DataRowPostProcessor.postprocessRow(DataRowPostProcessor.java:128) [java] at org.apache.cayenne.access.jdbc.InheritanceAwareRowReader.postprocessRow(InheritanceAwareRowReader.java:45) [java] at org.apache.cayenne.access.jdbc.FullRowReader.readRow(FullRowReader.java:54) [java] at org.apache.cayenne.access.jdbc.FullRowReader.readRow(FullRowReader.java:31) [java] at org.apache.cayenne.access.jdbc.JDBCResultIterator.nextRow(JDBCResultIterator.java:194) [java] at org.apache.cayenne.access.jdbc.JDBCResultIterator.allRows(JDBCResultIterator.java:171) [java] at org.apache.cayenne.access.jdbc.SelectAction.performAction(SelectAction.java:155) [java] at org.apache.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryAction.java:87) [java] at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:236) [java] at org.apache.cayenne.access.DataDomainQueryAction.runQuery(DataDomainQueryAction.java:422) [java] at org.apache.cayenne.access.DataDomainQueryAction.access$000(DataDomainQueryAction.java:66) [java] at org.apache.cayenne.access.DataDomainQueryAction$2.transform(DataDomainQueryAction.java:395) [java] at org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:846) [java] at org.apache.cayenne.access.DataDomainQueryAction.runQueryInTransaction(DataDomainQueryAction.java:392) [java] at org.apache.cayenne.access.DataDomainQueryAction.execute(DataDomainQueryAction.java:118) [java] at org.apache.cayenne.access.DataDomain.onQuery(DataDomain.java:739) [java] at org.apache.cayenne.util.ObjectContextQueryAction.runQuery(ObjectContextQueryAction.java:316) [java] at org.apache.cayenne.util.ObjectContextQueryAction.execute(ObjectContextQueryAction.java:95) [java] at org.apache.cayenne.access.DataContext.onQuery(DataContext.java:1267) [java] at org.apache.cayenne.access.DataContext.performQuery(DataContext.java:1256) [java] at org.apache.cayenne.access.IncrementalFaultList.resolveInterval(IncrementalFaultList.java:295) [java] at org.apache.cayenne.access.IncrementalFaultList.get(IncrementalFaultList.java:550) [java] at org.apache.cayenne.access.IncrementalFaultList$1.next(IncrementalFaultList.java:467) [java] at org.apache.cayenne.access.ClientServerChannelQueryAction.toClientObjects(ClientServerChannelQueryAction.java:187) Is my design correct? can I hide the attributes from the superclass and expose them only in the subclass? Thanks Marcin From edwardbrown@example.com Wed Jan 07 14:05:23 2009 Return-Path: <edwardbrown@example.com> Delivered-To: edwardbrown@example.com Received: (qmail 14219 invoked from network); 7 Jan 2009 14:05:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 7 Jan 2009 14:05:23 -0000 Received: (qmail 18526 invoked by uid 500); 7 Jan 2009 14:05:22 -0000 Delivered-To: edwardbrown@example.com Received: (qmail 18512 invoked by uid 500); 7 Jan 2009 14:05:22 -0000 Mailing-List: contact edwardbrown@example.com; run by ezmlm Precedence: bulk List-Help: <mailto:edwardbrown@example.com> List-Unsubscribe: <mailto:edwardbrown@example.com> List-Post: <mailto:edwardbrown@example.com> List-Id: <user.cayenne.apache.org> Reply-To: edwardbrown@example.com Delivered-To: mailing list edwardbrown@example.com Received: (qmail 18501 invoked by uid 99); 7 Jan 2009 14:05:22 -0000 Received: from nike.apache.org (HELO nike.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jan 2009 06:05:22 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of edwardbrown@example.com designates 83.161.120.155 as permitted sender) Received: from [83.161.120.155] (HELO wa-out-1112.google.com) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jan 2009 14:05:12 +0000 Received: by wa-out-1112.google.com with SMTP id k22so4526994waf.20 for <edwardbrown@example.com>; Wed, 07 Jan 2009 06:04:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:message-id :in-reply-to:subject:mime-version:content-type :content-transfer-encoding; bh=oIrE6iClDGLscUrAMorr84NQmC07SHWELY8jTNQuXtE=; b=HCGCSYZ8MuzdC+qrD2iVO6j3ARr4LyaUvlsCGdyoYz9ngkrY/VZ5iZgf/GOBBYE+t1 3kO9yP1ZfU4e6oXGW958BRkyERfkKMz+UnvioPLelCm6N9/IxUT5HEfcR18vjL3vC7fF waRd/uiQzicbwUj6F83LvBdD/gQGDob6qqIoQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:message-id:in-reply-to:subject:mime-version :content-type:content-transfer-encoding; b=tlXkjiEC2rZE+0hdRGDzu7/gFM4L7LS8UUcaqP+/mnADqf5CwCM8e/eVSaqrPfnL3/ Y2Fja37s3L5X5DuhilyWN2SrHJVaz3PsyqQLHwAutNN8CFKeGJHUeGbfTmRTaMlDFEZw 6rnizXDC7FBS/fkOcDvIiRw81383GlsPwE7Mg= Received: by 83.161.120.155 with SMTP id t2mr15251776wal.224.1231337091688; Wed, 07 Jan 2009 06:04:51 -0800 (PST) Received: from localhost ([83.161.120.155]) by mx.google.com with ESMTPS id z20sm37191890pod.26.283.161.120.155.04.51 (version=SSLv3 cipher=RC4-MD5); Wed, 07 Jan 2009 06:04:51 -0800 (PST) Date: Wed, 7 Jan 2009 07:04:52 -0700 (MST) From: Chad Smith <edwardbrown@example.com> To: edwardbrown@example.com Message-ID: <21291181.211231337090390.JavaMail.SYSTEM@cks-desktop> In-Reply-To: <27383243.191231336871359.JavaMail.SYSTEM@cks-desktop> Subject: A little help w/ session state please MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org I have a web app that uses Cayenne 2.0.4 w/ Spring and it uses a servlet filter to manage the data context ... Request init code -------------------------------- HttpSession session = ((HttpServletRequest)servletRequest).getSession(true); DataContext dataContext = ServletUtil.getSessionContext(session); DataContext.bindThreadDataContext(dataContext); Request destroy code -------------------------------- DataContext dataContext = DataContext.getThreadDataContext(); if (dataContext.hasChanges()) { dataContext.rollbackChanges(); } DataContext.bindThreadDataContext(null); ... I also have a parent table and child table in which the child table has a circular reference to itself parent table: Forum forum.forum_id child table: forum_thread forum_thread.forum_id forum_thread.thread_id forum_thread.parent_thread_id (the circular reference) ... here is the cayenne mapping xml for the relationships ... <db-relationship name="forumToThread" source="forum" target="forum_thread" toMany="true"> <db-attribute-pair source="forum_id" target="forum_id"/> </db-relationship> <db-relationship name="subThreadToThread" source="forum_thread" target="forum_thread" toMany="false"> <db-attribute-pair source="parent_thread_id" target="thread_id"/> </db-relationship> <db-relationship name="threadToForum" source="forum_thread" target="forum" toMany="false"> <db-attribute-pair source="forum_id" target="forum_id"/> </db-relationship> <db-relationship name="threadToSubThread" source="forum_thread" target="forum_thread" toMany="true"> <db-attribute-pair source="thread_id" target="parent_thread_id"/> </db-relationship> <obj-relationship name="forumToThread" source="Forum" target="Thread" deleteRule="Cascade" db-relationship-path="forumToThread"/> <obj-relationship name="subThreadToThread" source="Thread" target="Thread" db-relationship-path="subThreadToThread"/> <obj-relationship name="threadToForum" source="Thread" target="Forum" db-relationship-path="threadToForum"/> <obj-relationship name="threadToSubThread" source="Thread" target="Thread" deleteRule="Cascade" db-relationship-path="threadToSubThread"/> ... here is the code I'm using to delete a thread ... public boolean deleteThread(int threadId) throws DataAccessException { // NOTE: transactions are auto commit unless otherwise specified! Thread thread = loadThread(threadId); // remove any parent association if (thread.getSubThreadToThread() != null) { Thread parentThread = thread.getSubThreadToThread(); parentThread.removeFromThreadToSubThread(thread); } // remove forum association Forum forum = thread.getThreadToForum(); forum.removeFromForumToThread(thread); super.delete(thread); return true; } ... so here is the problem: I setup the following data Forum record which has 3 top level thread records. Lets say thread 2 has several children and several grand children. When I delete one of thread 2's children it does the database deletes perfectly (cascade deletes of the correct grandchildren), however, the gui continues to show the grand children but the child record (that was deleted) is gone. Here is the SQL and the data context looks clean before and after processing .... CayenneDao >>> --------------- Cayenne Context: 2009-01-07 06:49:40 ---------------- - hasChanges = false | isTransactionEventsEnabled = false | isUsingSharedSnapshotCache = true | isValidatingObjectsOnCommit = true 2009-01-07 06:49:40,953 INFO (QueryLogger.java:423) - --- will run 1 query. 2009-01-07 06:49:40,953 INFO (QueryLogger.java:377) - --- transaction started. 2009-01-07 06:49:40,953 INFO (QueryLogger.java:300) - DELETE FROM gtools.forum_thread WHERE thread_id = ? 2009-01-07 06:49:40,953 INFO (QueryLogger.java:322) - [bind: 228] 2009-01-07 06:49:40,968 INFO (QueryLogger.java:368) - === updated 1 row. 2009-01-07 06:49:40,968 INFO (QueryLogger.java:322) - [bind: 227] 2009-01-07 06:49:40,968 INFO (QueryLogger.java:368) - === updated 1 row. 2009-01-07 06:49:40,968 INFO (QueryLogger.java:322) - [bind: 226] 2009-01-07 06:49:40,968 INFO (QueryLogger.java:368) - === updated 1 row. 2009-01-07 06:49:41,015 INFO (QueryLogger.java:384) - +++ transaction committed. CayenneDao >>> --------------- Cayenne Context: 2009-01-07 06:49:41 ---------------- - hasChanges = false | isTransactionEventsEnabled = false | isUsingSharedSnapshotCache = true | isValidatingObjectsOnCommit = true ... no matter where I go w/in the application the data (grand children) seems to stick in the cache but if I log off and back on they are now gone (no longer in the object cache). What am I doing wrong here? I know that is a lot to wade through but I would greatly appreciate any help on diagnosing the problem. Thanks in advance. Chad From edwardbrown@example.com Wed Jan 07 15:33:39 2009 Return-Path: <edwardbrown@example.com> Delivered-To: edwardbrown@example.com Received: (qmail 64633 invoked from network); 7 Jan 2009 15:33:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 7 Jan 2009 15:33:38 -0000 Received: (qmail 89664 invoked by uid 500); 7 Jan 2009 15:33:37 -0000 Delivered-To: edwardbrown@example.com Received: (qmail 89652 invoked by uid 500); 7 Jan 2009 15:33:37 -0000 Mailing-List: contact edwardbrown@example.com; run by ezmlm Precedence: bulk List-Help: <mailto:edwardbrown@example.com> List-Unsubscribe: <mailto:edwardbrown@example.com> List-Post: <mailto:edwardbrown@example.com> List-Id: <user.cayenne.apache.org> Reply-To: edwardbrown@example.com Delivered-To: mailing list edwardbrown@example.com Received: (qmail 89636 invoked by uid 99); 7 Jan 2009 15:33:37 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jan 2009 07:33:37 -0800 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 edwardbrown@example.com designates 83.161.120.155 as permitted sender) Received: from [83.161.120.155] (HELO mail-bw0-f19.google.com) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jan 2009 15:33:31 +0000 Received: by bwz12 with SMTP id 12so26632442bwz.4 for <edwardbrown@example.com>; Wed, 07 Jan 2009 07:33:08 -0800 (PST) Received: by 83.161.120.155 with SMTP id e13mr8331833mur.20.1231342388423; Wed, 07 Jan 2009 07:33:08 -0800 (PST) Received: by 83.161.120.155 with HTTP; Wed, 7 Jan 2009 07:33:08 -0800 (PST) Message-ID: <edwardbrown@example.com> Date: Wed, 7 Jan 2009 07:33:08 -0800 From: "John Armstrong" <edwardbrown@example.com> Sender: edwardbrown@example.com To: edwardbrown@example.com Subject: Re: A little help w/ session state please In-Reply-To: <21291181.211231337090390.JavaMail.SYSTEM@cks-desktop> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <27383243.191231336871359.JavaMail.SYSTEM@cks-desktop> <21291181.211231337090390.JavaMail.SYSTEM@cks-desktop> X-Google-Sender-Auth: 974fa070faf83d7e X-Virus-Checked: Checked by ClamAV on apache.org This I think may be more of a cayenne problem. You have to reload the object to destroy the cayenne cache using something like RefreshQuery. Thats what I have to do in many cases. Like this: context.deleteObject(theFeed); context.commitChanges(); context.commitChangesToParent(); context.performQuery(new RefreshQuery(theFeed)); I may be missing the point entirely, sorry :) John- On Wed, Jan 7, 2009 at 6:04 AM, Chad Smith <edwardbrown@example.com> wrote: > I have a web app that uses Cayenne 2.0.4 w/ Spring and it uses a servlet filter to manage the data context ... > > Request init code > -------------------------------- > HttpSession session = ((HttpServletRequest)servletRequest).getSession(true); > DataContext dataContext = ServletUtil.getSessionContext(session); > DataContext.bindThreadDataContext(dataContext); > > > Request destroy code > -------------------------------- > DataContext dataContext = DataContext.getThreadDataContext(); > if (dataContext.hasChanges()) { > dataContext.rollbackChanges(); > } > DataContext.bindThreadDataContext(null); > > ... I also have a parent table and child table in which the child table has a circular reference to itself > > parent table: Forum > > forum.forum_id > > child table: forum_thread > > forum_thread.forum_id > forum_thread.thread_id > forum_thread.parent_thread_id (the circular reference) > > ... here is the cayenne mapping xml for the relationships ... > > <db-relationship name="forumToThread" source="forum" target="forum_thread" toMany="true"> > <db-attribute-pair source="forum_id" target="forum_id"/> > </db-relationship> > <db-relationship name="subThreadToThread" source="forum_thread" target="forum_thread" toMany="false"> > <db-attribute-pair source="parent_thread_id" target="thread_id"/> > </db-relationship> > <db-relationship name="threadToForum" source="forum_thread" target="forum" toMany="false"> > <db-attribute-pair source="forum_id" target="forum_id"/> > </db-relationship> > <db-relationship name="threadToSubThread" source="forum_thread" target="forum_thread" toMany="true"> > <db-attribute-pair source="thread_id" target="parent_thread_id"/> > </db-relationship> > <obj-relationship name="forumToThread" source="Forum" target="Thread" deleteRule="Cascade" db-relationship-path="forumToThread"/> > <obj-relationship name="subThreadToThread" source="Thread" target="Thread" db-relationship-path="subThreadToThread"/> > <obj-relationship name="threadToForum" source="Thread" target="Forum" db-relationship-path="threadToForum"/> > <obj-relationship name="threadToSubThread" source="Thread" target="Thread" deleteRule="Cascade" db-relationship-path="threadToSubThread"/> > > ... here is the code I'm using to delete a thread ... > > public boolean deleteThread(int threadId) throws DataAccessException { > // NOTE: transactions are auto commit unless otherwise specified! > Thread thread = loadThread(threadId); > > // remove any parent association > if (thread.getSubThreadToThread() != null) { > Thread parentThread = thread.getSubThreadToThread(); > parentThread.removeFromThreadToSubThread(thread); > } > > // remove forum association > Forum forum = thread.getThreadToForum(); > forum.removeFromForumToThread(thread); > > super.delete(thread); > return true; > } > > ... so here is the problem: I setup the following data > > Forum record which has 3 top level thread records. Lets say thread 2 has several children and several grand children. When I delete one of thread 2's children it does the database deletes perfectly (cascade deletes of the correct grandchildren), however, the gui continues to show the grand children but the child record (that was deleted) is gone. Here is the SQL and the data context looks clean before and after processing .... > > CayenneDao >>> --------------- Cayenne Context: 2009-01-07 06:49:40 ---------------- > - hasChanges = false | isTransactionEventsEnabled = false | isUsingSharedSnapshotCache = true | isValidatingObjectsOnCommit = true > 2009-01-07 06:49:40,953 INFO (QueryLogger.java:423) - --- will run 1 query. > 2009-01-07 06:49:40,953 INFO (QueryLogger.java:377) - --- transaction started. > 2009-01-07 06:49:40,953 INFO (QueryLogger.java:300) - DELETE FROM gtools.forum_thread WHERE thread_id = ? > 2009-01-07 06:49:40,953 INFO (QueryLogger.java:322) - [bind: 228] > 2009-01-07 06:49:40,968 INFO (QueryLogger.java:368) - === updated 1 row. > 2009-01-07 06:49:40,968 INFO (QueryLogger.java:322) - [bind: 227] > 2009-01-07 06:49:40,968 INFO (QueryLogger.java:368) - === updated 1 row. > 2009-01-07 06:49:40,968 INFO (QueryLogger.java:322) - [bind: 226] > 2009-01-07 06:49:40,968 INFO (QueryLogger.java:368) - === updated 1 row. > 2009-01-07 06:49:41,015 INFO (QueryLogger.java:384) - +++ transaction committed. > CayenneDao >>> --------------- Cayenne Context: 2009-01-07 06:49:41 ---------------- > - hasChanges = false | isTransactionEventsEnabled = false | isUsingSharedSnapshotCache = true | isValidatingObjectsOnCommit = true > > ... no matter where I go w/in the application the data (grand children) seems to stick in the cache but if I log off and back on they are now gone (no longer in the object cache). What am I doing wrong here? I know that is a lot to wade through but I would greatly appreciate any help on diagnosing the problem. > > Thanks in advance. > Chad > From edwardbrown@example.com Wed Jan 07 15:49:23 2009 Return-Path: <edwardbrown@example.com> Delivered-To: edwardbrown@example.com Received: (qmail 70541 invoked from network); 7 Jan 2009 15:49:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 7 Jan 2009 15:49:23 -0000 Received: (qmail 18054 invoked by uid 500); 7 Jan 2009 15:49:21 -0000 Delivered-To: edwardbrown@example.com Received: (qmail 18040 invoked by uid 500); 7 Jan 2009 15:49:21 -0000 Mailing-List: contact edwardbrown@example.com; run by ezmlm Precedence: bulk List-Help: <mailto:edwardbrown@example.com> List-Unsubscribe: <mailto:edwardbrown@example.com> List-Post: <mailto:edwardbrown@example.com> List-Id: <user.cayenne.apache.org> Reply-To: edwardbrown@example.com Delivered-To: mailing list edwardbrown@example.com Received: (qmail 18029 invoked by uid 99); 7 Jan 2009 15:49:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jan 2009 07:49:21 -0800 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 edwardbrown@example.com designates 83.161.120.155 as permitted sender) Received: from [83.161.120.155] (HELO rv-out-0708.google.com) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jan 2009 15:49:14 +0000 Received: by rv-out-0708.google.com with SMTP id c5so8683822rvf.52 for <edwardbrown@example.com>; Wed, 07 Jan 2009 07:48:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:message-id :in-reply-to:subject:mime-version:content-type :content-transfer-encoding; bh=HLXMS+W4zXjE5GrO6gSLkhVCBIIza2FAJEp6V0P2NMA=; b=OK1VKsUOW9WzyAUlZ/HpWwN/wX7vJY1P0uvYdnWm72nIbRy6NzSHzADbgJ6UWZs76H 4bfn/EaPuwlwIelBefmS/Bf6pnhCGAUcJcYs76hIOxB+tJePl+V/VsfilGRi7xOJSmOK rdkQAbL61QjRMP5wGNwtpIFoaLJrU1v7XYZ74= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:message-id:in-reply-to:subject:mime-version :content-type:content-transfer-encoding; b=sycv1mUR4WygfMZNKKqKK15nkB4f69pItk1RIVO8Ju7shVri+u10hB3uf9g524QxEZ fuR6k6pdGPrE99XTVaTTE8Aehyjlwi2kvLseqXVwhwPdjjQHFg0uIOJ5XHxBDRM+1KRF jmUuB+dzydGNX0dTGj6XsFWe2XLqRsGhKKpnE= Received: by 83.161.120.155 with SMTP id g13mr15337407wah.64.1231343333642; Wed, 07 Jan 2009 07:48:53 -0800 (PST) Received: from localhost ([83.161.120.155]) by mx.google.com with ESMTPS id q20sm27990805pog.22.283.161.120.155.48.52 (version=SSLv3 cipher=RC4-MD5); Wed, 07 Jan 2009 07:48:53 -0800 (PST) Date: Wed, 7 Jan 2009 08:48:54 -0700 (MST) From: Chad Smith <edwardbrown@example.com> To: edwardbrown@example.com Message-ID: <4706100.391231343332859.JavaMail.SYSTEM@cks-desktop> In-Reply-To: <3258719.371231343259875.JavaMail.SYSTEM@cks-desktop> Subject: Re: A little help w/ session state please MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org John, I don't think you are missing the point and that looked promising. But it looks like RefreshQuery is a 3.0 bean and not available in 2.0.4. -Chad ----- Original Message ----- From: "John Armstrong" <edwardbrown@example.com> To: edwardbrown@example.com Sent: Wednesday, January 7, 2009 8:33:08 AM GMT -07:00 US/Canada Mountain Subject: Re: A little help w/ session state please This I think may be more of a cayenne problem. You have to reload the object to destroy the cayenne cache using something like RefreshQuery. Thats what I have to do in many cases. Like this: context.deleteObject(theFeed); context.commitChanges(); context.commitChangesToParent(); context.performQuery(new RefreshQuery(theFeed)); I may be missing the point entirely, sorry :) John- On Wed, Jan 7, 2009 at 6:04 AM, Chad Smith <edwardbrown@example.com> wrote: > I have a web app that uses Cayenne 2.0.4 w/ Spring and it uses a servlet filter to manage the data context ... > > Request init code > -------------------------------- > HttpSession session = ((HttpServletRequest)servletRequest).getSession(true); > DataContext dataContext = ServletUtil.getSessionContext(session); > DataContext.bindThreadDataContext(dataContext); > > > Request destroy code > -------------------------------- > DataContext dataContext = DataContext.getThreadDataContext(); > if (dataContext.hasChanges()) { > dataContext.rollbackChanges(); > } > DataContext.bindThreadDataContext(null); > > ... I also have a parent table and child table in which the child table has a circular reference to itself > > parent table: Forum > > forum.forum_id > > child table: forum_thread > > forum_thread.forum_id > forum_thread.thread_id > forum_thread.parent_thread_id (the circular reference) > > ... here is the cayenne mapping xml for the relationships ... > > <db-relationship name="forumToThread" source="forum" target="forum_thread" toMany="true"> > <db-attribute-pair source="forum_id" target="forum_id"/> > </db-relationship> > <db-relationship name="subThreadToThread" source="forum_thread" target="forum_thread" toMany="false"> > <db-attribute-pair source="parent_thread_id" target="thread_id"/> > </db-relationship> > <db-relationship name="threadToForum" source="forum_thread" target="forum" toMany="false"> > <db-attribute-pair source="forum_id" target="forum_id"/> > </db-relationship> > <db-relationship name="threadToSubThread" source="forum_thread" target="forum_thread" toMany="true"> > <db-attribute-pair source="thread_id" target="parent_thread_id"/> > </db-relationship> > <obj-relationship name="forumToThread" source="Forum" target="Thread" deleteRule="Cascade" db-relationship-path="forumToThread"/> > <obj-relationship name="subThreadToThread" source="Thread" target="Thread" db-relationship-path="subThreadToThread"/> > <obj-relationship name="threadToForum" source="Thread" target="Forum" db-relationship-path="threadToForum"/> > <obj-relationship name="threadToSubThread" source="Thread" target="Thread" deleteRule="Cascade" db-relationship-path="threadToSubThread"/> > > ... here is the code I'm using to delete a thread ... > > public boolean deleteThread(int threadId) throws DataAccessException { > // NOTE: transactions are auto commit unless otherwise specified! > Thread thread = loadThread(threadId); > > // remove any parent association > if (thread.getSubThreadToThread() != null) { > Thread parentThread = thread.getSubThreadToThread(); > parentThread.removeFromThreadToSubThread(thread); > } > > // remove forum association > Forum forum = thread.getThreadToForum(); > forum.removeFromForumToThread(thread); > > super.delete(thread); > return true; > } > > ... so here is the problem: I setup the following data > > Forum record which has 3 top level thread records. Lets say thread 2 has several children and several grand children. When I delete one of thread 2's children it does the database deletes perfectly (cascade deletes of the correct grandchildren), however, the gui continues to show the grand children but the child record (that was deleted) is gone. Here is the SQL and the data context looks clean before and after processing .... > > CayenneDao >>> --------------- Cayenne Context: 2009-01-07 06:49:40 ---------------- > - hasChanges = false | isTransactionEventsEnabled = false | isUsingSharedSnapshotCache = true | isValidatingObjectsOnCommit = true > 2009-01-07 06:49:40,953 INFO (QueryLogger.java:423) - --- will run 1 query. > 2009-01-07 06:49:40,953 INFO (QueryLogger.java:377) - --- transaction started. > 2009-01-07 06:49:40,953 INFO (QueryLogger.java:300) - DELETE FROM gtools.forum_thread WHERE thread_id = ? > 2009-01-07 06:49:40,953 INFO (QueryLogger.java:322) - [bind: 228] > 2009-01-07 06:49:40,968 INFO (QueryLogger.java:368) - === updated 1 row. > 2009-01-07 06:49:40,968 INFO (QueryLogger.java:322) - [bind: 227] > 2009-01-07 06:49:40,968 INFO (QueryLogger.java:368) - === updated 1 row. > 2009-01-07 06:49:40,968 INFO (QueryLogger.java:322) - [bind: 226] > 2009-01-07 06:49:40,968 INFO (QueryLogger.java:368) - === updated 1 row. > 2009-01-07 06:49:41,015 INFO (QueryLogger.java:384) - +++ transaction committed. > CayenneDao >>> --------------- Cayenne Context: 2009-01-07 06:49:41 ---------------- > - hasChanges = false | isTransactionEventsEnabled = false | isUsingSharedSnapshotCache = true | isValidatingObjectsOnCommit = true > > ... no matter where I go w/in the application the data (grand children) seems to stick in the cache but if I log off and back on they are now gone (no longer in the object cache). What am I doing wrong here? I know that is a lot to wade through but I would greatly appreciate any help on diagnosing the problem. > > Thanks in advance. > Chad > From edwardbrown@example.com Wed Jan 07 15:52:47 2009 Return-Path: <edwardbrown@example.com> Delivered-To: edwardbrown@example.com Received: (qmail 72420 invoked from network); 7 Jan 2009 15:52:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 7 Jan 2009 15:52:47 -0000 Received: (qmail 27119 invoked by uid 500); 7 Jan 2009 15:52:46 -0000 Delivered-To: edwardbrown@example.com Received: (qmail 27103 invoked by uid 500); 7 Jan 2009 15:52:46 -0000 Mailing-List: contact edwardbrown@example.com; run by ezmlm Precedence: bulk List-Help: <mailto:edwardbrown@example.com> List-Unsubscribe: <mailto:edwardbrown@example.com> List-Post: <mailto:edwardbrown@example.com> List-Id: <user.cayenne.apache.org> Reply-To: edwardbrown@example.com Delivered-To: mailing list edwardbrown@example.com Received: (qmail 27090 invoked by uid 99); 7 Jan 2009 15:52:46 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jan 2009 07:52:46 -0800 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 edwardbrown@example.com designates 83.161.120.155 as permitted sender) Received: from [83.161.120.155] (HELO mail-bw0-f19.google.com) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jan 2009 15:52:40 +0000 Received: by bwz12 with SMTP id 12so26664706bwz.4 for <edwardbrown@example.com>; Wed, 07 Jan 2009 07:52:18 -0800 (PST) Received: by 83.161.120.155 with SMTP id i18mr8330964mun.74.1231343537669; Wed, 07 Jan 2009 07:52:17 -0800 (PST) Received: by 83.161.120.155 with HTTP; Wed, 7 Jan 2009 07:52:17 -0800 (PST) Message-ID: <edwardbrown@example.com> Date: Wed, 7 Jan 2009 07:52:17 -0800 From: "John Armstrong" <edwardbrown@example.com> Sender: edwardbrown@example.com To: edwardbrown@example.com Subject: Re: A little help w/ session state please In-Reply-To: <4706100.391231343332859.JavaMail.SYSTEM@cks-desktop> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <3258719.371231343259875.JavaMail.SYSTEM@cks-desktop> <4706100.391231343332859.JavaMail.SYSTEM@cks-desktop> X-Google-Sender-Auth: 240666e1c79cdf8b X-Virus-Checked: Checked by ClamAV on apache.org Check with Andrus on the Cayenne list. They are usually pretty good about helping find the answer (rather then just saying 'Use 3.0!') Good luck, glad to see others are cayenning with Wicket! J On Wed, Jan 7, 2009 at 7:48 AM, Chad Smith <edwardbrown@example.com> wrote: > John, > I don't think you are missing the point and that looked promising. But it looks like RefreshQuery is a 3.0 bean and not available in 2.0.4. > > -Chad > > ----- Original Message ----- > From: "John Armstrong" <edwardbrown@example.com> > To: edwardbrown@example.com > Sent: Wednesday, January 7, 2009 8:33:08 AM GMT -07:00 US/Canada Mountain > Subject: Re: A little help w/ session state please > > This I think may be more of a cayenne problem. You have to reload the > object to destroy the cayenne cache using something like RefreshQuery. > > Thats what I have to do in many cases. Like this: > > context.deleteObject(theFeed); > context.commitChanges(); > context.commitChangesToParent(); > context.performQuery(new RefreshQuery(theFeed)); > > I may be missing the point entirely, sorry :) > John- > > On Wed, Jan 7, 2009 at 6:04 AM, Chad Smith <edwardbrown@example.com> wrote: >> I have a web app that uses Cayenne 2.0.4 w/ Spring and it uses a servlet filter to manage the data context ... >> >> Request init code >> -------------------------------- >> HttpSession session = ((HttpServletRequest)servletRequest).getSession(true); >> DataContext dataContext = ServletUtil.getSessionContext(session); >> DataContext.bindThreadDataContext(dataContext); >> >> >> Request destroy code >> -------------------------------- >> DataContext dataContext = DataContext.getThreadDataContext(); >> if (dataContext.hasChanges()) { >> dataContext.rollbackChanges(); >> } >> DataContext.bindThreadDataContext(null); >> >> ... I also have a parent table and child table in which the child table has a circular reference to itself >> >> parent table: Forum >> >> forum.forum_id >> >> child table: forum_thread >> >> forum_thread.forum_id >> forum_thread.thread_id >> forum_thread.parent_thread_id (the circular reference) >> >> ... here is the cayenne mapping xml for the relationships ... >> >> <db-relationship name="forumToThread" source="forum" target="forum_thread" toMany="true"> >> <db-attribute-pair source="forum_id" target="forum_id"/> >> </db-relationship> >> <db-relationship name="subThreadToThread" source="forum_thread" target="forum_thread" toMany="false"> >> <db-attribute-pair source="parent_thread_id" target="thread_id"/> >> </db-relationship> >> <db-relationship name="threadToForum" source="forum_thread" target="forum" toMany="false"> >> <db-attribute-pair source="forum_id" target="forum_id"/> >> </db-relationship> >> <db-relationship name="threadToSubThread" source="forum_thread" target="forum_thread" toMany="true"> >> <db-attribute-pair source="thread_id" target="parent_thread_id"/> >> </db-relationship> >> <obj-relationship name="forumToThread" source="Forum" target="Thread" deleteRule="Cascade" db-relationship-path="forumToThread"/> >> <obj-relationship name="subThreadToThread" source="Thread" target="Thread" db-relationship-path="subThreadToThread"/> >> <obj-relationship name="threadToForum" source="Thread" target="Forum" db-relationship-path="threadToForum"/> >> <obj-relationship name="threadToSubThread" source="Thread" target="Thread" deleteRule="Cascade" db-relationship-path="threadToSubThread"/> >> >> ... here is the code I'm using to delete a thread ... >> >> public boolean deleteThread(int threadId) throws DataAccessException { >> // NOTE: transactions are auto commit unless otherwise specified! >> Thread thread = loadThread(threadId); >> >> // remove any parent association >> if (thread.getSubThreadToThread() != null) { >> Thread parentThread = thread.getSubThreadToThread(); >> parentThread.removeFromThreadToSubThread(thread); >> } >> >> // remove forum association >> Forum forum = thread.getThreadToForum(); >> forum.removeFromForumToThread(thread); >> >> super.delete(thread); >> return true; >> } >> >> ... so here is the problem: I setup the following data >> >> Forum record which has 3 top level thread records. Lets say thread 2 has several children and several grand children. When I delete one of thread 2's children it does the database deletes perfectly (cascade deletes of the correct grandchildren), however, the gui continues to show the grand children but the child record (that was deleted) is gone. Here is the SQL and the data context looks clean before and after processing .... >> >> CayenneDao >>> --------------- Cayenne Context: 2009-01-07 06:49:40 ---------------- >> - hasChanges = false | isTransactionEventsEnabled = false | isUsingSharedSnapshotCache = true | isValidatingObjectsOnCommit = true >> 2009-01-07 06:49:40,953 INFO (QueryLogger.java:423) - --- will run 1 query. >> 2009-01-07 06:49:40,953 INFO (QueryLogger.java:377) - --- transaction started. >> 2009-01-07 06:49:40,953 INFO (QueryLogger.java:300) - DELETE FROM gtools.forum_thread WHERE thread_id = ? >> 2009-01-07 06:49:40,953 INFO (QueryLogger.java:322) - [bind: 228] >> 2009-01-07 06:49:40,968 INFO (QueryLogger.java:368) - === updated 1 row. >> 2009-01-07 06:49:40,968 INFO (QueryLogger.java:322) - [bind: 227] >> 2009-01-07 06:49:40,968 INFO (QueryLogger.java:368) - === updated 1 row. >> 2009-01-07 06:49:40,968 INFO (QueryLogger.java:322) - [bind: 226] >> 2009-01-07 06:49:40,968 INFO (QueryLogger.java:368) - === updated 1 row. >> 2009-01-07 06:49:41,015 INFO (QueryLogger.java:384) - +++ transaction committed. >> CayenneDao >>> --------------- Cayenne Context: 2009-01-07 06:49:41 ---------------- >> - hasChanges = false | isTransactionEventsEnabled = false | isUsingSharedSnapshotCache = true | isValidatingObjectsOnCommit = true >> >> ... no matter where I go w/in the application the data (grand children) seems to stick in the cache but if I log off and back on they are now gone (no longer in the object cache). What am I doing wrong here? I know that is a lot to wade through but I would greatly appreciate any help on diagnosing the problem. >> >> Thanks in advance. >> Chad >> > From edwardbrown@example.com Wed Jan 07 16:58:36 2009 Return-Path: <edwardbrown@example.com> Delivered-To: edwardbrown@example.com Received: (qmail 10753 invoked from network); 7 Jan 2009 16:58:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 7 Jan 2009 16:58:34 -0000 Received: (qmail 61145 invoked by uid 500); 7 Jan 2009 16:58:32 -0000 Delivered-To: edwardbrown@example.com Received: (qmail 61131 invoked by uid 500); 7 Jan 2009 16:58:32 -0000 Mailing-List: contact edwardbrown@example.com; run by ezmlm Precedence: bulk List-Help: <mailto:edwardbrown@example.com> List-Unsubscribe: <mailto:edwardbrown@example.com> List-Post: <mailto:edwardbrown@example.com> List-Id: <user.cayenne.apache.org> Reply-To: edwardbrown@example.com Delivered-To: mailing list edwardbrown@example.com Received: (qmail 60946 invoked by uid 99); 7 Jan 2009 16:58:32 -0000 Received: from nike.apache.org (HELO nike.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jan 2009 08:58:32 -0800 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of edwardbrown@example.com designates 83.161.120.155 as permitted sender) Received: from [83.161.120.155] (HELO yw-out-1718.google.com) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jan 2009 16:58:23 +0000 Received: by yw-out-1718.google.com with SMTP id 6so3109964ywa.82 for <edwardbrown@example.com>; Wed, 07 Jan 2009 08:58:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type:references; bh=MZzii4L9ffV8UwOXEcqdJpSuqyiO4YDx6GWMOu9ubfQ=; b=yA5EH1L7Tm8UWWklFmBO5kHBTJzKzbiNqbt87Gwy4sQH1O99Sf3m9xq78AtWJVt2eH OTDJBisaawp5+pwftJ+2KKggHkEIjSt5p/KUp7j9eokER6dZbsKqUp0/ke+J1QJEgigZ nkdDx4Lx2Q9F897G1wbOrl6BPIBGRMfFwJKio= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:references; b=gO0j/Kc2nY9XgjGe24aETbx7e1L1GNkhqMPVdvs+qEl94nDFBDbQWdOfVu/kRoFPos AH7vhXsiqXKksVL0PnJl8o5tXqCtisHWdY4SsCI/Z1Z6oUHkEbUMoTCHGjyavGLqCq6q k4Vbrp36ELLCK7Ti0dcowhKF5sjxX6fHMX+9M= Received: by 83.161.120.155 with SMTP id b6mr188823ybe.218.1231347482500; Wed, 07 Jan 2009 08:58:02 -0800 (PST) Received: by 83.161.120.155 with HTTP; Wed, 7 Jan 2009 08:58:02 -0800 (PST) Message-ID: <edwardbrown@example.com> Date: Wed, 7 Jan 2009 19:58:02 +0300 From: "Andrey Razumovsky" <edwardbrown@example.com> To: edwardbrown@example.com Subject: Re: A little help w/ session state please In-Reply-To: <edwardbrown@example.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_232875_24386225.1231347482492" References: <3258719.371231343259875.JavaMail.SYSTEM@cks-desktop> <4706100.391231343332859.JavaMail.SYSTEM@cks-desktop> <edwardbrown@example.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_232875_24386225.1231347482492 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline I think DataContext.invalidateObjects(...) method was present in 2.0. Still, I'd recommend to update to Cay3 anyways. BTW this message is already on Cayenne list Regards, Andrey 2009/1/7 John Armstrong <edwardbrown@example.com> > Check with Andrus on the Cayenne list. They are usually pretty good > about helping find the answer (rather then just saying 'Use 3.0!') > > Good luck, glad to see others are cayenning with Wicket! > > J > > On Wed, Jan 7, 2009 at 7:48 AM, Chad Smith <edwardbrown@example.com> wrote: > > John, > > I don't think you are missing the point and that looked promising. But > it looks like RefreshQuery is a 3.0 bean and not available in 2.0.4. > > > > -Chad > > > > ----- Original Message ----- > > From: "John Armstrong" <edwardbrown@example.com> > > To: edwardbrown@example.com > > Sent: Wednesday, January 7, 2009 8:33:08 AM GMT -07:00 US/Canada Mountain > > Subject: Re: A little help w/ session state please > > > > This I think may be more of a cayenne problem. You have to reload the > > object to destroy the cayenne cache using something like RefreshQuery. > > > > Thats what I have to do in many cases. Like this: > > > > context.deleteObject(theFeed); > > context.commitChanges(); > > context.commitChangesToParent(); > > context.performQuery(new RefreshQuery(theFeed)); > > > > I may be missing the point entirely, sorry :) > > John- > > > > On Wed, Jan 7, 2009 at 6:04 AM, Chad Smith <edwardbrown@example.com> > wrote: > >> I have a web app that uses Cayenne 2.0.4 w/ Spring and it uses a servlet > filter to manage the data context ... > >> > >> Request init code > >> -------------------------------- > >> HttpSession session = > ((HttpServletRequest)servletRequest).getSession(true); > >> DataContext dataContext = ServletUtil.getSessionContext(session); > >> DataContext.bindThreadDataContext(dataContext); > >> > >> > >> Request destroy code > >> -------------------------------- > >> DataContext dataContext = DataContext.getThreadDataContext(); > >> if (dataContext.hasChanges()) { > >> dataContext.rollbackChanges(); > >> } > >> DataContext.bindThreadDataContext(null); > >> > >> ... I also have a parent table and child table in which the child table > has a circular reference to itself > >> > >> parent table: Forum > >> > >> forum.forum_id > >> > >> child table: forum_thread > >> > >> forum_thread.forum_id > >> forum_thread.thread_id > >> forum_thread.parent_thread_id (the circular reference) > >> > >> ... here is the cayenne mapping xml for the relationships ... > >> > >> <db-relationship name="forumToThread" source="forum" > target="forum_thread" toMany="true"> > >> <db-attribute-pair source="forum_id" target="forum_id"/> > >> </db-relationship> > >> <db-relationship name="subThreadToThread" source="forum_thread" > target="forum_thread" toMany="false"> > >> <db-attribute-pair source="parent_thread_id" target="thread_id"/> > >> </db-relationship> > >> <db-relationship name="threadToForum" source="forum_thread" > target="forum" toMany="false"> > >> <db-attribute-pair source="forum_id" target="forum_id"/> > >> </db-relationship> > >> <db-relationship name="threadToSubThread" source="forum_thread" > target="forum_thread" toMany="true"> > >> <db-attribute-pair source="thread_id" target="parent_thread_id"/> > >> </db-relationship> > >> <obj-relationship name="forumToThread" source="Forum" target="Thread" > deleteRule="Cascade" db-relationship-path="forumToThread"/> > >> <obj-relationship name="subThreadToThread" source="Thread" > target="Thread" db-relationship-path="subThreadToThread"/> > >> <obj-relationship name="threadToForum" source="Thread" target="Forum" > db-relationship-path="threadToForum"/> > >> <obj-relationship name="threadToSubThread" source="Thread" > target="Thread" deleteRule="Cascade" > db-relationship-path="threadToSubThread"/> > >> > >> ... here is the code I'm using to delete a thread ... > >> > >> public boolean deleteThread(int threadId) throws DataAccessException > { > >> // NOTE: transactions are auto commit unless otherwise specified! > >> Thread thread = loadThread(threadId); > >> > >> // remove any parent association > >> if (thread.getSubThreadToThread() != null) { > >> Thread parentThread = thread.getSubThreadToThread(); > >> parentThread.removeFromThreadToSubThread(thread); > >> } > >> > >> // remove forum association > >> Forum forum = thread.getThreadToForum(); > >> forum.removeFromForumToThread(thread); > >> > >> super.delete(thread); > >> return true; > >> } > >> > >> ... so here is the problem: I setup the following data > >> > >> Forum record which has 3 top level thread records. Lets say thread 2 > has several children and several grand children. When I delete one of > thread 2's children it does the database deletes perfectly (cascade deletes > of the correct grandchildren), however, the gui continues to show the grand > children but the child record (that was deleted) is gone. Here is the SQL > and the data context looks clean before and after processing .... > >> > >> CayenneDao >>> --------------- Cayenne Context: 2009-01-07 06:49:40 > ---------------- > >> - hasChanges = false | isTransactionEventsEnabled = false | > isUsingSharedSnapshotCache = true | isValidatingObjectsOnCommit = true > >> 2009-01-07 06:49:40,953 INFO (QueryLogger.java:423) - --- will run 1 > query. > >> 2009-01-07 06:49:40,953 INFO (QueryLogger.java:377) - --- transaction > started. > >> 2009-01-07 06:49:40,953 INFO (QueryLogger.java:300) - DELETE FROM > gtools.forum_thread WHERE thread_id = ? > >> 2009-01-07 06:49:40,953 INFO (QueryLogger.java:322) - [bind: 228] > >> 2009-01-07 06:49:40,968 INFO (QueryLogger.java:368) - === updated 1 row. > >> 2009-01-07 06:49:40,968 INFO (QueryLogger.java:322) - [bind: 227] > >> 2009-01-07 06:49:40,968 INFO (QueryLogger.java:368) - === updated 1 row. > >> 2009-01-07 06:49:40,968 INFO (QueryLogger.java:322) - [bind: 226] > >> 2009-01-07 06:49:40,968 INFO (QueryLogger.java:368) - === updated 1 row. > >> 2009-01-07 06:49:41,015 INFO (QueryLogger.java:384) - +++ transaction > committed. > >> CayenneDao >>> --------------- Cayenne Context: 2009-01-07 06:49:41 > ---------------- > >> - hasChanges = false | isTransactionEventsEnabled = false | > isUsingSharedSnapshotCache = true | isValidatingObjectsOnCommit = true > >> > >> ... no matter where I go w/in the application the data (grand children) > seems to stick in the cache but if I log off and back on they are now gone > (no longer in the object cache). What am I doing wrong here? I know that > is a lot to wade through but I would greatly appreciate any help on > diagnosing the problem. > >> > >> Thanks in advance. > >> Chad > >> > > > ------=_Part_232875_24386225.1231347482492-- From edwardbrown@example.com Wed Jan 07 17:07:24 2009 Return-Path: <edwardbrown@example.com> Delivered-To: edwardbrown@example.com Received: (qmail 15803 invoked from network); 7 Jan 2009 17:07:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 7 Jan 2009 17:07:24 -0000 Received: (qmail 83204 invoked by uid 500); 7 Jan 2009 17:07:18 -0000 Delivered-To: edwardbrown@example.com Received: (qmail 83186 invoked by uid 500); 7 Jan 2009 17:07:18 -0000 Mailing-List: contact edwardbrown@example.com; run by ezmlm Precedence: bulk List-Help: <mailto:edwardbrown@example.com> List-Unsubscribe: <mailto:edwardbrown@example.com> List-Post: <mailto:edwardbrown@example.com> List-Id: <user.cayenne.apache.org> Reply-To: edwardbrown@example.com Delivered-To: mailing list edwardbrown@example.com Received: (qmail 83159 invoked by uid 99); 7 Jan 2009 17:07:18 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jan 2009 09:07:18 -0800 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 edwardbrown@example.com designates 83.161.120.155 as permitted sender) Received: from [83.161.120.155] (HELO wa-out-1112.google.com) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jan 2009 17:07:10 +0000 Received: by wa-out-1112.google.com with SMTP id k22so4568989waf.20 for <edwardbrown@example.com>; Wed, 07 Jan 2009 09:06:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:message-id :in-reply-to:subject:mime-version:content-type :content-transfer-encoding; bh=ApN8f9AAPsKOJJiipS95MTjwDG8oSFM/YmLZb2cabNY=; b=Gpk+akmKkku32MCY7PKgwDPKUimFhjKRJwWamhDTvdr4iHsB6Ae8WilNfb7ODWurZO H5xGVPHtNgM8hWvudq3kD3KrLoLnGjEMuF8ec8CImTZ9Fl7ThOMSzFsJw2+ULW4PkVts dbFKPfAH56ykcdI9vxDEOvI3wQ4py9GrPOHzE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:message-id:in-reply-to:subject:mime-version :content-type:content-transfer-encoding; b=GXT4F35kVfkGvH0yudOuw4szvKJ3LV3PnkF3en8CYzh+7qDlQReV+8RFehFy24n5Vz /FJf8/P0YYAWtjS/8TeJcRbMLSoqyh53+0rH063nIQ5BzIbWU14uOjHMjplkbuqmu4Hj u4fbxD3r23moH60VBgwcrnJdNWWJMUvbGkoxM= Received: by 83.161.120.155 with SMTP id c14mr15381365wal.86.1231348009816; Wed, 07 Jan 2009 09:06:49 -0800 (PST) Received: from localhost ([83.161.120.155]) by mx.google.com with ESMTPS id y25sm28451616pod.24.283.161.120.155.06.49 (version=SSLv3 cipher=RC4-MD5); Wed, 07 Jan 2009 09:06:49 -0800 (PST) Date: Wed, 7 Jan 2009 10:06:49 -0700 (MST) From: Chad Smith <edwardbrown@example.com> To: edwardbrown@example.com Message-ID: <3362702.511231348009125.JavaMail.SYSTEM@cks-desktop> In-Reply-To: <edwardbrown@example.com> Subject: Re: A little help w/ session state please MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Andrey, you rock - that did it! thanks, -Chad ----- Original Message ----- From: "Andrey Razumovsky" <edwardbrown@example.com> To: edwardbrown@example.com Sent: Wednesday, January 7, 2009 9:58:02 AM GMT -07:00 US/Canada Mountain Subject: Re: A little help w/ session state please I think DataContext.invalidateObjects(...) method was present in 2.0. Still, I'd recommend to update to Cay3 anyways. BTW this message is already on Cayenne list Regards, Andrey 2009/1/7 John Armstrong <edwardbrown@example.com> > Check with Andrus on the Cayenne list. They are usually pretty good > about helping find the answer (rather then just saying 'Use 3.0!') > > Good luck, glad to see others are cayenning with Wicket! > > J > > On Wed, Jan 7, 2009 at 7:48 AM, Chad Smith <edwardbrown@example.com> wrote: > > John, > > I don't think you are missing the point and that looked promising. But > it looks like RefreshQuery is a 3.0 bean and not available in 2.0.4. > > > > -Chad > > > > ----- Original Message ----- > > From: "John Armstrong" <edwardbrown@example.com> > > To: edwardbrown@example.com > > Sent: Wednesday, January 7, 2009 8:33:08 AM GMT -07:00 US/Canada Mountain > > Subject: Re: A little help w/ session state please > > > > This I think may be more of a cayenne problem. You have to reload the > > object to destroy the cayenne cache using something like RefreshQuery. > > > > Thats what I have to do in many cases. Like this: > > > > context.deleteObject(theFeed); > > context.commitChanges(); > > context.commitChangesToParent(); > > context.performQuery(new RefreshQuery(theFeed)); > > > > I may be missing the point entirely, sorry :) > > John- > > > > On Wed, Jan 7, 2009 at 6:04 AM, Chad Smith <edwardbrown@example.com> > wrote: > >> I have a web app that uses Cayenne 2.0.4 w/ Spring and it uses a servlet > filter to manage the data context ... > >> > >> Request init code > >> -------------------------------- > >> HttpSession session = > ((HttpServletRequest)servletRequest).getSession(true); > >> DataContext dataContext = ServletUtil.getSessionContext(session); > >> DataContext.bindThreadDataContext(dataContext); > >> > >> > >> Request destroy code > >> -------------------------------- > >> DataContext dataContext = DataContext.getThreadDataContext(); > >> if (dataContext.hasChanges()) { > >> dataContext.rollbackChanges(); > >> } > >> DataContext.bindThreadDataContext(null); > >> > >> ... I also have a parent table and child table in which the child table > has a circular reference to itself > >> > >> parent table: Forum > >> > >> forum.forum_id > >> > >> child table: forum_thread > >> > >> forum_thread.forum_id > >> forum_thread.thread_id > >> forum_thread.parent_thread_id (the circular reference) > >> > >> ... here is the cayenne mapping xml for the relationships ... > >> > >> <db-relationship name="forumToThread" source="forum" > target="forum_thread" toMany="true"> > >> <db-attribute-pair source="forum_id" target="forum_id"/> > >> </db-relationship> > >> <db-relationship name="subThreadToThread" source="forum_thread" > target="forum_thread" toMany="false"> > >> <db-attribute-pair source="parent_thread_id" target="thread_id"/> > >> </db-relationship> > >> <db-relationship name="threadToForum" source="forum_thread" > target="forum" toMany="false"> > >> <db-attribute-pair source="forum_id" target="forum_id"/> > >> </db-relationship> > >> <db-relationship name="threadToSubThread" source="forum_thread" > target="forum_thread" toMany="true"> > >> <db-attribute-pair source="thread_id" target="parent_thread_id"/> > >> </db-relationship> > >> <obj-relationship name="forumToThread" source="Forum" target="Thread" > deleteRule="Cascade" db-relationship-path="forumToThread"/> > >> <obj-relationship name="subThreadToThread" source="Thread" > target="Thread" db-relationship-path="subThreadToThread"/> > >> <obj-relationship name="threadToForum" source="Thread" target="Forum" > db-relationship-path="threadToForum"/> > >> <obj-relationship name="threadToSubThread" source="Thread" > target="Thread" deleteRule="Cascade" > db-relationship-path="threadToSubThread"/> > >> > >> ... here is the code I'm using to delete a thread ... > >> > >> public boolean deleteThread(int threadId) throws DataAccessException > { > >> // NOTE: transactions are auto commit unless otherwise specified! > >> Thread thread = loadThread(threadId); > >> > >> // remove any parent association > >> if (thread.getSubThreadToThread() != null) { > >> Thread parentThread = thread.getSubThreadToThread(); > >> parentThread.removeFromThreadToSubThread(thread); > >> } > >> > >> // remove forum association > >> Forum forum = thread.getThreadToForum(); > >> forum.removeFromForumToThread(thread); > >> > >> super.delete(thread); > >> return true; > >> } > >> > >> ... so here is the problem: I setup the following data > >> > >> Forum record which has 3 top level thread records. Lets say thread 2 > has several children and several grand children. When I delete one of > thread 2's children it does the database deletes perfectly (cascade deletes > of the correct grandchildren), however, the gui continues to show the grand > children but the child record (that was deleted) is gone. Here is the SQL > and the data context looks clean before and after processing .... > >> > >> CayenneDao >>> --------------- Cayenne Context: 2009-01-07 06:49:40 > ---------------- > >> - hasChanges = false | isTransactionEventsEnabled = false | > isUsingSharedSnapshotCache = true | isValidatingObjectsOnCommit = true > >> 2009-01-07 06:49:40,953 INFO (QueryLogger.java:423) - --- will run 1 > query. > >> 2009-01-07 06:49:40,953 INFO (QueryLogger.java:377) - --- transaction > started. > >> 2009-01-07 06:49:40,953 INFO (QueryLogger.java:300) - DELETE FROM > gtools.forum_thread WHERE thread_id = ? > >> 2009-01-07 06:49:40,953 INFO (QueryLogger.java:322) - [bind: 228] > >> 2009-01-07 06:49:40,968 INFO (QueryLogger.java:368) - === updated 1 row. > >> 2009-01-07 06:49:40,968 INFO (QueryLogger.java:322) - [bind: 227] > >> 2009-01-07 06:49:40,968 INFO (QueryLogger.java:368) - === updated 1 row. > >> 2009-01-07 06:49:40,968 INFO (QueryLogger.java:322) - [bind: 226] > >> 2009-01-07
{'source': 'Apache Software Foundation Public Mail Archives'}