These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: exception in simple hql-query '... is not mapped.'
PostPosted: Tue Mar 15, 2005 11:12 am 
Newbie

Joined: Fri Mar 11, 2005 4:34 am
Posts: 1
Hi,

I am getting an Exception 'QuerySyntaxError: users is not mapped. [from users]' in my small application (see full stacktrace below). I tripel checked and the 'users' table and mapping is in place, I actually use it already for inserts and updates, just queries don't work.
Does anybody know what it means?

Here is the code

Session session = SessionManager.currentSession();
Query userQuery = session.createQuery("from users");
List list = userQuery.list();

If I use the following code:

Criteria us = session.createCriteria(User.class);
Iterator it = us.list().iterator();

it works fine.
Also I found in the debug log the following entry:

15:34:46,562 INFO HbmBinder:256 - Mapping class: com.endress.infoserve.wam.bo.impl.User -> users
15:34:46,562 DEBUG HbmBinder:1086 - Mapped property: id -> user_oid
15:34:46,562 DEBUG HbmBinder:1086 - Mapped property: locale -> locale
15:34:46,562 DEBUG HbmBinder:1086 - Mapped property: sites

[b]Hibernate version:[/b]
Hibernate 3.0rc1

[
[b]Full stack trace of any exception that occurs:[/b]
org.hibernate.hql.ast.QuerySyntaxError: users is not mapped. [from users]
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:74)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:195)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:414)
at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:814)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:773)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at com.endress.infoserve.wam.bo.impl.Backend.getUser(Backend.java:48)
at com.endress.infoserve.wam.test.SiteTest.main(SiteTest.java:42)
Caused by: users is not mapped.
at org.hibernate.hql.ast.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:81)
at org.hibernate.hql.ast.FromElementFactory.addFromElement(FromElementFactory.java:77)
at org.hibernate.hql.ast.FromClause.addFromElement(FromClause.java:71)
at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:223)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:2312)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2232)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:498)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:356)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:184)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:140)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189)
... 8 more
Exception in thread "main"
[b]Name and version of the database you are using:[/b]
SAPDB 7.5
[b]The generated SQL (show_sql=true):[/b]

[b]Debug level Hibernate log excerpt:[/b]

15:34:46,562 INFO HbmBinder:256 - Mapping class: com.endress.infoserve.wam.bo.impl.User -> users
15:34:46,562 DEBUG HbmBinder:1086 - Mapped property: id -> user_oid
15:34:46,562 DEBUG HbmBinder:1086 - Mapped property: locale -> locale
15:34:46,562 DEBUG HbmBinder:1086 - Mapped property: sites


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 11:34 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You have to query for the class, not for the table name


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.