db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Karan Malhi <karan.ma...@gmail.com>
Subject Query question
Date Fri, 14 Oct 2005 14:10:44 GMT
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);


--
Karan Malhi

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message