This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Hibernate: Problem getting a simple list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate: Problem getting a simple list" Watch "Hibernate: Problem getting a simple list" New topic
Author

Hibernate: Problem getting a simple list

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

I am trying to get a simple list of departments from an employee table in my database using Hibernate. Appearntly this simple task is fairly difficult since Hibernate is all about populating objects with data. Anyway, here is the query I am using:



the createSQLQuery uses the Employee.class to determine the column, I think, so here is my Employee.hbm.xml



I am getting the following exception:



Any ideas?


GenRocket - Experts at Building Test Data
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Hibernate is claiming your ID column doesn't exist in the DB. Is it there?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
pascal betz
Ranch Hand

Joined: Jun 19, 2001
Posts: 547
hi Gregg

why do you use SQL ?

if i got it right, then you can use

the hibernate reference has a chapter on
HQL
in section 11.4 you can find some examples for the thing (i think) you want to do.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Hibernate: Problem getting a simple list
 
Similar Threads
Who can solve that?
Unknown entity class: java.lang.Integer
Hibernate: Column not found. org.hibernate.exception.GenericJDBCException
Invalid Mapping Exception while inserting data through hibernate
Deleting Record in a Web Application.