cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Cayenne Documentation > Modeling Vertical Inheritance
Date Tue, 27 Jul 2010 11:59:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1810/9/1/_/styles/combined.css?spaceKey=CAYDOC&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CAYDOC/Modeling+Vertical+Inheritance">Modeling
Vertical Inheritance</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~andrus">Andrus
Adamchik</a>
    </h4>
        <br/>
                         <h4>Changes (3)</h4>
                                 
    
<div id="page-diffs">
            <table class="diff" cellpadding="0" cellspacing="0">
            <tr><td class="diff-unchanged" >h2. Modeling Vertical Inheritance
<br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">Continuing
with the example used for [single table mapping|Modeling Single Table Inheritance], let&#39;s
re-map it as vertical inheritance. <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">(TODO)</span>
<span class="diff-added-words"style="background-color: #dfd;"> </span> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">!vertical-inheritance.png!
<br> <br>Note that in Cayenne *vertical* is essentially *single table with flattened
attributes in subclasses*. We&#39;ll demonstrate this below. <br> <br>We need
to start by mapping all 3 tables, and creating 1..1 relationship between BOOK and subclass
tables (&quot;To Dep PK&quot; must be checked on BOOK side of relationships). <br>
<br>On the ObjEntity end, there is no difference in mapping qualifier (it is needed),
superclass, root table (&quot;Table/View&quot; for subclasses is still &quot;BOOK&quot;).
The only difference is that subclass-specific attributes are mapped as &quot;flattened
attributes&quot;: <br> <br>!flattened_attribute.png! <br> <br>bq.
Note that flattened attributes can be used with or without inheritance, however in combination
with single-table inheritance mapping, they give us &quot;vertical&quot; inheritance.
<br></td></tr>
        </table>
</div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="ModelingVerticalInheritance-ModelingVerticalInheritance"></a>Modeling
Vertical Inheritance</h2>

<p>Continuing with the example used for <a href="/confluence/display/CAYDOC/Modeling+Single+Table+Inheritance"
title="Modeling Single Table Inheritance">single table mapping</a>, let's re-map
it as vertical inheritance.</p>

<p><span class="image-wrap" style=""><img src="/confluence/download/attachments/21792602/vertical-inheritance.png?version=1&amp;modificationDate=1280231909075"
style="border: 0px solid black" /></span></p>

<p>Note that in Cayenne <b>vertical</b> is essentially <b>single table
with flattened attributes in subclasses</b>. We'll demonstrate this below.</p>

<p>We need to start by mapping all 3 tables, and creating 1..1 relationship between
BOOK and subclass tables ("To Dep PK" must be checked on BOOK side of relationships).</p>

<p>On the ObjEntity end, there is no difference in mapping qualifier (it is needed),
superclass, root table ("Table/View" for subclasses is still "BOOK"). The only difference
is that subclass-specific attributes are mapped as "flattened attributes":</p>

<p><span class="image-wrap" style=""><img src="/confluence/download/attachments/21792602/flattened_attribute.png?version=1&amp;modificationDate=1280231902959"
style="border: 0px solid black" /></span></p>

<blockquote><p>Note that flattened attributes can be used with or without inheritance,
however in combination with single-table inheritance mapping, they give us "vertical" inheritance.</p></blockquote>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CAYDOC/Modeling+Vertical+Inheritance">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=21792602&revisedVersion=2&originalVersion=1">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAYDOC/Modeling+Vertical+Inheritance?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message