How to get entity between two dates in appengine datastore for

I have an appointment table with appointment date as one of the columns. I want to get all appointments between two dates in the appengine store using JPA. please let me know how to achieve this? I tried the following request but it didn't work.

select a from Destination a where (apptSts = 'p' or apptSts = 'a') and (apptDate> =: fromDate or apptDate <=: toDate)

+3


source to share


4 answers


To get appointments between two dates, you need to change your query logic to include " and " instead of " or ":

select a from Appointment
where apptDate>=fromDate and apptDate<=toDate

      



You can have inequality files on the same property in the appengine, but they cannot be combined with OR.

See examples in the gql link , which should also apply to JPA.

+3


source


Make property as list property. Then you can request between two dates. See the following test code done at Objectify. I think you can use the same technique in JPA as well. https://github.com/stickfigure/objectify/blob/master/src/test/java/com/googlecode/objectify/test/QueryExoticTypesTests.java



+3


source


You can apply multiple inequality, but they must be in the same field (variable). I think what is going wrong is that the application engine does not allow for parenthesis elements, I mean

(conditionA AND conditionB .....) OR (conditionC AND conditionC .....)
//--this is not allowed.

      

By the way, the following is acceptable (I tried)

(conditionA AND conditionB .....) AND (conditionC AND conditionC)
//--allowed(although its bracket are meaning less here)

      

0


source


You can only do one more or less query, so one way to do this is to do more than a query and view the results and manually filter those that do not match the query than the query.

-2


source







All Articles