Return-Path: X-Original-To: apmail-openjpa-dev-archive@www.apache.org Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D6284946E for ; Thu, 10 Nov 2011 14:36:34 +0000 (UTC) Received: (qmail 66986 invoked by uid 500); 10 Nov 2011 14:36:34 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 66925 invoked by uid 500); 10 Nov 2011 14:36:34 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 66917 invoked by uid 99); 10 Nov 2011 14:36:34 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Nov 2011 14:36:33 +0000 X-ASF-Spam-Status: No, hits=2.8 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of kwsutter@gmail.com designates 209.85.215.174 as permitted sender) Received: from [209.85.215.174] (HELO mail-ey0-f174.google.com) (209.85.215.174) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Nov 2011 14:36:29 +0000 Received: by eye27 with SMTP id 27so3349105eye.33 for ; Thu, 10 Nov 2011 06:36:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=VjdJKgoEI/XeL/JUXtYOIFzaSLRRaGvyGcY55lnC6Gk=; b=fqAGPb6y1m9mCsDF1AQ1GYxAag81DoTOMvHuhDV3UYXRTn0Nb1q4ZAqkdURyrhgU3g SDZRGydMDD7HmCmYurvq6Ug7JNlGGZTuCfvQIA/FL/+YhI8CRhHkivXfgyKHTZuXj2cU uN5y8QSv+nLaQRVUFVI/oTuC6La0olc9s4Zwk= Received: by 10.14.18.26 with SMTP id k26mr593016eek.5.1320935768204; Thu, 10 Nov 2011 06:36:08 -0800 (PST) MIME-Version: 1.0 Received: by 10.14.95.130 with HTTP; Thu, 10 Nov 2011 06:35:47 -0800 (PST) In-Reply-To: <1320886814011-6980197.post@n2.nabble.com> References: <1320886814011-6980197.post@n2.nabble.com> From: Kevin Sutter Date: Thu, 10 Nov 2011 08:35:47 -0600 Message-ID: Subject: Re: L1 and L2cache. To: dev@openjpa.apache.org Content-Type: multipart/alternative; boundary=0016e659fe1a3c247404b162538c --0016e659fe1a3c247404b162538c Content-Type: text/plain; charset=ISO-8859-1 Hi Ravi, You don't mention anything about transactions or persistence contexts in your description, so I'm not sure when things are getting cleared out naturally. The normal path of finding an entity is through the Persistence Context (L1 cache), then the L2 cache (if configured), then the database. The idea being is that even if you get an "old" copy of the data at least it will be discovered if you attempt to make changes to it (optimistic locking). If you want to force the app to get an updated copy, then you have to clear out the respective cache of the given entity. You mentioned that turning off the L2 cache should be forcing OpenJPA to the database. Not if you still have that Entity instance in your L1 cache. I would try your scenario with turning on Trace so that you can see where the "old" data is coming from. My guess is this entity still exists in your L1 cache. You can clear that by either closing or clearing the EM. Depending on the version of OpenJPA you are using, you could also detach the specific entity from your persistence context. Hope this helps, Kevin On Wed, Nov 9, 2011 at 7:00 PM, Ravi P Palacherla < ravi.palacherla@oracle.com> wrote: > Hi, > > I have a question about L1 cache refresh. > > Lets say I have two Entity Managers in my application. > > I have a simple JPAEntity entity that has id and name values. > > Sequence of steps in the app: > -------------------------------- > EntityManager EM1 does a query for JPAEntity with id=1. > EntityManager EM2 does a query for same JPAEntity with id=1. > EM1 updates name from "old" to "new" > Now when EM2 does the query again with id=1, it is showing the value of > name > as "old" but not "new" > > I disabled DataCache and QueryCache which means that EM2's query goes to > database but it still is showing old values. Reason I think is because > EM2's > cache (L1cache) is not updated with "new" value. > > Is my understanding correct ? > If yes, then is there a way I can refresh EM2's cache other than using > evict() or refresh() call ? > > Regards, > Ravi. > > -- > View this message in context: > http://openjpa.208410.n2.nabble.com/L1-and-L2cache-tp6980197p6980197.html > Sent from the OpenJPA Developers mailing list archive at Nabble.com. > --0016e659fe1a3c247404b162538c--