Class SimpleResultSetBeanMapper<T>

java.lang.Object
io.github.connellite.jdbc.SimpleResultSetBeanMapper<T>
Type Parameters:
T - bean type (no-arg constructor for class beans; canonical constructor for records)

public class SimpleResultSetBeanMapper<T> extends Object
Maps the current row of a ResultSet into a simple POJO (no collections, arrays, or nested beans). Field -> column: Column.value() when non-blank, otherwise the field name.

Supported property types: primitives and wrappers, String, BigDecimal, BigInteger, UUID, Enum (by constant name or ordinal), Date, Time, Timestamp, Date, LocalDate, LocalTime, LocalDateTime, Instant, ZonedDateTime, OffsetDateTime.

Vendor-specific JDBC values (for example oracle.sql.TIMESTAMP) are normalized before coercion, following the same approach as Spring's JdbcUtils#getResultSetValue.

The two-argument constructor accepts labels (for example from ResultSetMetaDataUtils.getColumnLabels(ResultSet)): every mapped column must appear in that collection or construction throws SQLException. A null columnLabels argument skips that check.

Reflection metadata (field bindings, record constructor, scalar mode) is cached per bean class. Keys are weak, so an unloaded class does not pin its ClassLoader; the metadata stays for as long as that class is reachable. Per-mapper TypeConverter registrations use a ConcurrentReferenceHashMap.

  • Field Details

    • METADATA_CACHE_INITIAL_CAPACITY

      public static final int METADATA_CACHE_INITIAL_CAPACITY
      See Also:
  • Constructor Details

    • SimpleResultSetBeanMapper

      public SimpleResultSetBeanMapper(Class<T> beanClass) throws SQLException
      Builds mapper without metadata validation.
      Throws:
      SQLException
    • SimpleResultSetBeanMapper

      public SimpleResultSetBeanMapper(Class<T> beanClass, Collection<String> columnLabels) throws SQLException
      Builds mapper and validates that mapped columns exist in columnLabels.
      Throws:
      SQLException
  • Method Details