Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 72420 invoked from network); 7 Jan 2009 15:52:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) 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: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 27103 invoked by uid 500); 7 Jan 2009 15:52:46 -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 27090 invoked by uid 99); 7 Jan 2009 15:52:46 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) 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 siberian@siberian.org designates 209.85.218.19 as permitted sender) Received: from [209.85.218.19] (HELO mail-bw0-f19.google.com) (209.85.218.19) 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 ; Wed, 07 Jan 2009 07:52:18 -0800 (PST) Received: by 10.103.131.18 with SMTP id i18mr8330964mun.74.1231343537669; Wed, 07 Jan 2009 07:52:17 -0800 (PST) Received: by 10.103.117.4 with HTTP; Wed, 7 Jan 2009 07:52:17 -0800 (PST) Message-ID: <479ffcd60901070752s49e90813h46e9a7b9e0e52589@mail.gmail.com> Date: Wed, 7 Jan 2009 07:52:17 -0800 From: "John Armstrong" Sender: siberian@siberian.org To: user@cayenne.apache.org 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 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" > To: user@cayenne.apache.org > 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 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 ... >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> ... 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 >> >