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 6EF849CF1 for ; Wed, 2 May 2012 16:38:34 +0000 (UTC) Received: (qmail 23472 invoked by uid 500); 2 May 2012 16:38:34 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 23416 invoked by uid 500); 2 May 2012 16:38:34 -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 23405 invoked by uid 99); 2 May 2012 16:38:34 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 May 2012 16:38:34 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.85.213.43] (HELO mail-yw0-f43.google.com) (209.85.213.43) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 May 2012 16:38:27 +0000 Received: by yhkk6 with SMTP id k6so1626716yhk.16 for ; Wed, 02 May 2012 09:38:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding:x-gm-message-state; bh=6NgqvsK8o0xkwGcW0wiVe/HORIMKbskeIMoZgGX4zLI=; b=o9jZSLdWEIgVffYpFhGuUC5DWZzry6lzo6Y1sY1N181BP/GRSjkrTierblJw5PLmyU ouhrO9sl8iCrRj+pfLaRgC5yvcSy5yZsPC+ezNALQmgQDhojfZ3go6AKepKqwyXmML3Z HT9maADTdghkbnt8n8ORmdveeVzqINukCTFgDh+hCGGVRhIzuYsr42NRQdhANgovDgwq PL6DZO6iLmuuAl709cnm6DQ2M1nNIXqDDeaA2oXZUUnIA6lubel/pdYTDkdRuuGKziI6 Yhh8od/Eb8Whzjx0lE8ZQltbkcrM2OMtKq/4CkSfxoOxCMcRwBSBc9lsu/lF9wnQX+mC 2PaA== Received: by 10.50.42.129 with SMTP id o1mr5898260igl.72.1335976686037; Wed, 02 May 2012 09:38:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.50.65.67 with HTTP; Wed, 2 May 2012 09:37:44 -0700 (PDT) In-Reply-To: <4FA153FC.5090505@itsurcom.com> References: <1335776991480-3950272.post@n3.nabble.com> <10487276-F7AA-424F-AC30-DDF37B5B123C@objectstyle.org> <1335778199194-3950308.post@n3.nabble.com> <34399D2C-D0A5-47E8-AE70-A9CBA4F3793C@objectstyle.org> <1335778527664-3950320.post@n3.nabble.com> <1335779141649-3950341.post@n3.nabble.com> <864E57FB-450C-456F-BD1D-B78B264AF07B@objectstyle.org> <1335779713917-3950361.post@n3.nabble.com> <1335781268404-3950419.post@n3.nabble.com> <4F9ECDB0.7020104@itsurcom.com> <4F9EE062.2070109@itsurcom.com> <4FA130FE.9010708@itsurcom.com> <4FA153FC.5090505@itsurcom.com> From: Michael Gentry Date: Wed, 2 May 2012 12:37:44 -0400 Message-ID: Subject: Re: Standalone app, Threads and Object contexts To: user@cayenne.apache.org, awillerding@itsurcom.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQlTa3i3oFR1r/EXEHLv29cn9rE7GWmpUOsmAF/HuCliEc6O2bjIpi1dZR2zaUvBmor21OcQ Hi Andrew, I do not believe you want to share a context like that. A DataContext is NOT thread safe between different threads. Also, even if you synchronized access to it further (to be thread safe), a single commit failure (such as a constraint exception) would doom all future commits because the shared DataContext is now dirty with uncommitable changes and nothing else can commit, either. Use individual DataContexts for related changes. If you re-use a DataContext, it should be applicable to a previous request (just like a web session re-attaches your HTTP Session). mrg On Wed, May 2, 2012 at 11:34 AM, Andrew Willerding wrote: > But just to confirm my understanding. =A0I can create one > DataContext(ObjectContext) and perform as many "simultaneous i.e. from > multiple threads" object creations, object updates, stored procedure > executions without concern as long as these creations/updates/stored > procedure executions are non-related and independent meaning one thread > that's doing a creation/update/stored procedure execution is not dependen= t > on a creation/update/execution going on in another thread. =A0Something l= ike > this