deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject svn commit: r990082 - in /websites/staging/deltaspike/trunk/content: ./ documentation/data.html
Date Tue, 07 Jun 2016 01:08:05 GMT
Author: buildbot
Date: Tue Jun  7 01:08:05 2016
New Revision: 990082

Staging update by buildbot for deltaspike

    websites/staging/deltaspike/trunk/content/   (props changed)

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

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
@@ -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>
+<span class="directive">public</span> <span class="type">interface</span>
<span class="class">PersonRepository</span> <span class="directive">extends</span>
Deactivatable {
@@ -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 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 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 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></code> for any method.</p>
+<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>
+    Stream&lt;Person&gt; findByLocation(<span class="predefined-type">String</span>
+<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
+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 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 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>
 <li><a href="#_transactions">Transactions</a></li>

View raw message