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 9059118107 for ; Wed, 3 Feb 2016 21:25:28 +0000 (UTC) Received: (qmail 1641 invoked by uid 500); 3 Feb 2016 21:25:18 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 1616 invoked by uid 500); 3 Feb 2016 21:25:18 -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 1599 invoked by uid 99); 3 Feb 2016 21:25:18 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Feb 2016 21:25:18 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 929A0C0D97 for ; Wed, 3 Feb 2016 21:25:17 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.958 X-Spam-Level: * X-Spam-Status: No, score=1.958 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, KAM_INFOUSMEBIZ=0.75, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, T_REMOTE_IMAGE=0.01] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (1024-bit key) header.d=modernizingmedicine.com Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id uk_hGGXrExLB for ; Wed, 3 Feb 2016 21:25:13 +0000 (UTC) Received: from mail-pf0-f179.google.com (mail-pf0-f179.google.com [209.85.192.179]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id 2923A207E1 for ; Wed, 3 Feb 2016 21:25:13 +0000 (UTC) Received: by mail-pf0-f179.google.com with SMTP id o185so20146786pfb.1 for ; Wed, 03 Feb 2016 13:25:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=modernizingmedicine.com; s=modernizingmedicine; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=5X/hCw8wj66LEzj+tGPSQknYGeMhATzYK+b8Zy3II4M=; b=GdJn+7/7l4RbKwJdbAV6tXmVxc1pFBmFCKISj/e67JULzXOy8Zi5pshqvTsXW7k4R4 kfEPKDJQs+/HOOBRacJ3JJxmAXj0hNrmA8mKqD5W1zZYoKVYYvRevk0ftGclCxxsU/LR ONSmbHzWDM8aZTnFCinp9SIw626Xhej0vA99k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=5X/hCw8wj66LEzj+tGPSQknYGeMhATzYK+b8Zy3II4M=; b=FZWxyfcXrqCs95jhs9WmdmkOJTTCqP4ewXIEIBslj308wRrxOGMI3awEmueeUw8Cxl EaVPgaawbat3kFiuuimU5uo04JLmoEsSYdeWTbc2wzPVy4jdMucE90MD5tA0RstaOpXc rQHc6ZPChUObdZIvKb7CrxJ05bBpolmGZB2II1/WyCdOpTgEA1YuaioynLyRsVANcxkV NPlFS5gLTWW0hlMYZdT3oGxTrQOCXqc9VwzvjdcHRAvv1rIJX3lz1dIup/wlz1EkjdMy rsWgfDs3wTTMNbDz+6sIc6pP1rufZB1KZuEgHKBrXm2NIGkaD9fmWRsFsoRy5y1ZUOBt aC7A== X-Gm-Message-State: AG10YOSrOIAVx98Qr3MLHccbvFDC6jk7m3F8ezA/f5+cOXq3Pr6nPmQxWrNw1u8t3sSgQeDx5mIsib0/Hob5LsrE X-Received: by 10.98.8.153 with SMTP id 25mr5813559pfi.51.1454534706978; Wed, 03 Feb 2016 13:25:06 -0800 (PST) MIME-Version: 1.0 Received: by 10.67.7.2 with HTTP; Wed, 3 Feb 2016 13:24:47 -0800 (PST) In-Reply-To: References: <6EA8FC26-416D-43C6-BAFE-14C2ECE8EC38@objectstyle.org> <67587EE8-0E14-49F1-85DE-3644D054307B@objectstyle.org> From: Frank Herrmann Date: Wed, 3 Feb 2016 16:24:47 -0500 Message-ID: Subject: Re: QueryCache @CacheGroups Annotation To: user@cayenne.apache.org Content-Type: multipart/alternative; boundary=001a1149922285feae052ae4400d --001a1149922285feae052ae4400d Content-Type: text/plain; charset=UTF-8 I think I'm beginning to understand. The annotation, along with the CacheInvalidationFilter, is to flush a particular cache group when changes are committed to the annotated object. Is there some documentation for 3.1 or 4.0 for these annotations and query caching? The latest I can find is the 3.0 documentation. Thanks again, -Frank On Wed, Feb 3, 2016 at 3:57 PM, Frank Herrmann < frank.herrmann@modernizingmedicine.com> wrote: > Is the annotation used for the Object Cache then and not the Query Cache? > > On Wed, Feb 3, 2016 at 3:10 PM, Frank Herrmann < > frank.herrmann@modernizingmedicine.com> wrote: > >> So, is the CacheGroups annotation used by the query cache at all? If I >> have to set the cache group via code, then what purpose does the annotation >> serve? >> >> Thanks for the clarification. >> >> -Frank >> >> On Wed, Feb 3, 2016 at 3:08 PM, Andrus Adamchik >> wrote: >> >>> Ah, I think this is relevant: >>> >>> >>>>> If I specify the cache group in the code, i.e. >>> >>>>> query.setCacheGroups(), everything works fine, and the cache group >>> is >>> >>>>> utilized. >>> >>> This is needed. This is how Cayenne knows which cache group a query is >>> associated with. >>> >>> Andrus >>> >>> >>> >>> >>> > On Feb 3, 2016, at 11:04 PM, Frank Herrmann < >>> frank.herrmann@modernizingmedicine.com> wrote: >>> > >>> > Sure. It takes a few hops to get there but here it is. >>> > >>> > The actual search is done in our CayenneGenericDao class. The type >>> > parameter in this method is the StatusFirm class. >>> > >>> > public List find(Class type, SearchContext searchContext) >>> >> { >>> >> DataContext dataContext = getObjectContext(); >>> >> if >>> (FlushMode.ALWAYS.equals(DataContextUtils.getFlushMode(dataContext)) || >>> >> FlushMode.AUTO.equals(DataContextUtils.getFlushMode(dataContext))) >>> >> flush(); >>> >> Query query = getQuery(type, searchContext); >>> >> if (!validateContext(searchContext, query)) >>> >> return new ArrayList(0); >>> >> >>> >> if(type != null) >>> >> flushIfNecessary(type, dataContext); >>> >> List results = null; >>> >> if(query instanceof SelectQuery) >>> >> results = (List) doFind((SelectQuery)query, searchContext); >>> >> >>> >> else if(query instanceof SQLTemplate) >>> >> results = (List) doFind((SQLTemplate)query, searchContext, type == >>> >> null); >>> >> else >>> >> throw new IllegalArgumentException("Query type not supported " + >>> >> query.getClass()); >>> >> >>> >> if(type != null && Persistent.class.isAssignableFrom(type)) >>> >> CayenneObjectUtils.addFreshLoaded(dataContext, (List>> >> Persistent>)results); >>> >> return results; >>> >> } >>> > >>> > >>> > Here is the getQuery method. At the point where >>> query.setCacheStrategy() is >>> > call, the strategy is "CACHE", and it is being cached, just to the >>> default >>> > cache group. >>> > >>> > private Query getQuery(Class type, SearchContext searchContext) >>> >> { >>> >> if (searchContext == null) >>> >> return new SelectQuery(type); >>> >> >>> >> Object path = searchContext.getPath(); >>> >> Map params = searchContext.getParameters(); >>> >> if (params == null) >>> >> params = Collections.emptyMap(); >>> >> if (path != null) >>> >> { >>> >> Query query = resolveQuery(path); >>> >> if(query instanceof ParameterizedQuery) >>> >> { >>> >> query = ((ParameterizedQuery)query).createQuery(params); >>> >> } >>> >> return query; >>> >> } >>> >> SelectQuery query = new SelectQuery(type); >>> >> Object oCriteria = searchContext.getCriteria(); >>> >> if (oCriteria instanceof List) >>> >> { >>> >> List criteria = (List) searchContext.getCriteria(); >>> >> query.andQualifier(buildQualifiers(criteria, params)); >>> >> } >>> >> else if (oCriteria instanceof Expression) >>> >> { >>> >> query.andQualifier((Expression) oCriteria); >>> >> } >>> >> else if (oCriteria instanceof Criterion) >>> >> { >>> >> query.andQualifier(cayenneCriteriaAdaptor.adapt((Criterion) oCriteria, >>> >> params)); >>> >> } >>> >> else if (oCriteria != null) >>> >> throw new IllegalArgumentException("Criteria type not supported " + >>> >> oCriteria.getClass().getName()); >>> >> if (searchContext.getCacheStrategy() != null) { >>> >> >>> >> >>> query.setCacheStrategy(cacheStrategies.get(searchContext.getCacheStrategy())); >>> >> } >>> >> return query; >>> >> } >>> > >>> > >>> > >>> > Thanks Andrus. >>> > >>> > On Wed, Feb 3, 2016 at 2:14 PM, Andrus Adamchik < >>> andrus@objectstyle.org> >>> > wrote: >>> > >>> >> Do you have an example of SelectQuery fetching StatusFirms? >>> >> >>> >> Andrus >>> >> >>> >>> On Feb 3, 2016, at 10:12 PM, Frank Herrmann < >>> >> frank.herrmann@modernizingmedicine.com> wrote: >>> >>> >>> >>> Hi Andrus, >>> >>> >>> >>> Thanks for the quick reply. However, adding the filter didn't seem to >>> >> work. >>> >>> Below is my addition of the filter to our runtime. >>> >>> >>> >>> public synchronized static void initialize(String cayenneConfig) >>> >>>> { >>> >>>> if(cayenneRuntime != null) { >>> >>>> return; >>> >>>> } >>> >>>> >>> >>>> if(logger.isInfoEnabled()) { >>> >>>> logger.info("Loading cayenne domain config from " + cayenneConfig); >>> >>>> } >>> >>>> >>> >>>> Module module = new M2CayenneModule(); >>> >>>> cayenneRuntime = new ServerRuntime(cayenneConfig, module); >>> >>>> >>> >>>> CacheInvalidationFilter cacheInvalidationFilter = new >>> >>>> CacheInvalidationFilter(); >>> >>>> cayenneRuntime.getDataDomain().addFilter(cacheInvalidationFilter); >>> >>> >>> >>> >>> >>> Here is the annotation on an object: >>> >>> >>> >>> @CacheGroups("minimal_cache") >>> >>>> public class StatusFirm extends _StatusFirm implements >>> >>>> com.m2.domain.StatusFirm { >>> >>>> } >>> >>> >>> >>> >>> >>> However, when this object is returned during a find, it uses the >>> default >>> >>> cache group. Like I said, however, if I specify the cache group in >>> the >>> >>> code, it works. So I know ehcache is being used and is configured >>> >>> correctly. >>> >>> >>> >>> Thanks again for the help. >>> >>> >>> >>> -Frank >>> >>> >>> >>> >>> >>> >>> >>> On Wed, Feb 3, 2016 at 1:12 PM, Andrus Adamchik < >>> andrus@objectstyle.org> >>> >>> wrote: >>> >>> >>> >>>> Hi Frank, >>> >>>> >>> >>>> For the annotation to get processed, you will need to add >>> >>>> CacheInvalidationFilter to your ServerRuntime. Here is an example: >>> >>>> >>> >>>> >>> >>>> >>> >> >>> https://github.com/andrus/wowodc13/blob/94ac0f4920a5f494c4e73de717c05e5a54302921/editor/src/main/java/demo/editor/services/cayenne/EditorCayenneService.java >>> >>>> >>> >>>> Hope this helps, >>> >>>> Andrus >>> >>>> >>> >>>>> On Feb 3, 2016, at 7:55 PM, Frank Herrmann < >>> >>>> frank.herrmann@modernizingmedicine.com> wrote: >>> >>>>> >>> >>>>> Hello All, >>> >>>>> >>> >>>>> I was wondering if there is anything special I might be missing to >>> >>>> utilize >>> >>>>> the @CacheGroups annotation for query caching. I have successfully >>> >> gotten >>> >>>>> Cayenne to use Ehcache for query caching. I have cache groups >>> specified >>> >>>> in >>> >>>>> the ehcache.xml file. However, if I use the @CacheGroups >>> annotation on >>> >> an >>> >>>>> object, it appears to be ignored. The caching still goes to the >>> default >>> >>>>> cache. If I specify the cache group in the code, i.e. >>> >>>>> query.setCacheGroups(), everything works fine, and the cache group >>> is >>> >>>>> utilized. >>> >>>>> >>> >>>>> I am using Cayenne 3.1. >>> >>>>> >>> >>>>> Thanks to anyone who can point me in the right direction. >>> >>>>> >>> >>>>> -Frank >>> >>>>> >>> >>>>> -- >>> >>>>> FRANK HERRMANN >>> >>>>> SOFTWARE ENGINEER >>> >>>>> >>> >>>>> T: 561-880-2998 x1563 >>> >>>>> >>> >>>>> E: frank.herrmann@modmed.com >>> >>>>> >>> >>>>> >>> >>>>> >>> >>>>> [image: [ Modernizing Medicine ]] >>> >>>>> [image: [ Facebook ]] >> > >>> >>>> [image: >>> >>>>> [ LinkedIn ]] < >>> http://www.linkedin.com/company/modernizing-medicine/> >>> >>>> [image: >>> >>>>> [ YouTube ]] >>> >> [image: [ >>> >>>>> Twitter ]] [image: [ Blog ]] >>> >>>>> [image: [ Instagram ]] >>> >>>>> >>> >>>> >>> >>>> >>> >>> >>> >>> >>> >>> -- >>> >>> FRANK HERRMANN >>> >>> SOFTWARE ENGINEER >>> >>> >>> >>> T: 561-880-2998 x1563 >>> >>> >>> >>> E: frank.herrmann@modmed.com >>> >>> >>> >>> >>> >>> >>> >>> [image: [ Modernizing Medicine ]] >>> >>> [image: [ Facebook ]] >>> >> [image: >>> >>> [ LinkedIn ]] >> > >>> >> [image: >>> >>> [ YouTube ]] >>> [image: [ >>> >>> Twitter ]] [image: [ Blog ]] >>> >>> [image: [ Instagram ]] >>> >>> >>> >> >>> >> >>> > >>> > >>> > -- >>> > FRANK HERRMANN >>> > SOFTWARE ENGINEER >>> > >>> > T: 561-880-2998 x1563 >>> > >>> > E: frank.herrmann@modmed.com >>> > >>> > >>> > >>> > [image: [ Modernizing Medicine ]] >>> > [image: [ Facebook ]] >>> [image: >>> > [ LinkedIn ]] >>> [image: >>> > [ YouTube ]] >>> [image: [ >>> > Twitter ]] [image: [ Blog ]] >>> > [image: [ Instagram ]] >>> > >>> >>> >> >> >> -- >> FRANK HERRMANN >> SOFTWARE ENGINEER >> >> T: 561-880-2998 x1563 >> >> E: frank.herrmann@modmed.com >> >> >> >> [image: [ Modernizing Medicine ]] >> [image: [ Facebook ]] [image: >> [ LinkedIn ]] [image: >> [ YouTube ]] [image: [ >> Twitter ]] [image: [ Blog ]] >> [image: [ Instagram ]] >> >> >> > > > -- > FRANK HERRMANN > SOFTWARE ENGINEER > > T: 561-880-2998 x1563 > > E: frank.herrmann@modmed.com > > > > [image: [ Modernizing Medicine ]] > [image: [ Facebook ]] [image: > [ LinkedIn ]] [image: > [ YouTube ]] [image: [ > Twitter ]] [image: [ Blog ]] > [image: [ Instagram ]] > > > -- FRANK HERRMANN SOFTWARE ENGINEER T: 561-880-2998 x1563 E: frank.herrmann@modmed.com [image: [ Modernizing Medicine ]] [image: [ Facebook ]] [image: [ LinkedIn ]] [image: [ YouTube ]] [image: [ Twitter ]] [image: [ Blog ]] [image: [ Instagram ]] --001a1149922285feae052ae4400d--