deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From johndam...@apache.org
Subject svn commit: r1747106 - /deltaspike/site/trunk/content/documentation/data.html
Date Tue, 07 Jun 2016 01:07:19 GMT
Author: johndament
Date: Tue Jun  7 01:07:19 2016
New Revision: 1747106

URL: http://svn.apache.org/viewvc?rev=1747106&view=rev
Log:
Site checkin for project Apache DeltaSpike Documentation

Modified:
    deltaspike/site/trunk/content/documentation/data.html

Modified: deltaspike/site/trunk/content/documentation/data.html
URL: http://svn.apache.org/viewvc/deltaspike/site/trunk/content/documentation/data.html?rev=1747106&r1=1747105&r2=1747106&view=diff
==============================================================================
--- deltaspike/site/trunk/content/documentation/data.html (original)
+++ deltaspike/site/trunk/content/documentation/data.html Tue Jun  7 01:07:19 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>



Mime
View raw message