db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Bouschen <mbo.t...@spree.de>
Subject Re: #key and #value in query filter?
Date Tue, 30 Oct 2007 20:02:05 GMT
Hi Matthew,

I think the equivalent JDOQL would be:

  Query q = pm.newQuery(Item.class);
  q.declareVariables("String key");
  q.setFilter("this.images.containsKey(key) && ((key == 'thumbnail') || 
(key ==  'full') || (key == 'high-res'))");
  List result = q.execute();

or as single String JDOQL:

  SELECT this.images.get(key) FROM Item
  WHERE this.images.containsKey(key) && ((key == 'thumbnail') || (key 
==  'full') || (key == 'high-res'))
  VARIABLES String key

Alternatively you can pass the string literals used the 'in' clause as a 
collection parameter:

  Collection keys = new HashSet();
  Query q = pm.newQuery(Item.class);
  q.declareVariables("String key");
  q.declareParakmeters("java.util.Collection keys");
  q.setFilter("this.images.containsKey(key) && keys.contains(key)");
  List result = q.execute(keys);

Regards Michael

> Hi all,
> I just proposed in JPA on the thread for support for Maps that JPAQL 
> support "#key" and "#value" for navigation through maps, much like we 
> can use "#key" and "#value" to define fetch groups in JDO.  I took for 
> granted that these expressions can be used in JDOQL, and after a 
> search through the spec, I don't see where they can.  I only see the 
> list of supported Map and Collection methods in 14.6.2, "Filter 
> specfication".
> One of the JPA examples in the proposal looks like the following:
> SELECT im#value
> FROM Item i JOIN i.images im
> WHERE im#key in ('thumbnail', 'full', 'high-res')
> First, what would the equivalent JDOQL for this be?
> Second, what are your thoughts on JDOQL support for "#key", "#value" 
> and "in"?  This would allow us to write the following.  This is 
> decidedly not very Java-like (a design goal of JDOQL), so this would 
> be a bit of a departure from tradition for JDOQL.
> -matthew

Tech@Spree Engineering GmbH  Tel.: +49/(0)30/235 520-33
Buelowstr. 66                Fax.: +49/(0)30/217 520-12
10783 Berlin                 mailto:mbo.tech@spree.de 
Geschaeftsfuehrung: Anna-Kristin Proefrock
Sitz Berlin, Amtsgericht Charlottenburg, HRB 564 52

View raw message