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 41E8C200B7E for ; Tue, 6 Sep 2016 23:01:19 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 40CAD160ACB; Tue, 6 Sep 2016 21:01:19 +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 88513160AA9 for ; Tue, 6 Sep 2016 23:01:18 +0200 (CEST) Received: (qmail 83010 invoked by uid 500); 6 Sep 2016 21:01:17 -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 82998 invoked by uid 99); 6 Sep 2016 21:01:17 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Sep 2016 21:01:17 +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 F0AC0C0361 for ; Tue, 6 Sep 2016 21:01:16 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.299 X-Spam-Level: * X-Spam-Status: No, score=1.299 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=smarthealth-com.20150623.gappssmtp.com Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id tZKM7K26zOjn for ; Tue, 6 Sep 2016 21:01:14 +0000 (UTC) Received: from mail-pf0-f174.google.com (mail-pf0-f174.google.com [209.85.192.174]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with ESMTPS id 696B75FC13 for ; Tue, 6 Sep 2016 21:01:14 +0000 (UTC) Received: by mail-pf0-f174.google.com with SMTP id 128so2596156pfb.3 for ; Tue, 06 Sep 2016 14:01:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smarthealth-com.20150623.gappssmtp.com; s=20150623; h=from:subject:message-id:date:to:mime-version; bh=P7BExnaS2ddHrqUBD3JDP2yg98qB7j6Bwv6Du1i0Pbc=; b=XiVzgQWgb1pF56VbKvvhgqpsTrznoZfTj09kkmZHQhc4wl1UCapWNqXvjNg6B3MCy8 MRQLyQuHuWOBVjMPiEK1pqyik+Wo5LIc2xicLmNx4m+h79hDCOB8+ZYjX7RCyj9y/UGm y/Imtv/Lb3PijXvePGOe+n3pakAwY7vJq5xodzSB5Ja+AvQZgQ5Wsz1BXEAQJESFEw6O 9Nyj4l5Vxh7uEOWcdo4s/8UbHj7u85Vms0fCldFya+J5K6gkybDSebBiVF5PiF0cLmY3 YonCRCOOQsCwblrTr/+WLYH2kX9CEDSIAzvugVdz+42M/lZ9Cvw4g1BIQ1iN35LVAVWO lCVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:subject:message-id:date:to:mime-version; bh=P7BExnaS2ddHrqUBD3JDP2yg98qB7j6Bwv6Du1i0Pbc=; b=HrZLHEgQgHRJIbKp3WqHppBqrAHpfwLCf+m9mK0imbq5738QpJ3YB5uTkDwSULCll5 /KG2+99zEC0210M3qnLci8+025Rasl4iH9TGrTjedCePn0u6PKcnWr28L2zkCuK/Pl80 TI+Ql1c8hQQ/VvgsCQL+PZk6qXeG0FURa+WU5qpxgkMC4qhcHp/mJRQjRE1GkRPOLMxi wIM6lKCX5aLOZyOrXLb7usj8NmAPWBlY1ekonCo+7laWCZLcTON3USlswDExOngIj/8p SfFwcB6jbQi8gMj1qJh9Ci+amO8XuWW5k+MUfwkcl6nTXINCTdJsoCi4Mmq8A4HymqLZ H7Ig== X-Gm-Message-State: AE9vXwM4LiEy0Io+lLlPdGLmaEMHD3sp2+X8SPiS+BUjjFkW3t7psuydgNLR+LLWn34LejqS X-Received: by 10.98.32.140 with SMTP id m12mr19951718pfj.15.1473195673330; Tue, 06 Sep 2016 14:01:13 -0700 (PDT) Received: from botulism.workstations.smarthealth.com ([65.121.92.28]) by smtp.gmail.com with ESMTPSA id d5sm43144989pfc.4.2016.09.06.14.01.12 for (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Sep 2016 14:01:12 -0700 (PDT) From: Ramsey Gurley Content-Type: multipart/alternative; boundary="Apple-Mail=_620ABE1D-565F-40CF-AD1F-61A49A7E6B64" Subject: ServerRuntime from ObjectContext Message-Id: <3E821683-E61D-4E67-86CF-3EFA1DECC6B9@smarthealth.com> Date: Tue, 6 Sep 2016 14:01:10 -0700 To: user@cayenne.apache.org Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) X-Mailer: Apple Mail (2.1878.6) archived-at: Tue, 06 Sep 2016 21:01:19 -0000 --Apple-Mail=_620ABE1D-565F-40CF-AD1F-61A49A7E6B64 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 Hi all, Long time EOF/WebObjects user, new to Cayenne. I=92m finding a lot of = Cayenne is very similar to EOF. There are clearly major differences too. = One of these is the ServerRuntime concept. It seems like it is fairly = similar to an EOObjectStoreCoordinator at first glance, but I=92m = finding it is quite different.=20 Let me share some code to illustrate my confusion: final ServerRuntime first =3D new ServerRuntime("cayenne-project.xml"); final ServerRuntime second =3D new ServerRuntime("cayenne-project.xml"); final ServerRuntime third =3D new ServerRuntime("cayenne-project2.xml"); final ObjectContext oc =3D first.newContext(); final ObjectContext oc2 =3D second.newContext(oc); final ObjectContext oc3 =3D third.newContext(oc); final ObjectContext oc4 =3D third.newContext(); final ObjectContext oc5 =3D first.newContext(oc4); final Customer c1 =3D Customer.customerForLoginId(oc, "login id"); final Customer c2 =3D Customer.customerForLoginId(oc2, "login id"); final Customer c3 =3D Customer.customerForLoginId(oc3, "login id"); final Customer c4 =3D Customer.customerForLoginId(oc4, "login id"); final Customer c5 =3D Customer.customerForLoginId(oc5, "login id"); where public static Customer customerForLoginId(final ObjectContext context, = final String loginId) { return SelectQuery.query(Customer.class, = LOGIN_ID.eq(loginId)).selectOne(context); } cayenne-project.xml contains all my cayenne models. cayenne-project2.xml = is entirely empty. Exceptions are not thrown until the last two lines = fetching c4 and c5. I didn=92t expect to make it past oc2. I only = expected c1 to work for fetching. In the given situation, I=92m obviously working on authentication. In = the EOF code there is a process that logs a login attempt. In order to = do that in EOF, I use a peer editing context to create, edit, and save = the log object to the database. Therefore, I need a way to get a peer = ObjectContext given an ObjectContext. Thus far, the best I=92ve come up = with is to have a public static final ServerRuntime stashed on a utility = class, and use that one instance for everything=85 but this seems to go = against all the work done with dependency injection. I tried to follow = the advice found in this message, = http://cayenne.markmail.org/search/?q=3Dpeer+objectcontext#query:peer%20ob= jectcontext+page:2+mid:v77r6qhv6c4m72iy+state:results but storing the Injector in the user properties breaks serialization of = the ObjectContext. Is there an easy way to get a peer OC that I am = missing? Also, how do I know the OC is appropriate for something like a = SelectQuery? Do I need to wrap all calls in try blocks in case some code = hands in the wrong ServerRuntime=92s OC? Thanks, Ramsey --Apple-Mail=_620ABE1D-565F-40CF-AD1F-61A49A7E6B64--