Ok, I solved it. 
Solution is to hard code it in query like this:

select from C1 where key == :keys && date > 1436905284198



Am Donnerstag, 16. Juli 2015 21:41:56 UTC+2 schrieb Marcus Masekowsky:
>
> now I am asking me how to pass the second parameter value to the query:
> select from C1 where key == :keys && date > :date
>
> ":keys" is a list of keys and ":date" is a single long value.
>
> I execute the query with 
> query.execute(keyList);
>
> The method "execute" only takes one parameter. 
>
>
>
>
>
>
> Am Donnerstag, 16. Juli 2015 20:45:45 UTC+2 schrieb Marcus Masekowsky:
>>
>> I found the solution. I used the wrong syntax. Thanks for your help:
>>
>> Correct is:
>>
>> String queryBatch = "select from " + C1.class.getName() 
>>  + " where " + Model.KEY_FIELD + " == :keys"
>>  +" && " + C1.C1_DATE_FIELD + " > :date"
>>
>> Am Dienstag, 14. Juli 2015 22:27:32 UTC+2 schrieb Patrice (Cloud Platform 
>> Support):
>>>
>>> Hi Marcus, 
>>>
>>> I know this won't give you anything more than what you already have, but 
>>> can you try running your second query "queryBatchString", but without the 
>>> filter for  the date field?
>>> And could you copy the string for "queryBatchString"? Because looking at 
>>> how you build it, your keys should be after your "where", but it seems to 
>>> have trouble parsing "AND encodedKey", which should never be in the string 
>>> in the first place.
>>>
>>> Cheers!
>>>
>>>
>>> On Monday, July 13, 2015 at 4:54:30 PM UTC-4, Marcus Masekowsky wrote:
>>>>
>>>> Hi, thanks for your reply.
>>>>
>>>> to clarify, I have one query which retrieves the keys for Entity C1, 
>>>> This query is not my focus, because it onlys fetches the keys which I will 
>>>> later use to get the Entities from class C1.
>>>> So I have a list with keys from Entity C1. C1 has an attribute date of 
>>>> type long (Calendar Timemillis). Now I want to select all Entities with 
>>>> their Key in my keyList AND date > currDate.
>>>>
>>>>
>>>> Am Sonntag, 12. Juli 2015 19:50:27 UTC+2 schrieb Marcus Masekowsky:
>>>>>
>>>>> Hi,
>>>>>
>>>>> I am trying to add a AND-Expression to a GAE batch query to filter 
>>>>> Entities:
>>>>>
>>>>> Currently I am doing this, and it works perfect:
>>>>> 1. 
>>>>> DBQuery.selectFromKeysOnly -> Query to select Entitie by key
>>>>>
>>>>> 2. 
>>>>> String queryBatchString = "select from " + C1.class.getName() 
>>>>>  + " where " 
>>>>>                                  + Model.KEY_FIELD + " == :keys";
>>>>> 3. 
>>>>> Query query = pm.newQuery(queryBatchString);
>>>>> modelList = (List<Model>)query.execute(encodedKeyList);
>>>>>
>>>>> The disadvantage with that approach is, that the query in step 2 
>>>>> always returns all Entities. But I only want Entites which have a date > 
>>>>> current Date. Currently I am filtering the Entities in the server code 
>>>>> (Step 4). 
>>>>> To avoid this, I changed the query in 2. and added an "AND" expression 
>>>>> to filter the entities directly:
>>>>>
>>>>> String queryBatchString = "select from " + C1.class.getName() 
>>>>>  + " where " 
>>>>>                                  + Model.KEY_FIELD + " == :keys"
>>>>>  +  " AND " + C1.C1_DATE_FIELD + " > "+ currDate.getTimeInMillis();
>>>>>
>>>>>
>>>>> But with this change I get an QueryCompilerSyntaxException:
>>>>> "
>>>>> Portion of expression could not be parsed: AND encodedKey == :keys
>>>>> org.datanucleus.store.query.QueryCompilerSyntaxException: Portion of 
>>>>> expression could not be parsed: AND encodedKey == :keys
>>>>> "
>>>>>
>>>>> What is wrong or what can be done better. Are AND-Expressions not 
>>>>> allowed in Bbatch Queries?
>>>>>
>>>>>
>>>>> Thanks 
>>>>> Marcus
>>>>>
>>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/272793b9-2f9c-48a2-bea7-80b65b9df1fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to