Class JpaMapper<C>

  • Type Parameters:
    C - the type to map
    All Implemented Interfaces:
    RowMapper<C>

    public class JpaMapper<C>
    extends java.lang.Object
    implements RowMapper<C>
    Row mapper for a JPA-annotated type as a result.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static interface  JpaMapper.MemberSetter<C>  
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.Class<C> clazz  
      private JpaClass<C> jpaClass  
    • Constructor Summary

      Constructors 
      Constructor Description
      JpaMapper​(java.lang.Class<C> clazz)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      C map​(java.sql.ResultSet rs, StatementContext ctx)
      Map the current row of the result set.
      RowMapper<C> specialize​(java.sql.ResultSet rs, StatementContext ctx)
      Returns a specialized row mapper, optimized for the given result set.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.jdbi.v3.core.mapper.RowMapper

        init
    • Field Detail

      • clazz

        private final java.lang.Class<C> clazz
      • jpaClass

        private final JpaClass<C> jpaClass
    • Constructor Detail

      • JpaMapper

        JpaMapper​(java.lang.Class<C> clazz)
    • Method Detail

      • specialize

        public RowMapper<C> specialize​(java.sql.ResultSet rs,
                                       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<C>
        Parameters:
        rs - 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.
      • map

        public C map​(java.sql.ResultSet rs,
                     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<C>
        Parameters:
        rs - 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