-->
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.  [ 6 posts ] 
Author Message
 Post subject: Creating a class from multiple tables
PostPosted: Wed Dec 03, 2003 2:49 pm 
Beginner
Beginner

Joined: Wed Dec 03, 2003 2:43 pm
Posts: 22
Forgive if this has been answered many timed before. I have checked the faq but couldn't find anything.

If I want to create a class that uses many tables for its properties can I do this or do I have to subclass?

For example, if I have a table 'table1' with properties:

ID
NAME
ADDRESS
ZIPCODE

and another table 'table2' with properties:
TABLE1_ID
FAVORITE_COLOR
FAVORITE_ANIMAL
FAVORITE_FOOD

Is it possible to create a class 'Person' with properties name, address, favoriteColor, favoriteAnimal, and favoriteFood, or do I have to create a class BasePerson with just name, address and zipcode and then ExtendedPerson which extends BasePerson to get all the properties?

Thanks for the info!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 03, 2003 2:53 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You must subclass, what you want is expected in hibernate 2.2.

You can also do a one-to-one mapping (and allow lazy initialization).

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 03, 2003 2:53 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
imho, you have to create Base & Extended person. Working with single object spread among several tables is TODO for Hibernate 2.2


Top
 Profile  
 
 Post subject: Thanks
PostPosted: Wed Dec 03, 2003 2:54 pm 
Beginner
Beginner

Joined: Wed Dec 03, 2003 2:43 pm
Posts: 22
Thanks for the info!


Top
 Profile  
 
 Post subject: Subclass of a subclass
PostPosted: Wed Dec 03, 2003 3:08 pm 
Beginner
Beginner

Joined: Wed Dec 03, 2003 2:43 pm
Posts: 22
Is it possible to have a subclass of a subclass?


Top
 Profile  
 
 Post subject: Re: Subclass of a subclass
PostPosted: Wed Dec 03, 2003 7:35 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
gjz22 wrote:
Is it possible to have a subclass of a subclass?

Yes, you can have subclasses of subclasses or joined-subclassed of joined-subclasses

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.