J'ai fait des critères, mais quand j'utilise setMaxResults, il me donnera une exception SQLGrammarException. Mais quand je commente setMaxResults, cela retournera toutes les entrées après le premier résultat. J'utilise la base de données MySQL.Hibernate en utilisant les critères setMaxResults donnant SQLGrammarException
code:
return criteria
.setFirstResult(start)
.setMaxResults(end)
.setFetchSize(end)
.list();
Exception:
org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2536)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:119)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1716)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
....
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ...
Essayez de régler la « propriété show_sql' true et vérifier la requête générée essayer figureout problème il –