[
https://issues.apache.org/jira/browse/DELTASPIKE-421?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Gerhard Petracek closed DELTASPIKE-421.
---------------------------------------
> 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
> Assignee: Thomas Hug
> Fix For: 0.6
>
>
> 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.2#6252)