Class ListOutcome<T>

  • Type Parameters:
    T - Type of items
    All Implemented Interfaces:
    Outcome<List<T>>

    public final class ListOutcome<T>
    extends Object
    implements Outcome<List<T>>
    Outcome that returns a list.

    Use it when you need a full collection:

     Collection&lgt;User> users = new JdbcSession(source)
       .sql("SELECT * FROM user")
       .select(
         new ListOutcome<User>(
           new ListOutcome.Mapping<User>() {
             @Override
             public User map(final ResultSet rset) throws SQLException {
               return new User.Simple(rset.getLong(1), rset.getString(2));
             }
           }
         )
       );
    Since:
    0.13
    • Constructor Detail

      • ListOutcome

        public ListOutcome​(Outcome.Mapping<T> mpg)
        Public ctor.
        Parameters:
        mpg - Mapping
    • Method Detail

      • handle

        public List<T> handle​(ResultSet rset,
                              Statement stmt)
                       throws SQLException
        Description copied from interface: Outcome
        Process the result set and return some value.
        Specified by:
        handle in interface Outcome<T>
        Parameters:
        rset - The result set to process
        stmt - The statement used in the run
        Returns:
        The result
        Throws:
        SQLException - If something goes wrong inside