This discussion is archived
3 Replies Latest reply: Apr 8, 2013 8:34 AM by 999980 RSS

SQL Grammar Exception in Hibernate

996004 Newbie
Currently Being Moderated
I executed this query on HQL query editor in netbeans 6.9.1.

from teacher

But I got an error like below..

org.hibernate.exception.SQLGrammarException: could not execute query
     at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
     at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
     at org.hibernate.loader.Loader.doList(Loader.java:2223)
     at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
     at org.hibernate.loader.Loader.list(Loader.java:2099)
     at org.hibernate.hql.classic.QueryTranslatorImpl.list(QueryTranslatorImpl.java:912)
     at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
     at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
     at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
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 'from limit 100' at line 1
     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
     at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
     at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
     at com.mysql.jdbc.Util.getInstance(Util.java:381)
     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1030)
     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
     at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936)
     at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
     at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542)
     at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734)
     at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1885)
     at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
     at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
     at org.hibernate.loader.Loader.doQuery(Loader.java:674)
     at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
     at org.hibernate.loader.Loader.doList(Loader.java:2220)
     ... 8 more
How can i fix this error.

Thanks in Advance

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points