Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

QuerySyntaxException

 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys!

I'm getting this error when I run my app. I can't seem to figure this out. I checked the names on my mapping but it doesn't seem to be the problem. Here is the error I'm getting:


[java] Mar 22, 2007 6:04:22 PM org.hibernate.impl.SessionFactoryObjectFacto
ry addInstance
[java] INFO: Not binding factory to JNDI, no JNDI name configured
[java] Hibernate:
[java] select
[java] max(MESSAGE_ID)
[java] from
[java] MESSAGES
[java] Hibernate:
[java] insert
[java] into
[java] MESSAGES
[java] (MESSAGE_TEXT, NEXT_MESSAGE_ID, MESSAGE_ID)
[java] values
[java] (?, ?, ?)
[java] Exception in thread "main" org.hibernate.hql.ast.QuerySyntaxExceptio
n: MESSAGES is not mapped [from MESSAGES m order by m.text asc]
[java] at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassP
ersister(SessionFactoryHelper.java:158)
[java] at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(
FromElementFactory.java:87)
[java] at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClau
se.java:70)
[java] at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWa
lker.java:255)
[java] at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBa
seWalker.java:3056)
[java] at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlS
qlBaseWalker.java:2945)
[java] at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBas
eWalker.java:688)
[java] at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalk
er.java:544)
[java] at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlS
qlBaseWalker.java:281)
[java] at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBase
Walker.java:229)
[java] at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTransl
atorImpl.java:228)
[java] at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTran
slatorImpl.java:160)
[java] at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTransl
atorImpl.java:111)
[java] at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.j
ava:77)
[java] at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.j
ava:56)
[java] at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(Que
ryPlanCache.java:72)
[java] at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(Abstra
ctSessionImpl.java:133)
[java] at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSe
ssionImpl.java:112)
[java] at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1
623)
[java] at hello.HelloWorld.main(Unknown Source)
[java] Java Result: 1

BUILD SUCCESSFUL
Total time: 4 seconds


here is my persistent class



and the mapping...



What could be wrong with this? Thanks in advance!
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
from MESSAGES m order by m.text asc


You should be using the class name in the query instead of the table name. It should be :

 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! You rock!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic