http://git-wip-us.apache.org/repos/asf/cayenne-website/blob/0af753b3/docs/1.2/accessing-pk-and-fk-values.html ---------------------------------------------------------------------- diff --git a/docs/1.2/accessing-pk-and-fk-values.html b/docs/1.2/accessing-pk-and-fk-values.html new file mode 100644 index 0000000..7dc8ee9 --- /dev/null +++ b/docs/1.2/accessing-pk-and-fk-values.html @@ -0,0 +1,81 @@ +Title: Accessing PK and FK values + + + +<P>Normally it is not advisable to map primary and foreign key columns (PK and FK) as Java class properties (ObjAttributes). When reverse engineering of the database is done using CayenneModeler, produced mapping will reflect that - PKs and FKs will not be included in the Java class. However sometimes an application requires access to these values.</P> + +<DIV class="panelMacro"><TABLE class="infoMacro"><COLGROUP><COL width="24"><COL></COLGROUP><TR><TD valign="top"><IMG src="http://cayenne.apache.org/docs/1.2/images/icons/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></TD><TD>For generic and easy API to obtain an object primary key or to find an object from a known PK, skip to the next chapter on DataObjectUtils class.</TD></TR></TABLE></DIV> + +<P>Cayenne provides a generic way to do access primary and foreign keys by creating custom get* methods in the DataObject subclass. Lets take a Painting class as an example. The following code is generated by CayenneModeler:</P> + +<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent"> +<PRE class="code-java"><SPAN class="code-keyword">package</SPAN> org.objectstyle.art; + +<SPAN class="code-keyword">public</SPAN> class Painting <SPAN class="code-keyword">extends</SPAN> org.objectstyle.art.auto._Painting { + +} +</PRE> +</DIV></DIV> + +<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent"> +<PRE class="code-java"><SPAN class="code-keyword">package</SPAN> org.objectstyle.art.auto; + +/** <SPAN class="code-object">Class</SPAN> _Painting was generated by Cayenne. + * It is probably a good idea to avoid changing <SPAN class="code-keyword">this</SPAN> class manually, + * since it may be overwritten next time code is regenerated. + * If you need to make any customizations, please use subclass. + */ +<SPAN class="code-keyword">public</SPAN> class _Painting <SPAN class="code-keyword">extends</SPAN> org.objectstyle.art.ArtDataObject { + + <SPAN class="code-keyword">public</SPAN> <SPAN class="code-keyword">static</SPAN> <SPAN class="code-keyword">final</SPAN> <SPAN class="code-object">String</SPAN> ESTIMATED_PRICE_PROPERTY = <SPAN class="code-quote">"estimatedPrice"</SPAN>; + <SPAN class="code-keyword">public</SPAN> <SPAN class="code-keyword">static</SPAN> <SPAN class="code-keyword">final</SPAN> <SPAN class="code-object">String</SPAN> PAINTING_TITLE_PROPERTY = <SPAN class="code-quote">"paintingTitle"</SPAN>; + <SPAN class="code-keyword">public</SPAN> <SPAN class="code-keyword">static</SPAN> <SPAN class="code-keyword">final</SPAN> <SPAN class="code-object">String</SPAN> TO_ARTIST_PROPERTY = <SPAN class="code-quote">"toArtist"</SPAN>; + <SPAN class="code-keyword">public</SPAN> <SPAN class="code-keyword">static</SPAN> <SPAN class="code-keyword">final</SPAN> <SPAN class="code-object">String</SPAN> TO_GALLERY_PROPERTY = <SPAN class="code-quote">"toGallery"</SPAN>; + <SPAN class="code-keyword">public</SPAN> <SPAN class="code-keyword">static</SPAN> <SPAN class="code-keyword">final</SPAN> <SPAN class="code-object">String</SPAN> TO_PAINTING_INFO_PROPERTY = <SPAN class="code-quote">"toPaintingInfo"</SPAN>; + + <SPAN class="code-keyword">public</SPAN> <SPAN class="code-keyword">static</SPAN> <SPAN class="code-keyword">final</SPAN> <SPAN class="code-object">String</SPAN> PAINTING_ID_PK_COLUMN = <SPAN class="code-quote">"PAINTING_ID"</SPAN>; + + <SPAN class="code-keyword">public</SPAN> void setEstimatedPrice(java.math.BigDecimal estimatedPrice) { + writeProperty(<SPAN class="code-quote">"estimatedPrice"</SPAN>, estimatedPrice); + } + <SPAN class="code-keyword">public</SPAN> java.math.BigDecimal getEstimatedPrice() { + <SPAN class="code-keyword">return</SPAN> (java.math.BigDecimal)readProperty(<SPAN class="code-quote">"estimatedPrice"</SPAN>); + } + + + <SPAN class="code-keyword">public</SPAN> void setPaintingTitle(<SPAN class="code-object">String</SPAN> paintingTitle) { + writeProperty(<SPAN class="code-quote">"paintingTitle"</SPAN>, paintingTitle); + } + <SPAN class="code-keyword">public</SPAN> <SPAN class="code-object">String</SPAN> getPaintingTitle() { + <SPAN class="code-keyword">return</SPAN> (<SPAN class="code-object">String</SPAN>)readProperty(<SPAN class="code-quote">"paintingTitle"</SPAN>); + } +... +} +</PRE> +</DIV></DIV> + +<P>The following custom methods should be added to the Painting class to access the values of ARTIST_ID and PAINTING_ID:</P> + +<DIV class="panelMacro"><TABLE class="infoMacro"><COLGROUP><COL width="24"><COL></COLGROUP><TR><TD valign="top"><IMG src="http://cayenne.apache.org/docs/1.2/images/icons/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></TD><TD>If you perform class generation using Ant, you can customize class generation templates to generte these methods for you. Eventually CayenneModeler will support this too as optional functionality.</TD></TR></TABLE></DIV> + +<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent"> +<PRE class="code-java"><SPAN class="code-keyword">package</SPAN> org.objectstyle.art; + +<SPAN class="code-keyword">public</SPAN> class Painting <SPAN class="code-keyword">extends</SPAN> org.objectstyle.art.auto._Painting { + /** Read-only access to PK */ + <SPAN class="code-keyword">public</SPAN> <SPAN class="code-object">Integer</SPAN> getPaintingId() { + <SPAN class="code-keyword">return</SPAN> (getObjectId() != <SPAN class="code-keyword">null</SPAN> && !getObjectId().isTemporary()) + ? (<SPAN class="code-object">Integer</SPAN>)getObjectId().getIdSnapshot().get(PAINTING_ID_PK_COLUMN) + : <SPAN class="code-keyword">null</SPAN>; + } + + /** Read-only access to FK */ + <SPAN class="code-keyword">public</SPAN> <SPAN class="code-object">Integer</SPAN> getArtistId() { + Artist artist = getArtist(); + <SPAN class="code-keyword">return</SPAN> (artist != <SPAN class="code-keyword">null</SPAN>) + ? (<SPAN class="code-object">Integer</SPAN>)artist.getObjectId().getIdSnapshot().get(Artist.ARTIST_ID_PK_COLUMN) + : <SPAN class="code-keyword">null</SPAN>; + } +} +</PRE> +</DIV></DIV>
http://git-wip-us.apache.org/repos/asf/cayenne-website/blob/0af753b3/docs/1.2/acknowledgments.html ---------------------------------------------------------------------- diff --git a/docs/1.2/acknowledgments.html b/docs/1.2/acknowledgments.html new file mode 100644 index 0000000..fba09d1 --- /dev/null +++ b/docs/1.2/acknowledgments.html @@ -0,0 +1,5 @@ +Title: Acknowledgments + + <P><BR> +<BR> +We would like to thank our dedicated team of <A href="http://objectstyle.org/cayenne/contributors.html" class="external-link" rel="nofollow">contributors</A> - for making this project possible, early adopters - for taking all the pain to help us make a usable product, other users - for providing feedback, comments, patches and bug reports.</P> http://git-wip-us.apache.org/repos/asf/cayenne-website/blob/0af753b3/docs/1.2/ant-tasks.html ---------------------------------------------------------------------- diff --git a/docs/1.2/ant-tasks.html b/docs/1.2/ant-tasks.html new file mode 100644 index 0000000..05523eb --- /dev/null +++ b/docs/1.2/ant-tasks.html @@ -0,0 +1,27 @@ +Title: Ant Tasks + + + +<P>Cayenne ships with Ant tasks that provide Ant frontend to a number of useful operations in Cayenne. The following tasks are included:</P> + +<UL> + <LI><B><A href="cgen.html" title="cgen">cgen</A></B> - Java class generator</LI> + <LI><B><A href="cdbgen.html" title="cdbgen">cdbgen</A></B> - Database schema generator</LI> + <LI><B><A href="cdeploy.html" title="cdeploy">cdeploy</A></B> - Deployment configurator</LI> + <LI><B><A href="cdataport.html" title="cdataport">cdataport</A></B> - Data porting tool.</LI> +</UL> + + +<H3><A name="AntTasks-ImportingCayenneTasksinbuild.xml"></A>Importing Cayenne Tasks in build.xml</H3> +<P>Cayenne tasks above can be imported individually using Ant taskdef, as described in each task documentation page. However the users of Ant 1.6 and newer can take advantage of Antlib Ant feature. <A href="http://ant.apache.org/manual/CoreTypes/antlib.html" class="external-link" rel="nofollow">Antlib</A> allows 3rd party tasks and types to be defined easily. Cayenne has an embedded antlib.xml descriptor file in the package <TT>org.objectstyle.cayenne.tools</TT>. All of Cayenne's Ant tasks can be defined at once using the following definition in your Ant build file:</P> + +<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent"> +<PRE class="code-xml"><SPAN class="code-tag"><typedef resource=<SPAN class="code-quote">"org/objectstyle/cayenne/tools/antlib.xml"</SPAN>></SPAN> + <SPAN class="code-tag"><classpath refid=<SPAN class="code-quote">"classpath"</SPAN>/></SPAN> +<SPAN class="code-tag"></typedef></SPAN> +</PRE> +</DIV></DIV> + +<P>When using the Antlib construct, omit the <TT><taskdef></TT> elements shown in the examples of each task, as the antlib.xml file defines all of the Cayenne Ant tasks. </P> + +