问题
What does @SingleValueResult do? Does it impose the constraint 'single value result'?
Full name: org.skife.jdbi.v2.sqlobject.customizers.SingleValueResult
Here are some links about it:
- https://groups.google.com/forum/#!topic/jdbi/tQge_FNUoiw
- https://news.ycombinator.com/item?id=8134591
回答1:
No, it doesn't.
Instead it just provides some more type information for Optional
or Maybe
return types.
When JDBI recognizes that only a single row will be needed from the database, it will tell the database that only one row will be needed (see addStatementCustomizer(StatementCustomizers.MAX_ROW_ONE)
in the Query
class).
This will let the database optimize the returned data. But your Java application will never know if there was ever a second row.
来源:https://stackoverflow.com/questions/32749264/what-does-singlevalueresult-do