Meaningless Drivel is fun!
The moose likes Object Relational Mapping and the fly likes mapping two tables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "mapping two tables" Watch "mapping two tables" New topic

mapping two tables

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

hi all,

i am new in hibernate.i want to map 2 classes..when i fetch value from one table(class) ,no problem.when i try two map 2 classes,i unable to fetch the data(innerjoin).so please anybody send some sample code to me.

i mean mapping classes...(how to map more than one class).

thanks & regards,
Khushwinder Chahal
Ranch Hand

Joined: Oct 03, 2007
Posts: 128
Hi Seetharam,

You need to study this link:

There is an excellent example.
If still unsuccessful send you code along with description on my email id.
I will try to solve.

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

thanks Khushwinder Chahal ..i will do it..

thanks & regards,
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

Here's a sweet tutorial on mapping two classes to a single table with Hibernate:

Mapping Two Classes to One Table with Hibernate and JPA Tutorial

But I think you might be more interested in mapping associated classes. Here's how to map two classes associated in a one to one manner:

Mapping One to One Associated Classes with Hibernate and JPA

There are other tutorials that cover other type of associations as well.

Happy Hibernating!

-Cameron McKenzie
I agree. Here's the link:
subject: mapping two tables
jQuery in Action, 3rd edition