Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 18972 invoked from network); 7 Feb 2010 10:40:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 7 Feb 2010 10:40:56 -0000 Received: (qmail 29478 invoked by uid 500); 7 Feb 2010 10:40:55 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 29434 invoked by uid 500); 7 Feb 2010 10:40:54 -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 29424 invoked by uid 99); 7 Feb 2010 10:40:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 07 Feb 2010 10:40:54 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of razumovsky.andrey@gmail.com designates 74.125.82.43 as permitted sender) Received: from [74.125.82.43] (HELO mail-ww0-f43.google.com) (74.125.82.43) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 07 Feb 2010 10:40:46 +0000 Received: by wwi17 with SMTP id 17so1142605wwi.16 for ; Sun, 07 Feb 2010 02:40:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type; bh=L3X+NbF474q4ChjPukx9debsc5DhUk0BOX2cIhhmqT4=; b=jXjrD351f8w3dd9WpEkHNElff2vXG7PnafPfcH79S+RheC1YIvxHZq4B2daklc+6Vb 3nbhJ6YvoonuT4Z2opWIvsyD2I/3rgogC7Yl90GZANIX1TV5Uwh4JG6M8VEFhIYBSXrP +T/XPcSQ6EhYYg6zDG5sPdXD0niXugReLwypU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=hHwra/K//gsneF9EcYHlULCA8zi3/eEmY1WUfhPG5Sc16h40WBG+kyRHRXSHzUbhs2 UIDrtLzqKPqhaVNgCBzo89gACMTa4M0JuIOUYiCObZD8PQoR3jWHNEsop9WoOMs1wDbX JiyNDizgksxs/fLF/ycBSBtVeNjCjgcP52E+U= MIME-Version: 1.0 Received: by 10.216.88.195 with SMTP id a45mr2842212wef.63.1265539224268; Sun, 07 Feb 2010 02:40:24 -0800 (PST) In-Reply-To: <70CF30D5-20D6-4576-AC98-6530722ADFF7@lindesay.co.nz> References: <70CF30D5-20D6-4576-AC98-6530722ADFF7@lindesay.co.nz> From: Andrey Razumovsky Date: Sun, 7 Feb 2010 13:40:04 +0300 Message-ID: <3219fff71002070240x5ed09d0q4c55bf46c8245f17@mail.gmail.com> Subject: Re: ObjectIdQuery Question To: user@cayenne.apache.org Content-Type: multipart/alternative; boundary=0016e6d99a21e970be047f004f37 --0016e6d99a21e970be047f004f37 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable DataContext should be created via DataContext.createDataContext() if you're using shared configuration (cayenne.xml in classpath). Although there could be changes in 3.1 shapshot - I think Andrus i=D1=8B reworking something the= re. Also the simplest way to get DataObject for PK is Cayenne.objectForPk(...) in 3.1 and DataObjectUtils.objectForPk(...) in 3.0 2010/2/7 Andrew Lindesay > Hello; > > I am using 3.1 snapshot and am trying to do this in order to get an > DataObject instance for the ObjectId which I have; > > DataContext dc =3D new DataContext(); > ObjectId xyzObjectId =3D xyzObjectIds.get(i); > XYZ xyz =3D (XYZ) dc.performQuery(new > ObjectIdQuery(xyzObjectId)).get(0); > > I get an NPE here; > > > org.apache.cayenne.util.ObjectContextQueryAction.runQuery(ObjectContextQ= ueryAction.java:335) > at > org.apache.cayenne.util.ObjectContextQueryAction.execute(ObjectContextQue= ryAction.java:96) > at > org.apache.cayenne.access.DataContext.onQuery(DataContext.java:1049) at > > org.apache.cayenne.access.DataContext.performQuery(DataContext.java:1038) > > Which is this in code; > > protected void runQuery() > { this.response =3D actingContext.getChannel().onQuery(actingConte= xt, > query); } > > The problem is that there is no channel on the context. > > Am I using the API correctly? > > Regards; > > ___ > Andrew Lindesay > www.lindesay.co.nz > > --=20 Andrey --0016e6d99a21e970be047f004f37--