Projectable.uniqueResult() semantics

Bug #717563 reported by cowwoc
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Querydsl
Fix Released
Undecided
Unassigned

Bug Description

It's not clear what happens if Projectable.uniqueResult() is invoked on a query that returns multiple results.

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

Is this ok : for multiple results only the first one is returned

The details are implementation specific

Changed in querydsl:
status: New → Fix Committed
Revision history for this message
cowwoc (gili) wrote :

Timo,

The text you mentioned is okay but I am somewhat concerned about the method name. Coming from JPA I am somewhat unused to the method throwing an exception if multiple matches are found. I guess I could push this integrity-checking into the database using the UNIQUE keyword, but then I'm strongly in favor of renaming the method to something along the lines of firstResult(). The current method name implies that the result is unique, which is not necessarily true.

Revision history for this message
cowwoc (gili) wrote :

"somewhat unused to the method throwing an exception" should read "somewhat used to the method throwing an exception"

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

firstResult() also somewhat implies that the result is ordered, which it is not necessarily.

Maybe I should instead always throw an Exception if more than one result is found. Then this would be consistent. For Hibernate and JPA this would already be the case and could easily be applied to the other modules.

Revision history for this message
cowwoc (gili) wrote :

I would be fine with that.

summary: - Projectable.uniqueResult() Javadoc does not discuss what happens if
- multiple matches are found
+ Projectable.uniqueResult() should throw an Exception on multiple results
Changed in querydsl:
status: Fix Committed → In Progress
summary: - Projectable.uniqueResult() should throw an Exception on multiple results
+ Projectable.uniqueResult() semantics
Changed in querydsl:
status: In Progress → Fix Committed
Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

Released in 2.1.2

Changed in querydsl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.