I have a query which join many tables and retrives a sorted list of objects.
If my parent table has two children records, i am getting a list of 3 records as result. So i have used rownum to get only one(first) record.
My query looks like this:
@NamedQuery(name = "getResultByStatus", query = "select new com.Result(id, updatedDateH) from (select a.id as id, b.updatedDate as updatedDateH from User u,Parent a left outer join a.child b where a.status = :status and (u.id=b.updatorId or u.id=a.creatorId) order by b.updatedDate desc) where rownum<2")
this gives me the error:
QuerySyntaxException: unexpected token: select near line 1.
Would you please help me on this ?
|