Evolution #2119
add new findX(query, args) method to return unique result
| Status: | Résolu | Start date: | 05/31/2012 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 100% | ||
| Category: | topia-persistence | Spent time: | - | |
| Target version: | 2.6.11 |
Description
Like find(String, int, int, args) and findAll(String, args) add
new method to return only one result.
Associated revisions
fixes #2119 Add TopiaContext#findUnique and its tests
fixes #2119 for ToPIA3 : Add TopiaContext#findUnique and its tests
History
#1
Updated by Arnaud Thimel 12 months ago
- Status changed from Nouveau to Assigné
- Assignee set to Arnaud Thimel
#2
Updated by Arnaud Thimel 12 months ago
- Status changed from Assigné to Commentaire
- Assignee changed from Arnaud Thimel to Éric Chatellier
What is your expected behaviour if there is more than 1 result ?
What is your expected behaviour if there is 0 result ?
#3
Updated by Éric Chatellier 12 months ago
I don't have opinion on that.
Maybe for now we could take same behaviour as org.hibernate.Query#uniqueResult() method.
- exception for non unique result
- null for no result
#4
Updated by Arnaud Thimel 12 months ago
As a former user of the Hibernate method, I would have say the exact opposite :
findFirst
- returns only the 1st element (easier to developp, better perfs)
- if no result, simply return null (easier to use against an exception)
Do you agree on that ?
#5
Updated by Éric Chatellier 12 months ago
I aggree
#6
Updated by Arnaud Thimel 12 months ago
- Status changed from Commentaire to Assigné
- Assignee changed from Éric Chatellier to Arnaud Thimel
I will implement that :
findUnique(...)
- if no result, return "null"
- if more than 1 result, throw an exception
#7
Updated by Arnaud Thimel 12 months ago
- Status changed from Assigné to Résolu
- % Done changed from 0 to 100
Appliqué par commit r2573.