Return-Path: Delivered-To: apmail-db-torque-dev-archive@www.apache.org Received: (qmail 95738 invoked from network); 15 Jan 2008 17:33:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Jan 2008 17:33:03 -0000 Received: (qmail 26091 invoked by uid 500); 15 Jan 2008 17:32:52 -0000 Delivered-To: apmail-db-torque-dev-archive@db.apache.org Received: (qmail 26072 invoked by uid 500); 15 Jan 2008 17:32:52 -0000 Mailing-List: contact torque-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Apache Torque Developers List" Reply-To: "Apache Torque Developers List" Delivered-To: mailing list torque-dev@db.apache.org Received: (qmail 26061 invoked by uid 99); 15 Jan 2008 17:32:52 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Jan 2008 09:32:52 -0800 X-ASF-Spam-Status: No, hits=2.4 required=10.0 tests=DNS_FROM_OPENWHOIS,SPF_PASS,UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [70.103.251.107] (HELO scalix0.corp.dotster.net) (70.103.251.107) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Jan 2008 17:32:40 +0000 Received: from scalix0.corp.dotster.net (localhost [127.0.0.1]) by scalix0.corp.dotster.net (8.13.1/8.13.1) with ESMTP id m0FHWVJO007153 for ; Tue, 15 Jan 2008 09:32:31 -0800 Received: from scalix0.corp.dotster.net (root@localhost) by scalix0.corp.dotster.net (8.13.1/8.13.1/Submit) with ESMTP id m0FHWVd7007152 for ; Tue, 15 Jan 2008 09:32:31 -0800 Received: from localhost.localdomain (dotster-vip2.corp.dotster.net 70.103.251.2) by scalix0.corp.dotster.net (Scalix SMTP Relay 10.0.1.3) via ESMTP; Tue, 15 Jan 2008 09:32:30 -0800 (PST) Received: from brmiller by localhost.localdomain with local (Exim 4.67) (envelope-from ) id 1JEpeE-0002Ez-GH for torque-dev@db.apache.org; Tue, 15 Jan 2008 09:32:26 -0800 Date: Tue, 15 Jan 2008 09:32:26 -0800 From: "Brendan Miller" To: torque-dev@db.apache.org Message-ID: <20080115173226.GA8593@dotster.com> In-Reply-To: <20080110183045.GA19757@dotster.com> References: <20080110183045.GA19757@dotster.com> Subject: Re: determine if new criteria is called for x-scalix-Hops: 1 x-scalix-Authenticated-Sender: brmiller@dotster.com at 70.103.251.2 User-Agent: Mutt/1.5.15+20070412 (2007-04-11) MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline X-Virus-Checked: Checked by ClamAV on apache.org Can some kind soul shed some light on my predicament? Thanks, Brendan On Thu, Jan 10, 2008 at 10:30:45AM -0800, Brendan Miller wrote: > > I know we're in the middle of an RC release, but there is something that > continues to bother me. > > The generator for object classes creates > > public List getSomeClasss(Criteria criteria) throws TorqueException > > methods for each class that has a foreign key to this object's table. > In these methods, we have the following > > // the following code is to determine if a new query is > // called for. If the criteria is the same as the last > // one, just return the collection. > criteria.add(SomeClassPeer.MYCLASS_ID, getID()); > if (!lastSomeClassCriteria.equals(criteria)) > { > collSomeClasss = SomeClassPeer.doSelect(criteria); > } > > If my application does something like > > List allSomeClasses = getSomeClasss(); > > // ... > > Criteria crit = new Criteria(); > crit.add(SomeClassPeer.TYPE, "foo"); > List fooSomeClasses = getSomeClasss(crit); > > the last line will throw a NullPointerException because > > a) collSomeClasss is not null > b) the object is not new > c) lastSomeClassCriteria is null > > I have lots of occasion to find the releated SomeClass objects where > other criteria is in place, say an AMOUNT > 4.00 or a TYPE == "special" > or somesuch. I cannot use this method passing my own Criteria when the > whole list of related objects has already been retrieved (the collection > is no longer null), because the lastSomeClassCriteria is still null. > > Does this make sense? Please don't tell me that I'm "misusing Torque" > :) This seems so obvious. But then... > > Could it be fixed with a simple patch to the templates to replace > > if (!lastCriteria.equals(criteria)) > > with > > if (!criteria.equals(lastCriteria)) > > or > > if (lastCriteria == null || > !lastCriteria.equals(criteria)) > > ?? > > Thanks, > > Brendan Miller > > --------------------------------------------------------------------- > To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org > For additional commands, e-mail: torque-dev-help@db.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org For additional commands, e-mail: torque-dev-help@db.apache.org