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.
Halcon Guatemala
Ranch Hand
Joined: Sep 06, 2006
Posts: 57
posted
0
Hi Kai, could you be sure this line is in your hibernate configuration file:
?
Thanks
"La verdadera sabidur�a viene del temor de Dios"
Kai Allard
Greenhorn
Joined: Jul 03, 2007
Posts: 3
posted
0
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.
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.
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
Joined: Jul 03, 2007
Posts: 3
posted
0
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 ]
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.
J Straube
Greenhorn
Joined: Feb 22, 2010
Posts: 1
posted
0
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.