Interface Outcome<T>

  • Type Parameters:
    T - Type of expected result
    All Known Implementing Classes:
    ColumnOutcome, ListOutcome, SingleOutcome, StoredProcedureOutcome

    public interface Outcome<T>
    Outcome of ResultSet.

    The following convenience implementations are provided:

    • NOT_EMPTY to check that at least one result row is returned.
    • VOID for when you wish to disregard the result.
    • UPDATE_COUNT to check the number of updated rows.
    Since:
    0.12
    • Field Detail

      • VOID

        static final Outcome<Void> VOID
        Outcome that does nothing (and always returns null).

        Useful when you're not interested in the result:

         new JdbcSession(source)
           .sql("INSERT INTO foo (name) VALUES (?)")
           .set("Jeff Lebowski")
           .insert(Outcome.VOID);
        Since:
        0.12
      • UPDATE_COUNT

        static final Outcome<Integer> UPDATE_COUNT
        Outcome that returns the number of updated rows.

        Use it when you need to determine the number of rows updated:

         Integer count = new JdbcSession(source)
           .sql("UPDATE employee SET salary = 35000 WHERE department = ?")
           .set("Finance")
           .update(Outcome.UPDATE_COUNT);
        Since:
        0.12
      • LAST_INSERT_ID

        static final Outcome<Long> LAST_INSERT_ID
        Outcome that returns last insert ID.

        Use it when you need to get last insert ID from INSERT:

         long id = new JdbcSession(source)
           .sql("INSERT INTO employee (name) VALUES (?)")
           .set("Jeffrey")
           .insert(Outcome.LAST_INSERT_ID);
        Since:
        0.13
      • DEFAULT_MAPPINGS

        static final Outcome.Mappings DEFAULT_MAPPINGS
        Default mappings.
        Since:
        0.17.6
    • Method Detail

      • handle

        T handle​(ResultSet rset,
                 Statement stmt)
          throws SQLException
        Process the result set and return some value.
        Parameters:
        rset - The result set to process
        stmt - The statement used in the run
        Returns:
        The result
        Throws:
        SQLException - If something goes wrong inside