Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Hibernate: query returning data from multiple tables

 
Sunit Naik
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have very recently started working with hibernate and things were moving fine when the queries were getting columns from a single Table.
I have a hibernare query which returns data from multiple tables.

It selects data from three tables based on a join condition

1. tbl_site

2. tbl_ste2sitmgr

3. tbl_sitemanager

tbl_ste2sitmgr is basically a link between site and sitemanager, and contains a fk of site and a fk of sitemanager.

a site can have only one manager but a manager can manage many sites.

lets say this is the hibernate query statement



what kind of class should result belong to so that all the retrieved columns be effectively accessed.

I am sorry if this question sounds too lame, but I am a newbie in the hibernate/ORM world. Any help would be deeply appreciated

Thanks


 
Ankit Garg
Sheriff
Posts: 9597
36
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your relationship is a one-to-many relationship. One Manager can be associated with many Sites. You can execute a query from any direction. If you retrieve a Site class object, it will have a Manager class object. If you retrieve a Manager class object, then it will have a list of Site class objects...
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!