File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Hibernate: Column not found.  org.hibernate.exception.GenericJDBCException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate: Column not found.  org.hibernate.exception.GenericJDBCException" Watch "Hibernate: Column not found.  org.hibernate.exception.GenericJDBCException" New topic
Author

Hibernate: Column not found. org.hibernate.exception.GenericJDBCException

Natalie Ap
Ranch Hand

Joined: Jan 09, 2009
Posts: 49
Hi all,

I am stuck with this since a very long time. I am getting this error for an HQL or a native sql query in hibernate. I

request you to help me. I am unable to find the post where this has been discussed before. Kindly help!


Error


Code


xml files



Rahul Babbar
Ranch Hand

Joined: Jun 28, 2008
Posts: 210
Hi,

Most of the things seem right...
Is the User table is already present in your database or are you trying to create it using Hibernate.

I have a suggestion...change the table name in your hbm and the database to a name other than 'USER'..
to
<class name="User" table="USER_LOGIN">
or something like that..and make sure the table name in your DB is USER_LOGIN(or something else, but not USER)

I vaguely remember that sometime back, i was getting some weird error by using Hibernate with MySQL while trying to name the table name as USER....and hibernate complained...and changing the table name did the trick...
It sounds silly, but is true..(as far as i remember)


Rahul Babbar
Natalie Ap
Ranch Hand

Joined: Jan 09, 2009
Posts: 49
Hi Rahul,

Thanks for the quick response.

Tell you what..This code worked fine till Thurs. On Friday, I was tinkering around a bit trying to learn how to enable the Hibernate caching and connection pooling. After that, this weird error started appearing for ALL queries in my code.. So I changed my hibernate config file to what it was before. The DB was not touched, not was the code. But this error ha been coming and I cannot figure out what to do about it.


Any clues anyone? Please help!

Thanks,
Natalie




Rahul Babbar wrote:Hi,

Most of the things seem right...
Is the User table is already present in your database or are you trying to create it using Hibernate.

I have a suggestion...change the table name in your hbm and the database to a name other than 'USER'..
to
<class name="User" table="USER_LOGIN">
or something like that..and make sure the table name in your DB is USER_LOGIN(or something else, but not USER)

I vaguely remember that sometime back, i was getting some weird error by using Hibernate with MySQL while trying to name the table name as USER....and hibernate complained...and changing the table name did the trick...
It sounds silly, but is true..(as far as i remember)

Emanuel Kadziela
Ranch Hand

Joined: Mar 24, 2005
Posts: 186
Try to print out the actual SQL hibernate generates (put in the options like hibernate.show_sql=true, etc.) and see what exactly is getting translated into col_0_0.
Raakhi Khatwani
Greenhorn

Joined: Jan 31, 2011
Posts: 1
Well i have been facing the same issue.
the query works fine if i do not use aliases. but if i use them i keep getting JDBC exceptions
Jan 31, 2011 3:05:10 PM org.hibernate.type.NullableType nullSafeGet
INFO: could not read column value from result set: id; Column 'id' not found.
Jan 31, 2011 3:05:10 PM org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 0, SQLState: S0022
Jan 31, 2011 3:05:10 PM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: Column 'id' not found.

This is the query:

HIbernate: SELECT Reports.id reportId,Reports.studyId As 'studyId',Reports.name As 'Name',Reports.type As 'Periodicity',Users.name As 'Created By',Reports.status As 'Status' FROM Studies INNER JOIN Reports ON Reports.studyId=Studies.id INNER JOIN Users ON Users.id=Reports.createdBy WHERE (Studies.id = 127) AND (Reports.templateId IS NULL) AND (Reports.isDeleted = false)

when i copy and paste it in my SQL Browser, i get results.

I would be greatful if someone could shed some light
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Hibernate: Column not found. org.hibernate.exception.GenericJDBCException
 
Similar Threads
Hibernate: Problem getting a simple list
Getting strange message
[Hibernate3.0] Filters, DB2 => invalid parameter number
Hibernate SQLGrammarException
query a database table using a foreign key ( where) using Hibernate.