Search code examples
javajdbi

What does @SingleValueResult do?


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:


Solution

  • 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.