You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltaspike.apache.org by "Harald Wellmann (JIRA)" <ji...@apache.org> on 2013/10/02 21:07:46 UTC
[jira] [Created] (DELTASPIKE-421) Find zero or one
Harald Wellmann created DELTASPIKE-421:
------------------------------------------
Summary: 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)