What does @SingleValueResult do?

半腔热情 提交于 2021-01-29 02:05:00

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!