You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by bu...@apache.org on 2016/06/07 01:08:05 UTC

svn commit: r990082 - in /websites/staging/deltaspike/trunk/content: ./ documentation/data.html

Author: buildbot
Date: Tue Jun  7 01:08:05 2016
New Revision: 990082

Log:
Staging update by buildbot for deltaspike

Modified:
    websites/staging/deltaspike/trunk/content/   (props changed)
    websites/staging/deltaspike/trunk/content/documentation/data.html

Propchange: websites/staging/deltaspike/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Tue Jun  7 01:08:05 2016
@@ -1 +1 @@
-1745105
+1747106

Modified: websites/staging/deltaspike/trunk/content/documentation/data.html
==============================================================================
--- websites/staging/deltaspike/trunk/content/documentation/data.html (original)
+++ websites/staging/deltaspike/trunk/content/documentation/data.html Tue Jun  7 01:08:05 2016
@@ -598,7 +598,7 @@ be implemented in the repository.</p>
 }
 
 <span class="annotation">@Repository</span>(forEntity = Person.class)
-<span class="directive">public</span> <span class="type">interface</span> <span class="class">PersonRepository</span> <span class="directive">implements</span> Deactivatable{
+<span class="directive">public</span> <span class="type">interface</span> <span class="class">PersonRepository</span> <span class="directive">extends</span> Deactivatable {
     ...
 }</code></pre>
 </div>
@@ -925,6 +925,11 @@ expressions:</p>
 <p>Note that DeltaSpike will validate those expressions during startup, so
 you will notice early in case you have a typo in those expressions.</p>
 </div>
+<div class="paragraph">
+<p>Also note that as of 1.7, the Entity type returned can either by the
+entity defined in this repository, or any other entity in your persistence
+unit, or any primitive type supported by your JPA implementation.</p>
+</div>
 </div>
 <div class="sect2">
 <h3 id="_query_ordering">Query Ordering</h3>
@@ -1412,6 +1417,33 @@ annotations, the <code>singleResult</cod
 <p>This option will not throw an exception.</p>
 </div>
 </div>
+<div class="sect2">
+<h3 id="_java_8_semantics">Java 8 Semantics</h3>
+<div class="paragraph">
+<p>Repositories support returning instances of <code>java.util.Optional</code> and <code>java.util.stream.Stream</code> for any method.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="CodeRay highlight"><code data-lang="java"><span class="annotation">@Repository</span>(forEntity = Person.class)
+<span class="directive">public</span> <span class="type">interface</span> <span class="class">PersonRepository</span>
+{
+
+    Optional&lt;Person&gt; findBySsn(<span class="predefined-type">String</span> ssn);
+
+    Stream&lt;Person&gt; findByLocation(<span class="predefined-type">String</span> location);
+
+}</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Queries returning <code>Optional&lt;T&gt;</code> will behave like <code>SingleResultType.OPTIONAL</code>, if the data is present, return the single
+result, otherwise return <code>Optional.empty()</code>.  You can override this by using <code>SingleResultType.ANY</code> which takes the first
+result of the list, or else <code>empty()</code>.</p>
+</div>
+<div class="paragraph">
+<p>Queries returning <code>Stream&lt;T&gt;</code> act as a simple wrapper for <code>query.getResultList().stream()</code> to give back the results.</p>
+</div>
+</div>
 </div>
 </div>
 <div class="sect1">
@@ -2300,6 +2332,7 @@ provider when persisting / updating the
 <li><a href="#_optional_query_results">Optional Query Results</a></li>
 <li><a href="#_zero_or_one_result">Zero or One Result</a></li>
 <li><a href="#_any_result">Any Result</a></li>
+<li><a href="#_java_8_semantics">Java 8 Semantics</a></li>
 </ul>
 </li>
 <li><a href="#_transactions">Transactions</a></li>