• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

QuerySyntaxException: "Tablename is not mapped"

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am new to hibernate so I have a question (working on eclipse with JBoss Hibernate tools). I used "Hibernate Code Generation..." in order to get the class and mapping files of an existing database.

In order to test if everything worked fine I opened the HQL editor and wrote the select written bellow but I get this exception. The name of the class (Tablename) is case sensitive (I have read of this error).

I looked at the classes and the mapping files (*.hbm.xml) and the table exists as mapping file and as class and it was registered also in the configuration file.

What is my fault?

org.hibernate.hql.ast.QuerySyntaxException: Tablename is not mapped [SELECT id
FROM Tablename
WHERE number = '400']

Thank you very much.
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kai, could you be sure this line is in your hibernate configuration file:

?

Thanks
 
Kai Allard
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

thank you for your advice.
I have added the line to the config file and refreshed the project to no result, I am afraid. Still the same error.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello "KaiAllard"
Welcome to JavaRanch

We are glad to have you here. We have a naming policy at JavaRanch. Your displayed name must consist of a first name (or an initial), a space, and a family name (in that order) and not be obviously fictitious. Please take a moment to change it, which you can do right here.
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

org.hibernate.hql.ast.QuerySyntaxException: Tablename is not mapped



You will have to mention the mapping in your hibernate.cfg.xml. Can you post the contents of your hibernate.cfg.xml?
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sebastian, thanks for taking time to change your display name

We need a few more things to be able to figure out what the issue is.

1) The contents of the hbm.xml for that specific class/table that you are trying to query.
2) The code where you are building the SessionFactory
3) The logs when the SessionFactory is being built
4) The entire exception stacktrace that you are seeing.

In the meantime, can you try out the following:

If your hibernate POJO class (lets call it User) is inside the package named myPackage, then try out this HQL


Note that the User is the classname and not the tablename and also the usr.id and usr.number are members of the User class.

[Jaikiran: Edited to remove specific references to tables, on original poster's request]
[ July 04, 2007: Message edited by: Jaikiran Pai ]
 
Kai Allard
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sorry to have bothered you with that question, but as I have asked because I wasn't sure the database I use is not an open source now (maybe later...) so i am not allowed (at this moment) to employ Hibernate tools and "reverse engineering" on it.

So I deleted my posts.

PS: I would be glad if you could also delete any special information concerning the database out of your posts. Thank you very much.
[ July 04, 2007: Message edited by: Sebastian Strempel ]
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sebastian Strempel:
PS: I would be glad if you could also delete any special information concerning the database out of your posts. Thank you very much.



Done.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I would guess you miss understood the ejb-ql thing ....

thats your statement:
SELECT id FROM Tablename WHERE number = '400'
I would use that one:
select obj.id from Objectname as obj where number ='400';

means:
the ejb-ql syntax is used with Objects and its attributes, NOT with tablenames or tablecolums at all.
Thats the magic behind the loosely coupled paradigm behind the entity beans.

Cheers Jens
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic