cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [CONF] Apache Cayenne Documentation > Flattened Relationships
Date Thu, 10 Sep 2009 23:22:00 GMT
    <base href="">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=CAYDOC&amp;forWysiwyg=true"
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="">Flattened
     <h4>Page <b>edited</b> by             <a href="">Ari
     improve clarity
          <div id="versionComment" class="noteMacro" style="display:none; padding: 5px;">
     improve clarity<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">

<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">

<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
     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href=""
class="grey">Change Notification Preferences</a>

       <a href="">View
       <a href="">View
       <a href=";showCommentArea=true#addcomment">Add

View raw message