-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: can we get data from more then one table
PostPosted: Thu Jul 20, 2006 6:28 am 
Newbie

Joined: Fri Jun 09, 2006 12:40 am
Posts: 3
Location: India
HI

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?


Top
 Profile  
 
 Post subject: Re: can we get data from more then one table
PostPosted: Thu Jul 20, 2006 6:39 am 
Regular
Regular

Joined: Sun May 08, 2005 2:48 am
Posts: 118
Location: United Kingdom
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.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 20, 2006 7:36 am 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
Hibernate Reference Documentation
Chapter 5. Basic O/R Mapping
5.1. Mapping declaration
5.1.18. join
Using the <join> element, it is possible to map properties of one class to several tables.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 21, 2006 2:06 am 
Newbie

Joined: Fri Jun 09, 2006 12:40 am
Posts: 3
Location: India
pepelnm wrote:
Hibernate Reference Documentation
Chapter 5. Basic O/R Mapping
5.1. Mapping declaration
5.1.18. join
Using the <join> element, it is possible to map properties of one class to several tables.


I want to take data as some fields from table1 ,some from table2 and some from table3 in a single VO(Value Object) class's field.
Can i do like that is yes plz give me a simple impl of mapping document.
And these tables are mapped to differente classes.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.