Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A simple Select HQL not working

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps your query is retuirning nothing?
 
chris webster
Bartender
Posts: 2407
33
Linux Oracle Postgres Database Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic