如何解决在Java中的以下问题? [英] How to solve following issue in java?
本文介绍了如何解决在Java中的以下问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
org.hibernate.hql.ast.QuerySyntaxException:期待CLOSE,找到'LIMIT'在第1行第194列[来自com.claystone.db.Gpsdata其中id.mobileunitid ='2090818044'和gpsdate in(从id.cpsd.db.Gpsdata中选择id.gpsdate,其中id.mobileunitid ='2090818044' ORDER BY id.gpsdate DESC LIMIT 1)和gpsstatus ='true']
这是我的查询。请给出suggession这个查询中的错误是什么?
data = session.createQuery [from com.claystone.db.Gpsdata其中id.mobileunitid ='2090818044'和gpsdate(选择id.gpsdate从com.claystone.db.Gpsdata其中id.mobileunitid ='2090818044'ORDER BY id.gpsdate DESC LIMIT 1)和gpsstatus ='true']
解决方案
为什么使用子查询?就像这样做:
data = session.createQuery [from com.claystone.db.Gpsdata where id.mobileunitid =' 2090818044'和gpsstatus ='true'ORDER BY id.gpsdate DESC LIMIT 1]
您可能需要在结束时使用 LIMIT 1
并在查询中使用 .setMaxResults(1)
。
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']
解决方案
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.
这篇关于如何解决在Java中的以下问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文