Class JoinRowMapper

  • All Implemented Interfaces:
    RowMapper<JoinRow>

    public class JoinRowMapper
    extends java.lang.Object
    implements RowMapper<JoinRow>
    A RowMapper implementation to easily compose existing RowMappers. As the name implies, it is most commonly used for retrieving multiple tables' Java representations from a joined row.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.reflect.Type[] types  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private JoinRowMapper​(java.lang.reflect.Type[] types)  
    • Field Detail

      • types

        private final java.lang.reflect.Type[] types
    • Constructor Detail

      • JoinRowMapper

        private JoinRowMapper​(java.lang.reflect.Type[] types)
    • Method Detail

      • map

        public JoinRow map​(java.sql.ResultSet r,
                           StatementContext ctx)
                    throws java.sql.SQLException
        Description copied from interface: RowMapper
        Map the current row of the result set. This method should not cause the result set to advance; allow Jdbi to do that, please.
        Specified by:
        map in interface RowMapper<JoinRow>
        Parameters:
        r - the result set being iterated
        ctx - the statement context
        Returns:
        the value to produce for this row
        Throws:
        java.sql.SQLException - if anything goes wrong go ahead and let this percolate; Jdbi will handle it
      • specialize

        public RowMapper<JoinRow> specialize​(java.sql.ResultSet r,
                                             StatementContext ctx)
                                      throws java.sql.SQLException
        Description copied from interface: RowMapper
        Returns a specialized row mapper, optimized for the given result set.

        Before mapping the result set from a SQL statement; Jdbi will first call this method to obtain a specialized instance. The returned mapper will then be used to map the result set rows, and discarded.

        Implementing this method is optional; the default implementation returns this. Implementors might choose to override this method to improve performance, e.g. by matching up column names to properties once for the entire result set, rather than repeating the process for every row.

        Specified by:
        specialize in interface RowMapper<JoinRow>
        Parameters:
        r - the result set to specialize over
        ctx - the statement context to specialize over
        Returns:
        a row mapper equivalent to this one, possibly specialized.
        Throws:
        java.sql.SQLException - if anything goes wrong go ahead and let this percolate; Jdbi will handle it
        See Also:
        for an example of specialization.
      • forTypes

        public static JoinRowMapper forTypes​(java.lang.reflect.Type... classes)
        Create a JoinRowMapper that maps each of the given types and returns a JoinRow with the resulting values.
        Parameters:
        classes - the types to extract
        Returns:
        a JoinRowMapper that extracts the given types