Reputation: 4999
Im getting following error while running the query.
org.hibernate.hql.ast.QuerySyntaxException: expecting CLOSE, found 'LIMIT' near line 1, column 194 [from com.claystone.db.Gpsdata where id.mobileunitid = '2090818044' and gpsdate in (select id.gpsdate from com.claystone.db.Gpsdata where id.mobileunitid = '2090818044' ORDER BY id.gpsdate DESC LIMIT 1 ) and gpsstatus='true']
This is my Query.Please give the suggession what is the mistake in this query?
data=session.createQuery[from com.claystone.db.Gpsdata where id.mobileunitid = '2090818044' and gpsdate in (select id.gpsdate from com.claystone.db.Gpsdata where id.mobileunitid = '2090818044' ORDER BY id.gpsdate DESC LIMIT 1 ) and gpsstatus='true']
Upvotes: 1
Views: 6496
Reputation: 254
On the other hand , If you use createQuery() instead of CreateSQLQuery() same error can be seen. "expecting CLOSE, found 'LIMIT'" or "expecting CLOSE, found 'NULL'
Upvotes: 0
Reputation: 9993
why are you using the subquery? just do it like this :
data=session.createQuery[from com.claystone.db.Gpsdata where id.mobileunitid = '2090818044' and gpsstatus='true' ORDER BY id.gpsdate DESC LIMIT 1]
you might need to take the LIMIT 1
off the end and use .setMaxResults(1)
on the query.
Upvotes: 4