>> It seems that if I use "table-per-class", I am going to get hit
with thirty queries every time I do a select of the superclass, is that
correct?  <<

Correct

>> But if I use "table-per-subclass" with <joined-subclass/>, I will
get two selects -- one for the superclass result set and one for each table
(or table type) that exists in the result set. <<

No, Hibernate uses a great big outer join, because there is no
discriminator column in joined-subclass mappings.


The subclass fetching strategy you just described (we need to give it a
name) is subject to the N+1 selects problem. However, I *do* plan to
support it in a not too distant future version. (Hibernate 2.1.1 perhaps.)
Actually,  It will be a variation of the proposed multi-table mapping
support, ie. the <join> mapping. For multitable mappings we will support
both <join> and <sequential-read>. So the fetching strategy you describe
would be implementable as B and C in the following:

<class name="A">
    <id column="a_id>....</id>
    <discriminator column="type"/>

    <subclass name="B">
        <sequential-read table="b">
            <key column="b_id"/>
            <property name="b"/>
        </sequential-read>
    </subclass>

    <subclass name="C">
        <sequential-read table="c">
            <key column="c_id"/>
            <property name="c1"/>
            <property name="c2"/>
        </sequential-read>
    </subclass>

   <subclass name="D">
        <join table="d">
            <key column="d_id"/>
            <property name="d"/>
        </join>
    </subclass>

    <subclass name="E">
          <property name="d"/>
    </subclass>

</class>

So we now have a fully mixed inheritance strategy!! This hierarchy combines
together a table-per-subclass loaded by joining, 2 table-per-subclasses
loaded by sequential read and another subclass mapped to the superclass
table.

Don't expect this stuff in the next two weeks, however!

>> Since the subclass is
completely described this way, is the separate mapping file for the
subclass
redundant?  <<

You should not have a seperate mapping file for a subclass.







|---------+------------------------------------------->
|         |           "Brian Topping"                 |
|         |           <[EMAIL PROTECTED]>             |
|         |           Sent by:                        |
|         |           [EMAIL PROTECTED]|
|         |           ceforge.net                     |
|         |                                           |
|         |                                           |
|         |           07/08/03 04:19 PM               |
|         |                                           |
|---------+------------------------------------------->
  
>------------------------------------------------------------------------------------------------------------------------------|
  |                                                                                    
                                          |
  |       To:       <[EMAIL PROTECTED]>                                                
                      |
  |       cc:                                                                          
                                          |
  |       Subject:  [Hibernate] questions about polymorphism                           
                                          |
  
>------------------------------------------------------------------------------------------------------------------------------|




Hi all,

I have some questions about polymorphic persistence.  Any takers?

I have a schema that currently has about thirty subclasses (more with time)
and one common superclass.  I am looking for polymorphism between these
subclasses.  It seems that if I use "table-per-class", I am going to get
hit
with thirty queries every time I do a select of the superclass, is that
correct?  But if I use "table-per-subclass" with <joined-subclass/>, I will
get two selects -- one for the superclass result set and one for each table
(or table type) that exists in the result set.  Since most of the
collections
are of a single subtype, this seems to be the most efficient.  True?

[a comment: adding a "WildCat" subclass to the documentation example next
to
"DomesticCat" would be helpful, although it may add unnecessary complexity
to
the single page manual, since there are no examples of having multiple
subclasses with a common parent.]

Finally, if I understand the mapping file schema correctly, the superclass
mapping file is going to be very very large, essentially containing all of
the subclasses in <joined-subclass/> entities.  Since the subclass is
completely described this way, is the separate mapping file for the
subclass
redundant?

Thanks for any thoughts!!

Brian


-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel




**********************************************************************
Any personal or sensitive information contained in this email and
attachments must be handled in accordance with the Victorian Information
Privacy Act 2000, the Health Records Act 2001 or the Privacy Act 1988
(Commonwealth), as applicable.

This email, including all attachments, is confidential.  If you are not the
intended recipient, you must not disclose, distribute, copy or use the
information contained in this email or attachments.  Any confidentiality or
privilege is not waived or lost because this email has been sent to you in
error.  If you have received it in error, please let us know by reply
email, delete it from your system and destroy any copies.
**********************************************************************






-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to