Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id C14B8200C1C for ; Wed, 15 Feb 2017 17:41:08 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id BF3BB160B4D; Wed, 15 Feb 2017 16:41:08 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E024C160B5E for ; Wed, 15 Feb 2017 17:41:07 +0100 (CET) Received: (qmail 59247 invoked by uid 500); 15 Feb 2017 16:39:23 -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 53375 invoked by uid 99); 15 Feb 2017 16:31:54 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Feb 2017 16:31:54 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id DAE911A0473 for ; Wed, 15 Feb 2017 16:31:53 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.379 X-Spam-Level: ** X-Spam-Status: No, score=2.379 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id UQuVIS-3_5TK for ; Wed, 15 Feb 2017 16:31:51 +0000 (UTC) Received: from mail-vk0-f54.google.com (mail-vk0-f54.google.com [209.85.213.54]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 4C3935FAFB for ; Wed, 15 Feb 2017 16:31:51 +0000 (UTC) Received: by mail-vk0-f54.google.com with SMTP id k127so102095630vke.0 for ; Wed, 15 Feb 2017 08:31:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=tzz1KD/9PHY4fI3IyIyElhZl/aXlilyrHzh0mEt9rJ8=; b=s0AnoT30kFCU8eRTOPURkz9qu8pvGZfbmr8x6DBBeTy1wCwAcdw3KA+vLBQ5nHsNy9 GWJnp7eimMM9+5bRRp/ZxQrwcg1GG2NDUBhveK/T8NBzuEqQ8lMPYICg40ao/kFQ4gsQ mB0KKju0EBqOHOFRO84ghXeQb66ycVNWZhkzxhHd6dmaW1OgxjSNi5xnJ2T1ELN2oY/I VnPq+wCuxFSb3QqBZxQJYHDEwwvCSk40P1s/IwHS7b52YdCbTjBKXKXjBeM2mTSbv7O3 /dGWwp/Bl6apNoNqLaB3Tl4MgUDG+xMZfSwKO10Y0Ircd//qQg8F4DslR9/dGBXhrVpE mDjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=tzz1KD/9PHY4fI3IyIyElhZl/aXlilyrHzh0mEt9rJ8=; b=GcabD5R8nC8L/TFyQLetlxmJeVASH6beNruGvOZ6as5mxxkVKXhWUtDM5C6tesvqwk rc83spR07W4d0lu+zBuw9llZlUCRYqcGH44KkUWoPFSjfdrlToTj/HBj3kvrRqPkKSDv bDSXzCOVcODOjSi6BWyqKV5weSHev/CnNrekbWi9CruxXaZHwCvmxUEHPJqYNsg5O/sU UgaZv4BPC9ybE9Hta/0BW3C9UsUImn7EY6Fl2X9LZzdrXQHsuYRNdbHP1dMeWFhXTwSg jXrR6y3QlgLbv+posShqYIdVct/QRxsrLCP+QTvtqI+ZmceHN7i/bqN+fg5/hnW448Ac 9Rzg== X-Gm-Message-State: AMke39mQGgQWdus4EMVNVFFWybPSgOF+8TtBbNWGvfn989eZ/UDlek6K2aY2ENLfP5yDnSNhg9QSR1jUXy9Pmw== X-Received: by 10.31.170.15 with SMTP id t15mr15209463vke.6.1487176303130; Wed, 15 Feb 2017 08:31:43 -0800 (PST) MIME-Version: 1.0 Received: by 10.103.48.208 with HTTP; Wed, 15 Feb 2017 08:31:12 -0800 (PST) In-Reply-To: <8F187B59-872E-4A6F-8DE8-F2FE21CE2316@selbstdenker.ag> References: <8EABE69D-34DA-4978-B03B-5BACB159E9A1@karlmenn.is> <9AB3B549-019B-4CE3-BA18-4D7C9D3BC03B@me.com> <8CBA7A66-C983-4132-8718-189D44B335DF@amphorainc.com> <00433A51-9F43-49A3-A922-E0F38E5D9A4A@karlmenn.is> <7EBF25B3-C736-4FDD-8C90-B5E23D8D9458@karlmenn.is> <183437D8-9C5E-4127-983B-0C115BE8C2B2@me.com> <7B465EA9-F014-45F8-90DD-3546CCB67F14@amphorainc.com> <8F187B59-872E-4A6F-8DE8-F2FE21CE2316@selbstdenker.ag> From: Michael Gentry Date: Wed, 15 Feb 2017 11:31:12 -0500 Message-ID: Subject: Re: Creating a fault for an ObjectId To: Cayenne Users Content-Type: multipart/alternative; boundary=001a11432250448863054894375e archived-at: Wed, 15 Feb 2017 16:41:08 -0000 --001a11432250448863054894375e Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Maik, Would it be possible to use child DataContexts and then push the changes up to the parent? On Wed, Feb 15, 2017 at 11:17 AM, Musall, Maik wrote= : > The use case is as follows. > > I have a large collection of objects which I want some function to be > executed on. I want to use multiple threads to do this, so AFAIK I have t= o > use separate ObjectContexts per thread like in EOF. So, I will then > instantiate those objects in the per-thread contexts, do the processing, > but then the wrapper function should return the entire collection of > processed objects in the original context that they were in at the > beginning. > > With EOF, I have a snapshot cache that will contain the changed > attributes, but the EO instances in the original context have their > original values. So, I will then call ec.faultForGlobalID() to have them > refaulted from the snapshot cache, avoiding to refetch 100.000 objects fr= om > db. > > I suppose using a shared cache would make the problem obsolete, as those > objects would receive changed attributes automatically, but I'm still on > the fence whether or not to use a shared cache, because it's a major > behavioural difference to EOF and I still have to think about that while > migrating my project. > > Maik > > > > Am 15.02.2017 um 15:49 schrieb Ken Anderson >: > > > > Yes, use the objectID to pass around, but on the receiving end, you > should turn it into a fault and release it into the wild. Then, if some > code needs it, the fault fires, otherwise =E2=80=93 no DB activity. > > > > Ken Anderson > > CTO Amphora, Inc. > > Mobile: +1 914 262 8540 > > > > > > > > www.amphorainc.com > > > > > > > > > > On 2/15/17, 10:47 AM, "Amedeo Mantica" wrote: > > > > I would just use the ObjectId > > > >> On 15 Feb 2017, at 16:45, Hugi Thordarson wrote: > >> > >> It can be useful in some cases=E2=80=94one example is if you want to b= e able to > pass objects around in an API without triggering a DB fetch unless they a= re > actually used. > >> > >> Cheers, > >> - hugi > >> > >> > >>> On 15. feb. 2017, at 15:28, Amedeo Mantica > wrote: > >>> > >>> no worries, but I cannot understand your goal, why do you want to get > the fault ? > >>> > >>>> On 15 Feb 2017, at 16:25, Hugi Thordarson wrote: > >>>> > >>>> Thanks Ken, but the immediate fetch performed by Cayenne.objectForPk > is precisely what I=E2=80=99d like to avoid. > >>>> > >>>> Cheers, > >>>> - hugi > >>>> > >>>> S: Amedeo, sorry about calling you =E2=80=9CAmadeo=E2=80=9D in my la= st post. I have > been properly lambasted. > >>>> > >>>> > >>>>> On 15. feb. 2017, at 15:20, Ken Anderson < > ken.anderson@amphorainc.com> wrote: > >>>>> > >>>>> I do this: > >>>>> > >>>>> dataObject =3D (DataObject) Cayenne.objectForPK(getObjectContext(), > MyEntity.class, oid); > >>>>> > >>>>> But it will do the fetch if it=E2=80=99s not already in cache. > >>>>> > >>>>> Ken > >>>>> > >>>>> Ken Anderson > >>>>> CTO Amphora, Inc. > >>>>> Mobile: +1 914 262 8540 > >>>>> > >>>>> > >>>>> > >>>>> www.amphorainc.com > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> On 2/15/17, 9:59 AM, "Hugi Thordarson" wrote: > >>>>> > >>>>> Thanks Amadeo, but I ended up creating a method that looks like > this. It would be nice to get some feedback on it, if I=E2=80=99m violati= ng any > Cayenne Commandments. > >>>>> > >>>>> /** > >>>>> * @return An existing object or fault if registered with the OC, > otherwise creates a new hollow object based on the given ObjectId. > >>>>> */ > >>>>> public static Persistent faultForObjectId( ObjectContext oc, > ObjectId objectId ) { > >>>>> Persistent object =3D (Persistent) oc.getGraphManager().getNode( > objectId ); > >>>>> > >>>>> if( object =3D=3D null ) { > >>>>> ClassDescriptor descriptor =3D oc.getEntityResolver(). > getClassDescriptor(objectId.getEntityName()); > >>>>> > >>>>> object =3D (Persistent) descriptor.createObject(); > >>>>> > >>>>> object.setPersistenceState(PersistenceState.HOLLOW); > >>>>> object.setObjectContext(oc); > >>>>> object.setObjectId(objectId); > >>>>> > >>>>> oc.getGraphManager().registerNode(objectId, object); > >>>>> } > >>>>> > >>>>> return object; > >>>>> } > >>>>> > >>>>> Cheers, > >>>>> - hugi > >>>>> > >>>>> > >>>>>> On 15. feb. 2017, at 14:41, Amedeo Mantica > wrote: > >>>>>> > >>>>>> may be you want invalidateObject ? > >>>>>> > >>>>>>> On 15 Feb 2017, at 14:15, Hugi Thordarson > wrote: > >>>>>>> > >>>>>>> Hi all, > >>>>>>> I need to get a fault for an ObjectId from an ObjectContext. How > would I do this? > >>>>>>> > >>>>>>> I don=E2=80=99t see any public API for this=E2=80=94the implement= ation of > createFault in CayenneContext seems to get me halfway there, but it will > not return an existing fault, only create new ones. > >>>>>>> > >>>>>>> Cheers, > >>>>>>> - hugi > >>>>>> > >>>>> > >>>>> > >>>>> > >>>>> Confidentiality Notice: This e-mail and accompanying documents > contain confidential information intended for a specific individual and > purpose. This e-mailed information is private and protected by law. If yo= u > are not the intended recipient, you are hereby notified that any > disclosure, copying, or distribution, or the taking of any action based o= n > the contents of this information, is strictly prohibited. > >>>> > >>> > >> > > > > > > > > Confidentiality Notice: This e-mail and accompanying documents contain > confidential information intended for a specific individual and purpose. > This e-mailed information is private and protected by law. If you are not > the intended recipient, you are hereby notified that any disclosure, > copying, or distribution, or the taking of any action based on the conten= ts > of this information, is strictly prohibited. > > --001a11432250448863054894375e--