Return-Path: Delivered-To: apmail-db-jdo-dev-archive@www.apache.org Received: (qmail 37932 invoked from network); 14 Oct 2005 21:53:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 14 Oct 2005 21:53:15 -0000 Received: (qmail 95372 invoked by uid 500); 14 Oct 2005 21:53:15 -0000 Mailing-List: contact jdo-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jdo-dev@db.apache.org Delivered-To: mailing list jdo-dev@db.apache.org Received: (qmail 95361 invoked by uid 99); 14 Oct 2005 21:53:15 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Oct 2005 14:53:15 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [192.18.98.36] (HELO brmea-mail-4.sun.com) (192.18.98.36) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Oct 2005 14:53:16 -0700 Received: from fe-amer-09.sun.com ([192.18.108.183]) by brmea-mail-4.sun.com (8.12.10/8.12.9) with ESMTP id j9ELqrJE016718 for ; Fri, 14 Oct 2005 15:52:53 -0600 (MDT) Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com (Sun Java System Messaging Server 6.1 HotFix 0.11 (built Jan 28 2005)) id <0IOD00I01E304K00@mail-amer.sun.com> (original mail from Craig.Russell@Sun.COM) for jdo-dev@db.apache.org; Fri, 14 Oct 2005 15:52:53 -0600 (MDT) Received: from [129.146.30.183] by mail-amer.sun.com (Sun Java System Messaging Server 6.1 HotFix 0.11 (built Jan 28 2005)) with ESMTPSA id <0IOD00DSAE4542N5@mail-amer.sun.com> for jdo-dev@db.apache.org; Fri, 14 Oct 2005 15:52:53 -0600 (MDT) Date: Fri, 14 Oct 2005 14:52:48 -0700 From: Craig L Russell Subject: Re: Query question In-reply-to: Sender: Craig.Russell@Sun.COM To: jdo-dev@db.apache.org Message-id: <75262636-4286-41B5-9A87-703E8BA30334@sun.com> MIME-version: 1.0 X-Mailer: Apple Mail (2.734) Content-type: text/plain; format=flowed; delsp=yes; charset=US-ASCII Content-transfer-encoding: 7BIT References: X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi Karan, On Oct 14, 2005, at 7:10 AM, Karan Malhi wrote: > Hi, > First of all, I am sorry, I could not contribute much in the past > two or > three weeks. Hopefully, I should be able to start contributing some > things > this weekend. > I had a question regarding queries. > I have two classes , Address and Customer. Customer has many Addresses > > class Address{ > private String city; > } > > class Customer{ > Set address = new HashSet(); //contains collection of Address objects > } > > I want to find those customers , which belong to cities which are > contained > in a collection. For example, if i had a collection of String objects, > containing city values like PA, CA , LA, and I wanted to find > customers > belonging to one of those cities, then would the following work. if > this > doesnt work, then what would be the solution for this query . > > Set allowed = new HashSet(); // allowed collection contains cities > (String) > allowed.add('ny'); > allowed.add('pa'); > query.setFilter("address.contains(add) && allowedCities.contains > (add.city > )"); > query.declareParameter(Set allowedCities); > query.setImports("import java.util.*"); > query.setVariable(Address add); > query.execute(allowed); Yes, this is a proper JDOQL query. Craig > > > -- > Karan Malhi >