You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltaspike.apache.org by "Christian Kaltepoth (JIRA)" <ji...@apache.org> on 2013/10/03 08:18:50 UTC
[jira] [Commented] (DELTASPIKE-421) Find zero or one
[ https://issues.apache.org/jira/browse/DELTASPIKE-421?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13784856#comment-13784856 ]
Christian Kaltepoth commented on DELTASPIKE-421:
------------------------------------------------
+1 for this.
I think this is a really important and useful feature.
> Find zero or one
> ----------------
>
> Key: DELTASPIKE-421
> URL: https://issues.apache.org/jira/browse/DELTASPIKE-421
> Project: DeltaSpike
> Issue Type: New Feature
> Components: Data-Module
> Affects Versions: 0.5
> Reporter: Harald Wellmann
>
> At the moment,
> E findByFoo(T foo)
> behaves like Query.getSingleResult(), i.e. it throws an exception if there is no result or more than one result.
> Dealing with these exceptions is inconvenient when the semantics required by the user is "find zero or one" or "find any one".
> These cases should be supported by
> E findOptionalByFoo(T foo)
> which
> - returns null when there is no result
> - returns the single result when there is exactly one result
> - throws NonUniqueResultException when there is more than one result
> and
> E findAnyByFoo(T foo)
> which
> - returns null when there is no result
> - returns the first result otherwise
--
This message was sent by Atlassian JIRA
(v6.1#6144)