I am using JDO on google app engine. Each 'Employee' has a 'key'. I have a set of keys and wanted to retrieve all Employees whose key belongs to this set.
So I implemented it using the 'contains()' filter as specified here. The code works fine and looks like this -
List<Key> keys = getLookupKeys(....) ..//Get keys from somewhere.
Query query = pm.newQuery(Employee.class,":p.contains(key)"); //What is ":P" here?
List<Employee> employees = (List<Employee>) q.execute(keys); //This correctly gives me all I want
All that I wonder is what is this ":P" in this query? The Employee object does not have any field named 'p' neither my query declares any such parameter. So what does this 'p' point to? Does 'p' has any special meaning?
I believe it's mapping an implicit input parameter. As there's only one parameter, you don't need to explicitly call
setParameter
, you can just use it. I believe it would have been okay as:which might be clearer.
See the "implicit parameters" part of the Apache JDOQL docs for another example.