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 A5996200BA4 for ; Sat, 15 Oct 2016 23:35:00 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 964FB160AF1; Sat, 15 Oct 2016 21:35:00 +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 DC0E1160AD9 for ; Sat, 15 Oct 2016 23:34:59 +0200 (CEST) Received: (qmail 73835 invoked by uid 500); 15 Oct 2016 21:34:59 -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 73822 invoked by uid 99); 15 Oct 2016 21:34:58 -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; Sat, 15 Oct 2016 21:34:58 +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 2FA6E1A00D3 for ; Sat, 15 Oct 2016 21:34:58 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.179 X-Spam-Level: * X-Spam-Status: No, score=1.179 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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 mnV5CT9FrnwQ for ; Sat, 15 Oct 2016 21:34:56 +0000 (UTC) Received: from mail-qt0-f170.google.com (mail-qt0-f170.google.com [209.85.216.170]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 2DCA95FAFA for ; Sat, 15 Oct 2016 21:34:56 +0000 (UTC) Received: by mail-qt0-f170.google.com with SMTP id f6so97774243qtd.2 for ; Sat, 15 Oct 2016 14:34:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=fm0kncM8NFKs6RnnpZnOvbxRa+o+slD1qslb/NhSmIM=; b=wTY+WiIzW3Y/8ha5Lujwfu+7lescF+yuqDcMBt4UPvcqfRmp/9x74vXC1T2AL0GxPU CNQuER5SWeISC6NXInTCKg4B1vADVaQiI8RGXUKVTEbfFAUojNHg/NWZlf8wmF+C/akJ 139LNQGVlIT/y8UW/MaRbKezSrhV0HX4DjFHE5B2ipoxNh5LiTzZ0opdXb/clVAcw9Cd Geie7F5m5+3MjRRa7JBaCoBQG7bXGFB8HdQ5mYoPNmA3JLis+jFc3AFzPG2RL9iuH+tQ iIO/H+hUVTf/Rfg1m5z9//uLLpfl/msBAPE0gdYDmmqwmN3ht2LteVwPeuAQvZKY/VVI 5tGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=fm0kncM8NFKs6RnnpZnOvbxRa+o+slD1qslb/NhSmIM=; b=TLBte721E/A4AXJXwsTjMhtlTrTQbEz9Q+V9fmX7L3Z8ewd33vVunyHoHI3+YOJ9eE JoiIkrEO62TpjatmK9LJ6BEuJ6XBIyCegp+GV0kKIKVCLXThs4KlXUcqQmE0wccjoYQp WPWM68pnN7zfPDWuv+wX4VwrK/lqIEsuIyhLXwxEzHYr4hirjMxc28bP7/RBssOVIO+7 OE7PSXiJO+sL7LzeRrrEXCNkzJ70bTUbPZ1johi6VxqS7QMSDMynWfgvMJxEVHUkGBBC w/L6GeDR4UeNfpDiaBQpHG32SZWEwCaKOJgs/i5uf+Nsj+oNP0ZPebv0+AM/pVzEdVH3 5MgQ== X-Gm-Message-State: AA6/9RkzHjgo7/nYQAlPw9RgueDMtLW+sI3VT6kW+uUjRZJEdvy+GDiH5G/mWFKgS7+Q+Yls3rP05LJHpeOzAw== X-Received: by 10.200.53.82 with SMTP id z18mr18942461qtb.82.1476567290109; Sat, 15 Oct 2016 14:34:50 -0700 (PDT) MIME-Version: 1.0 References: <719B6EE0-825F-4657-B80B-014A120B13A6@wardle.org> In-Reply-To: From: John Huss Date: Sat, 15 Oct 2016 21:34:39 +0000 Message-ID: Subject: Re: Batch iteration To: user@cayenne.apache.org Content-Type: multipart/alternative; boundary=001a113a7a1cd066f7053eee1cf9 archived-at: Sat, 15 Oct 2016 21:35:00 -0000 --001a113a7a1cd066f7053eee1cf9 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I would use a peer context. You can create a peer context like this if you runtime has been bound to the current thread using CayenneRuntime.bindThreadInjector(runtime.getInjector()) public static ObjectContext newObjectContext() { ObjectContextFactory factory =3D CayenneRuntime.getThreadInjector ().getInstance(ObjectContextFactory.class); return (factory !=3D null) ? factory.createContext() : null; } On Sat, Oct 15, 2016 at 2:37 PM Mark Wardle wrote: > Sorry=E2=80=A6 meant to say using Cayenne M4.0.M3=E2=80=A6 > > Mark > > > On 15 Oct 2016, at 20:29, Mark Wardle wrote: > > > > I=E2=80=99m using ResultBatchIterator like this: > > > > Consumer forEach =3D ... > > try (ResultBatchIterator iterator =3D query.batchIterator(context, > batchSize)) { > > for(List batch : iterator) { > > for (T c : batch) { > > forEach.accept(c); > > } > > } > > } > > > > but I also want to do some processing, inserting rows, editing objects > etc. I see lots of SQL in my logs, but the transaction doesn=E2=80=99t ge= t > committed until the batch iterator completes, whether I use > context.commitChanges() or context.performGenericQuery() on some custom S= QL > created using SQLTemplate. > > > > Is there a way of committing the transaction earlier, or should I use a > peer object context? Is there an easy of getting a new peer editing conte= xt > given a single object context or do I need to inject a ServerRuntime here= ? > > > > Thank you, > > > > Mark > > > > > > --001a113a7a1cd066f7053eee1cf9--