Return-Path: X-Original-To: apmail-cayenne-user-archive@www.apache.org Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0DF27770B for ; Fri, 2 Sep 2011 15:28:38 +0000 (UTC) Received: (qmail 74006 invoked by uid 500); 2 Sep 2011 15:28:37 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 73961 invoked by uid 500); 2 Sep 2011 15:28:37 -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 73952 invoked by uid 99); 2 Sep 2011 15:28:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Sep 2011 15:28:36 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [74.125.82.171] (HELO mail-wy0-f171.google.com) (74.125.82.171) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Sep 2011 15:28:31 +0000 Received: by wyh13 with SMTP id 13so3622494wyh.16 for ; Fri, 02 Sep 2011 08:28:10 -0700 (PDT) MIME-Version: 1.0 Received: by 10.227.7.7 with SMTP id b7mr1183376wbb.63.1314977289768; Fri, 02 Sep 2011 08:28:09 -0700 (PDT) Received: by 10.227.196.199 with HTTP; Fri, 2 Sep 2011 08:28:09 -0700 (PDT) X-Originating-IP: [89.101.190.206] In-Reply-To: References: Date: Fri, 2 Sep 2011 16:28:09 +0100 Message-ID: Subject: Re: Data base externally modified From: Anthony Brew To: user@cayenne.apache.org Content-Type: multipart/alternative; boundary=002215974d5a3e908f04abf7020e --002215974d5a3e908f04abf7020e Content-Type: text/plain; charset=ISO-8859-1 Hi, Just an update, and I think I forgot to include something important Its a one to many relationship that I am seeing cached, (ie I fetch "Item" and the many to one "Item.getSubItems()" are being fetched from the cache) My code now looks a bit like: Expression e1 = Expression.fromString("id = $id"); Map params = new HashMap(); params.put("id", item.getId()); SelectQuery query = new SelectQuery(Item.class, e1.expWithParameters(params)); query.setCacheStrategy(QueryCacheStrategy.NO_CACHE); List items = context.performQuery(query); if(items.size() != 1){ throw new RuntimeException(""); } freshitem = (Item) items.get(0); subitems = freshitem.getSubItems() Where subitems are stale. I am sure I am making this more complicated than needs be. As I mentioned before I would like to turn on some flag to essentially always read from DB when I do items.getSubItems() if possible, or when I reload the Item when its getter methods are called to make it always read from the DB the first time when QueryCacheStrategy.NO_CACHE is specified... Thanks a Million, Anthony On Fri, Sep 2, 2011 at 3:54 PM, Mike Kienenberger wrote: > You may want to review these two threads from the end of July: > > OSCache is gone > http://www.mail-archive.com/dev@cayenne.apache.org/msg06209.html > > EhCache integration preview > http://www.mail-archive.com/user@cayenne.apache.org/msg06211.html > > > On Fri, Sep 2, 2011 at 10:30 AM, Anthony Brew >wrote: > > > Hi Andrus, > > I was just about to get back to you on, I accidentally > > started two threads when I joined the mailing list. > > > > Essentially we have a ruby on rails project that creates config on the > > front > > end, this is the part that is changing externally. Then internally we > read > > these config and do a bunch of processing and write the results to a > > separate set of tables. The tables are in turn read by the R on R app but > > never written to > > > > so > > Tables Set A | Set B > > ------------------------------------------------------------------------ > > Rails read and write | read only > > Java read only | read and write > > > > The issues I am facing are with set A changing in the app. > > > > I have tried forcing the Item to reload by doing this, (I cut code from > > Cayennes: DataObjectUtils.objectForPK(threadDataContext, Item.class, > > dirtyItem.getId());) > > > > private Item getItemWithNoCayenneCache(Item newGame, DataContext > > threadDataContext) { > > ObjectId gameIdentifier = buildId(threadDataContext, Game.class, > > newGame.getId()); > > > > return (Item) DataObjectUtils.objectForQuery(threadDataContext, > new > > ObjectIdQuery( > > gameIdentifier, > > false, > > ObjectIdQuery.CACHE_REFRESH)); > > } > > } > > > > > > stepping into *DataObjectUtils.objectForQuery stepping into the Cayenne > > code > > I eventually get to DataContext.java* > > * > > * > > where I see the following method called > > > > * > > @Override > > @SuppressWarnings("unchecked") > > public List performQuery(Query query) { > > query = nonNullDelegate().willPerformQuery(this, query); > > if (query == null) { > > return new ArrayList(1); > > } > > > > List result = onQuery(this, query).firstList(); > > return result != null ? result : new ArrayList(1); > > } > > * > > > > however i see that the delgate in * > > nonNullDelegate() is null and so I get back NoopDelegate.noopDelegate > which > > I assume is the route of my woes. > > * > > * > > > > * > > Im interested in trying the OSCache solution you proposed in my other > > thread, but I am a little wary the code is stale as my maven dependancies > > fail (I am actually pretty new to maven so this might be my bad). > > OSCache appears to be quite old since the OpenSymphony project died, > maybe > > my maven config is off, are there still active contributors? > > > > In my pom I have specified > > > > opensymphony > > oscache > > 2.4 > > > > > > however the dependancies on > > > > - javax.jms:jms:1.1 > > > > Thanks a Million > > Anthony > > > > > > On Fri, Sep 2, 2011 at 2:34 PM, Andrus Adamchik > >wrote: > > > > > Could you please explain your data access patterns? > > > > > > E.g. if you fetch some objects and store them in an instance variable > in > > > your application, they are not going to get refreshed automatically. To > > > refresh objects you need to either invalidate them explicitly via > > > context.invalidateObjects() or run a query. All the cache settings are > > > essentially about optimizing query execution (refresh data, but only as > > > often as needed). > > > > > > Andrus > > > > > > On Sep 2, 2011, at 9:28 AM, Anthony Brew wrote: > > > > > > > Hi Gary, > > > > Yeah thats what I am seeing in the code, but I cant for > the > > > life > > > > of me see how to turn off the caching completely in the modeller, I > > > actually > > > > think it wont hit our performance very badly to have no caching. > > > > > > > > The cache setting I see are the in the DataDomain Configuration > > > > > > > > Which has an option for a Query Cache Factory with a choice of two > > > classes. > > > > - org.apache.cayenne.cache.MapQueryCacheFactory > > > > - org.apache.cayenne.cache.OSQueryCacheFactory > > > > > > > > I selected the MapQueryCache and trie to set the size of the object > > cache > > > to > > > > 1 (couldn't set this to zero) as the application barfed saying caches > > had > > > to > > > > be greater than size zero. > > > > > > > > in my cayenne.xml I see the line > > > > > > > > > > > > > > > > was added, perhaps there is some manual setting I can add to this > file > > to > > > > turn caching off? > > > > > > > > All the Best, > > > > Anthony > > > > > > > > > > > > > > > > On Fri, Sep 2, 2011 at 12:20 AM, Gary Jarrel > > > wrote: > > > > > > > >> I'd say that would be cache related, as Cayenne is caching the data > > > >> from the database, switch the cache of in the Modeler perhaps and > that > > > >> should fix your problem. > > > >> > > > >> G > > > >> > > > >> On Fri, Sep 2, 2011 at 3:04 AM, Anthony Brew < > anthony.brew@swrve.com> > > > >> wrote: > > > >>> Hi, > > > >>> I have a two processes one which writes to a several database > > tables > > > >> (a > > > >>> ruby on rails application) and a java application that reads the > > state > > > >> these > > > >>> data base tables using Cayenne and writes to other tables. > > > >>> > > > >>> When the ruby modifies the underlying data-base I am seeing that > > > Cayenne > > > >> is > > > >>> not automatically picking up that the underlying data is now > > > inconsistant > > > >>> and not reloading. Is there some way I can config Cayenne to > > aggressive > > > >>> check some tables for updates while ignoring others? > > > >>> > > > >>> Thanks a Million > > > >>> Anthony Brew > > > >>> > > > >> > > > > > > > > > --002215974d5a3e908f04abf7020e--