I have requirement to map Different Table to one POJO class.
I want create single POJO class which contains fields from Both table.
Pleasez suggest me How to do hibernate mapping(Mapping *.hbm.xml file) for such
Thanks in Advance
You must have something like:
Mapping One Class to Two Tables: The Secondary Table!
One Class to Two Tables
From time to time, you'll run into a scenario where your application defines a single class, but the database maintains the correspoinding information in two separate tables. Well, with Hibernate, that's not a problem. All you have to do to map one class to two database tables is to define the first table mapping as you normally would, and then specify the name of the second table your class uses with the very intelligently named @SecondaryTable annotation. From there, when you get to a field that is supposed to be stored in the second table, well, you just mention the second table's name in the @Column annotation. It's all very simple and straight forward.
Here's a little scenario I map in a tutorial of mine. You'll notice that the code is pretty clean.
So there you go! It's as easy as using the SecondaryTable annotation!