| <html><head> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| <title xmlns:d="http://docbook.org/ns/docbook">Chapter 8. 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 II. Cayenne Framework"><link rel="prev" href="expressions.html" title="Chapter 7. Expressions"><link rel="next" href="queries.html" title="Chapter 9. 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 8. Orderings</th><th></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="expressions.html">Prev</a> </td><th width="60%" align="center"><a accesskey="u" href="cayenne-guide-part2.html">Part II. Cayenne Framework</a></th><td width="20%" align="right"> <a accesskey="n" href="queries.html">Next</a></td></tr></table><hr></div><div class="chapter" title="Chapter 8. Orderings"><div class="titlepage"><div><div><h2 class="title"><a name="orderings"></a>Chapter 8. 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<Painting> 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> </td><td width="20%" align="center"><a accesskey="u" href="cayenne-guide-part2.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="queries.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 7. Expressions </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 9. Queries</td></tr></table></div></body></html> |