net.sf.hibernate.QueryException: unexpected token: in [from Person in class com.vcdeals.db2.Person]

Hibernate JIRA | Neil Katin | 1 decade ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    I'm kind of hoping I'm just confused because it seems a bit hard to believe: findAll() doesn't seem to work. This is using the standard FinderRenderer in the net.sf.hibernate.tool.hbm2java package. The generated findAll looks like this: public static List findAll() throws SQLException, HibernateException { Session session = com.vcdeals.BrokerManager.getSession(); List finds = session.find("from Person in class com.vcdeals.db2.Person"); return finds; } This code generates the following hibernate error: net.sf.hibernate.QueryException: unexpected token: in [from Person in class com.vcdeals.db2.Person] at net.sf.hibernate.hql.FromParser.token(FromParser.java:89) at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87) at net.sf.hibernate.hql.PreprocessingParser.token(PreprocessingParser.java:123) at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29) at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149) at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138) at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:293) at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1530) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1501) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1491) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1483) at com.vcdeals.db2.PersonFinder.findAll(PersonFinder.java:47) at com.vcdeals.servlet.AdminServlet.ensureAdminUser(AdminServlet.java:127) at com.vcdeals.servlet.AdminServlet.init(AdminServlet.java:108) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1044) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:887) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3948) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4271) (and so on...) Replacing the find query string with "from Person as person" cures the problem -- the find works. Here's a context diff of FinderRenderer with the source patched to automatically generate this: *** FinderRenderer.java Sat Feb 21 17:21:52 2004 --- FinderRenderer.java.fixed Sun Feb 22 14:56:29 2004 *************** *** 243,250 **** + "throws SQLException, HibernateException {"); writer.println(" Session session = " + sessionMethod); } ! writer.println(" List finds = session.find(\"from " + classMapping.getName() ! + " in class " + classMapping.getPackageName() + "." + classMapping.getName() + "\");"); writer.println(" return finds;"); writer.println(" }"); writer.println(); --- 243,251 ---- + "throws SQLException, HibernateException {"); writer.println(" Session session = " + sessionMethod); } ! writer.println(" List finds = session.find(\"from " + classMapping.getName() ! + " as " + classMapping.getName().toLowerCase() ! + "\");"); writer.println(" return finds;"); writer.println(" }"); writer.println();

    Hibernate JIRA | 1 decade ago | Neil Katin
    net.sf.hibernate.QueryException: unexpected token: in [from Person in class com.vcdeals.db2.Person]
  2. 0

    I'm kind of hoping I'm just confused because it seems a bit hard to believe: findAll() doesn't seem to work. This is using the standard FinderRenderer in the net.sf.hibernate.tool.hbm2java package. The generated findAll looks like this: public static List findAll() throws SQLException, HibernateException { Session session = com.vcdeals.BrokerManager.getSession(); List finds = session.find("from Person in class com.vcdeals.db2.Person"); return finds; } This code generates the following hibernate error: net.sf.hibernate.QueryException: unexpected token: in [from Person in class com.vcdeals.db2.Person] at net.sf.hibernate.hql.FromParser.token(FromParser.java:89) at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87) at net.sf.hibernate.hql.PreprocessingParser.token(PreprocessingParser.java:123) at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29) at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149) at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138) at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:293) at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1530) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1501) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1491) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1483) at com.vcdeals.db2.PersonFinder.findAll(PersonFinder.java:47) at com.vcdeals.servlet.AdminServlet.ensureAdminUser(AdminServlet.java:127) at com.vcdeals.servlet.AdminServlet.init(AdminServlet.java:108) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1044) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:887) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3948) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4271) (and so on...) Replacing the find query string with "from Person as person" cures the problem -- the find works. Here's a context diff of FinderRenderer with the source patched to automatically generate this: *** FinderRenderer.java Sat Feb 21 17:21:52 2004 --- FinderRenderer.java.fixed Sun Feb 22 14:56:29 2004 *************** *** 243,250 **** + "throws SQLException, HibernateException {"); writer.println(" Session session = " + sessionMethod); } ! writer.println(" List finds = session.find(\"from " + classMapping.getName() ! + " in class " + classMapping.getPackageName() + "." + classMapping.getName() + "\");"); writer.println(" return finds;"); writer.println(" }"); writer.println(); --- 243,251 ---- + "throws SQLException, HibernateException {"); writer.println(" Session session = " + sessionMethod); } ! writer.println(" List finds = session.find(\"from " + classMapping.getName() ! + " as " + classMapping.getName().toLowerCase() ! + "\");"); writer.println(" return finds;"); writer.println(" }"); writer.println();

    Hibernate JIRA | 1 decade ago | Neil Katin
    net.sf.hibernate.QueryException: unexpected token: in [from Person in class com.vcdeals.db2.Person]
  3. 0

    Hibernate - Query Exception

    Coderanch | 1 decade ago | Parameswaran Thangavel
    net.sf.hibernate.QueryException: expecting 'elements' or 'indices' after: stCd [select rsc.twarsrcAdrs.stCd from com.metlife.us.ins.enroll.wrkpladv.wpa.bo.Twarsrc rsc where rsc.rsrcId = 24932]
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. net.sf.hibernate.QueryException

      unexpected token: in [from Person in class com.vcdeals.db2.Person]

      at net.sf.hibernate.hql.FromParser.token()
    2. net.sf.hibernate
      SessionImpl.find
      1. net.sf.hibernate.hql.FromParser.token(FromParser.java:89)
      2. net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
      3. net.sf.hibernate.hql.PreprocessingParser.token(PreprocessingParser.java:123)
      4. net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29)
      5. net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)
      6. net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)
      7. net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:293)
      8. net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1530)
      9. net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1501)
      10. net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1491)
      11. net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1483)
      11 frames
    3. com.vcdeals.db2
      PersonFinder.findAll
      1. com.vcdeals.db2.PersonFinder.findAll(PersonFinder.java:47)
      1 frame
    4. com.vcdeals.servlet
      AdminServlet.init
      1. com.vcdeals.servlet.AdminServlet.ensureAdminUser(AdminServlet.java:127)
      2. com.vcdeals.servlet.AdminServlet.init(AdminServlet.java:108)
      2 frames
    5. Glassfish Core
      StandardContext.start
      1. org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1044)
      2. org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:887)
      3. org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3948)
      4. org.apache.catalina.core.StandardContext.start(StandardContext.java:4271)
      4 frames