naveenm wrote:
I want to know that can we take data from different tables as a single Value Object(VO)?
Means I am having a single class which is having 8 properties and I have created three tables viz t1,t2,t3.
I want to take 3 filed of my VO from table t1, 3 rom table t2,3 filed of my VO from table t1, 2 from table t3.
There may be the possibility that i can get a list of VO.
Can it be possible?
You can get muliple objects per selected row with HQL.
The minimum grain of a single object as the hibernate mapping describes. You can't pick and choose columns from different objects and have Hibernate create a user-defined object on the fly. In anyway how would you propose to access that from Java since there will be no type available a compile time to call methods on.
So relating this to your case as I understand it.
You can setup your mappings of the all concern tables, lets say yours 3 tables map to 3 concrete objects (one for each table). You can then perform a select/join between those tables and have hibernate return all 3 full objects per row returned.
Your application then only accesses some methods relating to the columns its interested in, this is the natual way to do what you are trying to do.
Maybe if your SQL server can create a VIEW of the single table view you want. Then map hibernate to that SQL VIEW as a single object.
If you look at the documentation it should be pretty clear at which levels you can specify the table to use, since you can't override it at the <property .../> level hibernate can't create the view for you.