EJBQL Problem
Hi All,
I have a problem regarding my EJBQL query , and have no idea where the problem is - I am a novice, so any help would be much appreciated.
The EJBQL:
SELECT DISTINCT OBJECT(h)
FROM House h, Location l WHERE l.name = ?1 AND h.bedrooms = ?2
AND h.price BETWEEN ?3 AND ?4
The bedrooms and price conditions work, the problem occurs in the location. For example, I put in Headingley (for location name), 3 (for bedrooms), and 0 (for min price) and 500000 (for max. price). It should display no results, as there are no properties in headingley, however it displays the details of a house located in Harehills which has 3 bedrooms and is between the prices specified. Any ideas why it is ignoring the location condition?
Thanks again,
Pete
Hi All,
Thanks for all the suggestions - and indeed I needed to include a join to the location table. However, I have hit another problem - the EJBQL is now:
SELECT DISTINCT OBJECT(h) FROM House h, Location l
WHERE h.location = l.name
AND l.description = ?1
AND h.bedrooms = ?2
AND (h.price BETWEEN ?3 AND ?4)
But now I recieve the following exception upon deploying:
Error: line(2) column(43): JDO75311: Invalid argument(s) for '='.
; requested operation cannot be completed
Any ideas what this means and how to correct it?
Thanks,
Pete
Please try this query,
SELECT DISTINCT OBJECT(h) FROM Location l, IN (l.houses) As h
WHERE l.name = ?1 AND h.bedrooms = ?2 AND h.price BETWEEN ?3 AND ?4
provided you have two EJBs LocationEJB and HouseEJB and they have a one-to-many relationship and houses is the CMR field name in LocationEJB.