-->
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.  [ 9 posts ] 
Author Message
 Post subject: Joined SubClass
PostPosted: Thu Sep 11, 2003 2:33 pm 
Beginner
Beginner

Joined: Wed Aug 27, 2003 6:44 pm
Posts: 20
Hi,
I would like to know when to use Joined Subclass.Pls give some examples to understand it clearly.
I read it in doc but it's not clear.

Hope someone can help in this one.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 7:15 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Joined sub class allows polymorphic behaviour where the derived class properties are contained in an additional table rather then the one table hence the join is required. The relationship is determined from the key attribute, if the join was successful then the derived class will be instanciated instead of the base class. For example,

<class name="eg.Cat" table="CATS">
<id name="id" column="uid" type="long">
<generator class="hilo"/>
</id>
<property name="birthdate" type="date"/>
<property name="color" not-null="true"/>
<property name="sex" not-null="true"/>
<property name="weight"/>
<many-to-one name="mate"/>
<set name="kittens">
<key column="MOTHER"/>
<one-to-many class="eg.Cat"/>
</set>
<joined-subclass name="eg.DomesticCat" table="DOMESTIC_CATS">
<key column="CAT"/>
<property name="name" type="string"/>
</joined-subclass>
</class>

Mapping from the documentation. There are two domain objects where class "Cat" is the base class to the second domain object "DomesticCat", eg,

public class Cat {
..
}
and
public class DomesticCat extends Cat {
...
}

If table DOMESTIC_CATS has en entry which matches the Key in table CATS then the DomesticCat domain object will be created.

You use it when:
1) Your database exists and the model matches.
2) You have many and possibly differing attributes for the derived class(es) and/or there are few entries for the derived class(es). Separates the data and saves storage.
3) You don't consider using a single table to map derived classes as an appropriate practice.

Balance the tradeoffs.

Hope this helps.


Top
 Profile  
 
 Post subject: SubClass
PostPosted: Fri Sep 12, 2003 10:47 am 
Beginner
Beginner

Joined: Wed Aug 27, 2003 6:44 pm
Posts: 20
So the bottom line is Joind subclass is similar to (One-to-one) Association .The difference is if the objects needs to be extended then use Joined Subclass else use Association.Is it right or i am confusing the concept.


Top
 Profile  
 
 Post subject: Re: SubClass
PostPosted: Wed Nov 26, 2003 9:22 pm 
Beginner
Beginner

Joined: Wed Oct 29, 2003 5:27 am
Posts: 30
ashoknan wrote:
So the bottom line is Joind subclass is similar to (One-to-one) Association .The difference is if the objects needs to be extended then use Joined Subclass else use Association.Is it right or i am confusing the concept.


I have the same question as "ashoknan".
Q: What's the difference between "one-to-one" and "joined-subclass"?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 27, 2003 8:32 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Same difference between inheritance and attribute in OO.

One practical thing : you can lazy load a one-to-one

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 10, 2003 4:24 am 
Beginner
Beginner

Joined: Wed Oct 29, 2003 5:27 am
Posts: 30
epbernard wrote:
Same difference between inheritance and attribute in OO.

One practical thing : you can lazy load a one-to-one

Did you mean that there are only theoretical differenc and no other practical differences except a one-to-one can be lazy loaded?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 10, 2003 11:07 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
ffeliza wrote:
epbernard wrote:
Same difference between inheritance and attribute in OO.

One practical thing : you can lazy load a one-to-one

Did you mean that there are only theoretical differenc and no other practical differences except a one-to-one can be lazy loaded?


inheritance vs attribute in OO are very practical differences to me.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 24, 2003 10:47 pm 
Beginner
Beginner

Joined: Wed Oct 29, 2003 5:27 am
Posts: 30
epbernard wrote:
inheritance vs attribute in OO are very practical differences to me.

In the post "Mapping of inheritance hierarchy" (http://forum.hibernate.org/viewtopic.php?t=925297&start=0&postdays=0&postorder=asc&highlight=joinedsubclass), Gavin advised that if one wanted to find something to replace joined-subclass (since joined-subclass and subclass can't be used together), he/she can use one-to-one as a subsititution.

God!
Is there really some huge difference between one-to-one and joined-subclass ??


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 29, 2003 6:26 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
ffeliza wrote:
Is there really some huge difference between one-to-one and joined-subclass ??

Already answered
Quote:
Same difference between inheritance and attribute in OO.

This solution is an acceptable substitute for the lacking of subclass / joined-subclass mix. Have a concrete look at the way you *use* your objects to find the *real* difference.

_________________
Emmanuel


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