blob: bbf7d2bfd6b6066353cb5cb64ee0c7344f44850e [file] [log] [blame]
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title xmlns:d="http://docbook.org/ns/docbook">Chapter&nbsp;8.&nbsp;Orderings</title><link rel="stylesheet" type="text/css" href="css/cayenne-doc.css"><meta xmlns:d="http://docbook.org/ns/docbook" name="keywords" content="Cayenne 3.1 documentation"><meta xmlns:d="http://docbook.org/ns/docbook" name="description" content="User documentation for Apache Cayenne version 3.1"><link rel="home" href="index.html" title="Cayenne Guide"><link rel="up" href="cayenne-guide-part2.html" title="Part&nbsp;II.&nbsp;Cayenne Framework"><link rel="prev" href="expressions.html" title="Chapter&nbsp;7.&nbsp;Expressions"><link rel="next" href="queries.html" title="Chapter&nbsp;9.&nbsp;Queries"><script xmlns:d="http://docbook.org/ns/docbook" type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-7036673-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div xmlns:d="http://docbook.org/ns/docbook" class="navheader"><table width="100%" summary="Navigation header"><tr><th class="versioninfo">v.3.1 (3.1)</th><th align="center">Chapter&nbsp;8.&nbsp;Orderings</th><th></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="expressions.html">Prev</a>&nbsp;</td><th width="60%" align="center"><a accesskey="u" href="cayenne-guide-part2.html">Part&nbsp;II.&nbsp;Cayenne Framework</a></th><td width="20%" align="right">&nbsp;<a accesskey="n" href="queries.html">Next</a></td></tr></table><hr></div><div class="chapter" title="Chapter&nbsp;8.&nbsp;Orderings"><div class="titlepage"><div><div><h2 class="title"><a name="orderings"></a>Chapter&nbsp;8.&nbsp;Orderings</h2></div></div></div><p>An Ordering object defines how a list of objects should be ordered. Orderings are
essentially path expressions combined with a sorting strategy. Creating an Ordering:
</p><pre class="programlisting">Ordering o = <span xmlns="http://www.w3.org/1999/xhtml" class="hl-keyword">new</span> Ordering(Painting.NAME_PROPERTY, SortOrder.ASENDING);</pre><p>Like expressions, orderings are translated into SQL as parts of queries (and the sorting
occurs in the database). Also like expressions, orderings can be used in memory, naturally -
to sort
objects:</p><pre class="programlisting">Ordering o = <span xmlns="http://www.w3.org/1999/xhtml" class="hl-keyword">new</span> Ordering(Painting.NAME_PROPERTY, SortOrder.ASCENDING_INSENSITIVE);
List&lt;Painting&gt; list = ...
o.orderList(list);</pre><p>Note
that unlike filtering with Expressions, ordering is performed in-place. This list object is
reordered and no new list is created.</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="expressions.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="cayenne-guide-part2.html">Up</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="queries.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&nbsp;7.&nbsp;Expressions&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;Chapter&nbsp;9.&nbsp;Queries</td></tr></table></div></body></html>