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 > Flattened Relationships
Date Thu, 10 Sep 2009 23:22:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=CAYDOC&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="http://cwiki.apache.org/confluence/display/CAYDOC/Flattened+Relationships">Flattened
Relationships</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~ari">Ari
Maniatis</a>
    </h4>
     improve clarity
          <div id="versionComment" class="noteMacro" style="display:none; padding: 5px;">
     improve clarity<br />
     </div>
          <br/>
     <div class="notificationGreySide">
         <p>Flattened relationships are a fancy term for a relationship which involves
three or more tables in the database. Lets say you have Artists and Exhibits. They are joined
with a many-many join table called Artist_Exhibit, because many Artists could collaborate
on one Exhibit and each Artist might be part of many Exhibits. Now you could map these as
separate joins and end up with Java code which looks like this:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
artist.getArtistExhibits().getExhibits()
</pre>
</div></div>

<p>but with a flattened join, it is even simpler:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
artist.getExhibits()
</pre>
</div></div>

<p>From the application point of view there is no difference in working with flattened
relationships compared to the "normal" ones. Cayenne internally figures out how to build the
needed query joins to retrieve related objects. On adding or removing an object to/from a
flattened relationship via a corresponding "addTo..." / "removeFrom..." method an appropriate
join record is created or removed.</p>
<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td><b>Flattened
Relationships Limitations</b><br />Only many-to-many flattened relatationships
with a single join table can be modified. All other types of flattened relationships can be
used as "read-only". This is reflected in the DataObject code generated for such relationships
- no set/addTo/RemoveFrom methods are created for read-only relationships.</td></tr></table></div>

<p>See this documentation on how to <a href="/confluence/display/CAYDOC/CayenneModeler+Flattened+Relationships"
title="CayenneModeler Flattened Relationships">create flattened relationships in Cayenne
Modeler</a></p>
     </div>
     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>

       <a href="http://cwiki.apache.org/confluence/display/CAYDOC/Flattened+Relationships">View
Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=10493&revisedVersion=2&originalVersion=1">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/CAYDOC/Flattened+Relationships?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message