Topics

How to do range query with Datanucleus/JDO?


qquantum@...
 

What would be the Datanucleus/JDO implementation to this:
 
Suppose I have a POJO, `Hub` which represents a place/location:
 
```java
class Hub {
    List<Schedule> schedules; 
}
```
And a `Schedule` class to represent a specific day schedule of opening and closing of that place:
 
```
class Schedule {
    String day;
    LocalTime opens;
    LocalTime closes;
}
````
 
And then a query to those _Hubs_  to find which opens and closes during a specific day, say, query with this constraint:
 
```java
new Schedule().builder()
    .day("Monday")
    .opens(LocalTime.parse("09:00")
    .close(LocalTime.parse("17:00").build();
```
 
*Note that LocalTime is not Date*
 
So in this case we want to query for _Hubs_ that are open on Mondays at 9am to 5pm.   
 
 1. What would be the Datanucleus/JDO implementation for the `Hub`?
 2. What would be the query implementation to achieve the desired result as described? 
 


Andy
 
Edited

JDOQL would be something like
SELECT FROM mydomain.Hub WHERE this.schedules.contains(sch) && (sch.day == :schDay && sch.opens == :startTime && sch.closes == :endTime)
Left as an exercise to write that using JDOQLTyped syntax if that is what you're using.

No idea what you mean by "implementation for Hub"; they are your classes so you define them how you want them. "schedules" is simply a Collection field, hence a 1-N relation.