I'm using Objectdb, an object database, to save Cars to rent and requests for rental. When one customers ask for a rental of a car, I have to check if the car is available in that period (from start date to end date). In my database I have two tables (two classes): car and rent. This is the query to check if the car is available:
public List<Car> findByType(CarType type, Date start, Date end) {
TypedQuery<Car> query = em.createQuery("SELECT c FROM Car c, Rental r "
+ "WHERE c.type = :cartype AND "
+ "((r.start > :start AND r.start > :end) OR "
+ "(r.end < :start AND r.end < :end))", entityClass);
...
The problem is that this query always return 0 cars available. Is there a problem with a JOIN in JPQL? Or, is the query bad formed? thank you