aspose file tools
The moose likes Object Relational Mapping and the fly likes A simple Select HQL not working Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply Bookmark "A simple Select HQL not working " Watch "A simple Select HQL not working " New topic
Author

A simple Select HQL not working

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

This is the HQL written for retreving data from Two tables

String hql = "from Contact , Book";




But nothing gets printed on to the browser and no exception is shown anywhere . Can you please tell me whats ths problem is??

Thanks in advance.


Save India From Corruption - Anna Hazare.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Perhaps your query is retuirning nothing?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1104
    
    7

I'm still pretty new to Hibernate, so can I ask a stupid question prompted by this question?

How does Hibernate handle Cartesian (cross) products?

If the above query were written in SQL, my very limited understanding of Hibernate suggests it would look like:

SELECT * FROM Contact, Book

This would produce a combination of all possible row combinations from Contact and Book, with each row containing all attributes from both tables (which is why in SQL you always need a join condition to match the records from each table correctly e.g. WHERE Book.contact_id = Contact.contact_id).

Does Hibernate do the same thing here, or does it already know how to relate Contact and Book? And which objects does it return - Contact or Book - or does it already know how to cast the raw results back to one of these?

Actually, that's at least 3 stupid questions - sorry!


ex-Oracle bloke
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: A simple Select HQL not working
 
Similar Threads
Hibernate Exception Please Anybody Help Me.
Hibernate getting started
Stored Procedure inside HQL query?
How to use IN clause in HQL?
Hibernate mapping