Class SimpleResultSetBeanMapper<T>
- Type Parameters:
T- bean type (no-arg constructor for class beans; canonical constructor for records)
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSimpleResultSetBeanMapper(Class<T> beanClass) Builds mapper without metadata validation.SimpleResultSetBeanMapper(Class<T> beanClass, Collection<String> columnLabels) Builds mapper and validates that mapped columns exist incolumnLabels. -
Method Summary
Modifier and TypeMethodDescriptionMaps current row ofrsto target bean/record instance.withConverter(Class<C> type, TypeConverter<C> converter) Registers custom converter for target type.
-
Field Details
-
METADATA_CACHE_INITIAL_CAPACITY
public static final int METADATA_CACHE_INITIAL_CAPACITY- See Also:
-
-
Constructor Details
-
SimpleResultSetBeanMapper
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 incolumnLabels.- Throws:
SQLException
-
-
Method Details
-
withConverter
Registers custom converter for target type. Primitive types are normalized to wrappers. -
mapRow
Maps current row ofrsto target bean/record instance.- Throws:
SQLException
-