Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Object Relational Mapping and the fly likes Data fetch from multiple SQL tables 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 "Data fetch from multiple SQL tables" Watch "Data fetch from multiple SQL tables" New topic
Author

Data fetch from multiple SQL tables

mallika arora
Greenhorn

Joined: Aug 02, 2007
Posts: 5
I am in the process of writing my first hibernate application. I have a sql query that fetches data from multiple tables using left and right outer joins. I need to convert this JDBC data access code into Hibernate code. The tables in SQL are not related using foreign keys.

I have created hibernate mapping for each table, datasource configuration xml and POJO for each table. I am unable to follow how to use HQL createQuery that would use table classes to retrieve data from 8 or 9 tables.

Any example of HQL fetching data from multiple tables would be a help.

Please advice.

Thanks,
Mallika
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

From the Hibernate documentation pages

Joins
http://www.hibernate.org/hib_docs/v3/reference/en/html/queryhql.html#queryhql-joins


Describing implicit versus explicit joins
http://www.hibernate.org/hib_docs/v3/reference/en/html/queryhql.html#queryhql-joins-forms

Where clauses
http://www.hibernate.org/hib_docs/v3/reference/en/html/queryhql.html#queryhql-where

Examples
http://www.hibernate.org/hib_docs/v3/reference/en/html/queryhql.html#queryhql-examples

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Aniket S. Kulkarni
Ranch Hand

Joined: Jun 15, 2011
Posts: 87

@Mark Spritzler: Sir, These are not valid links. Please provide new valid links. Thanks!


Aniket Kulkarni
Oracle Certified Professional, Java SE 6 Programmer.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Data fetch from multiple SQL tables
 
Similar Threads
Hibernate Query for multiple tables
Hibernate Query column number mismatch
Hibernate with native SQL issue
When Command Object/POJO is not sufficient
how to update multiple table in frame