Considering following correct query
select _.* from _misc._lang__ _ where _.id > 10 order by _.id asc limit 1 offset 0
Now I tried to make the JPQL query like this
select l from _misc._lang__ l where l.id > :arg order by l.id asc limit 1 offset 0
And the error(EclipseLink)
The ORDER BY clause has 'l.id ASC ' and 'limit ' that are not separated by a comma.
It seems eclipse link got the limit as column name rather than the keyword, now how can I fix it?
Thanks!
-
I suggest you learn the syntax of JPQL: it uses class names and not table names, it doesn't use .*, and it doesn't have limit and offset clauses. In short it's a different language from SQL, and you have to learn it.JB Nizet– JB Nizet2014年05月01日 20:23:48 +00:00Commented May 1, 2014 at 20:23
-
@JBNizet sorry, typo :Duser2889419– user28894192014年05月01日 20:36:47 +00:00Commented May 1, 2014 at 20:36
1 Answer 1
"limit" is not reconized. You can use yourQuery.setMaxresults method instead like so :
result=em.createQuery("select l.* from _misc._lang__ l where l.id > :arg order by l.id asc").setParameter("arg", yourArg).setMaxResults(2).getResultList()
answered May 1, 2014 at 20:30
Guillaume S
1,4882 gold badges19 silver badges33 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-sql