File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Hibernate Join(ORM) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate Join(ORM)" Watch "Hibernate Join(ORM)" New topic

Hibernate Join(ORM)

Kalpesh K Rawal

Joined: Nov 23, 2005
Posts: 4
Can i map 2 tables in a singel class?if not then how can achive it?
Vikram Takkar

Joined: Oct 27, 2005
Posts: 12
i dont think that you can map 2 tables in single class ... you can map one table in one class and you can have more than one class mapping in one file but its not the good programming practice.. you should implement class-per-file mechanism....

i m giving this reply up to my knowledge ..this may b correct or may not be..

Vikram Takkar<br />Programmer
Naveen Mishra
Ranch Hand

Joined: Nov 20, 2005
Posts: 75
U can certainly do it man !!!

just go through the following link...
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

If you are using Hibernate3 then you can. Naveen Mishra's example doesn't map two tables to one class (though it does return data from two tables via HQL) - if you want the same behaviour via a mapping read the Hibernate documentation about the <join /> element.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
jQuery in Action, 3rd edition
subject: Hibernate Join(ORM)
It's not a secret anymore!