title: How to filter on the value of a specific element in a list?
body: <p>Using GAE-Java-JDO, is it possible to filter on the value of a specific element in a list?</p>
  <h1>WHAT WORKS</h1>
  <p>Normally, I would have the following:</p>
  <pre><code>@PersistenceCapable
  class A {
  
    String field1;
    String field2;
  
    // id, getters and setters
  
  }
  </code></pre>
  <p>Then I would build a simple query:</p>
  <pre><code>Query q = pm.newQuery(A.class, &quot;field1 == val&quot;);
  q.declareParameters(&quot;String val&quot;);
  List&lt;A&gt; list = new ArrayList&lt;A&gt;((List&lt;A&gt;) q.execute(&quot;foo&quot;));
  </code></pre>
  <h1>WHAT I WOULD LIKE</h1>
  <p>The above works fine. But what I would like to have is all of the fields stored in a list:</p>
  <pre><code>@PersistenceCapable
  class AA {
  
    ArrayList&lt;String&gt; fields;
  
    // id, getters and setters
  
  }
  </code></pre>
  <p>and then be able to query on a specific field in the list:</p>
  <pre><code>int index = 0;
  Query q = pm.newQuery(A.class, &quot;fields.get(index) == val&quot;);
  q.declareParameters(&quot;int index, String val&quot;);
  List&lt;A&gt; list = new ArrayList&lt;A&gt;((List&lt;A&gt;) q.execute(index, &quot;foo&quot;));
  </code></pre>
  <p>But this throws an exception:</p>
  <pre><code>org.datanucleus.store.appengine.query.DatastoreQuery$UnsupportedDatastoreFeatureException:
  Problem with query 
  &lt;SELECT FROM xxx.AA WHERE fields.get(index) == val PARAMETERS int index, String val,&gt;:     
  Unsupported method &lt;get&gt; while parsing expression: 
  InvokeExpression{[PrimaryExpression{strings}].get(ParameterExpression{ui})}
  </code></pre>
  <p>My impression from reading <a href="https://developers.google.com/appengine/docs/java/datastore/jdo/queries" rel="nofollow noreferrer">the GAE-JDO doc</a> is that this is not possible:</p>
  <blockquote>
  <p>&quot;The property value must be supplied by the application; it cannot refer to or be calculated in terms of other properties&quot;</p>
  </blockquote>
  <p>So... any ideas?</p>
  <p>Thanks in advance!</p>