File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Data fetch from multiple SQL tables Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply 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: 17224
    
    1

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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel/download
 
subject: Data fetch from multiple SQL tables
 
Similar Threads
how to update multiple table in frame
Hibernate Query for multiple tables
When Command Object/POJO is not sufficient
Hibernate Query column number mismatch
Hibernate with native SQL issue