Can you use lambda expressions in a JPA Entity with good performance?
<p>So, I have a OneToMany relationship in one of my entites:</p>

<pre><code>@OneToMany(cascade = { CascadeType.PERSIST, CascadeType.REFRESH }, fetch = FetchType.LAZY)
@OrderBy("priority")
    private List&lt;Result&gt; results
</code></pre>

<p>I want to get objects contained inside of these "results" based on by some criteria:</p>

<pre><code>Stream&lt;Item&gt; itemsToReturn = results.stream().filter(result -&gt; result.getPriority() &gt; 5)
                .map(Result::getItem)
                .filter(/*some filtering logic*/)
                .limit(numberOfItems);
</code></pre>

<p>It doesn't seem to be very effective though, since I guess all Items will be loaded into memory before any filtering is done in spite of the filtering and the limit.</p>

<p>Is my assumption correct? If so, can I do something so that I can use lambda in this entity, or I should write a JPA query to get these items?</p>

<p>Can lambdas be used with JPA at all?</p>