T
- the result typepublic class DataClassRowMapper<T> extends BeanPropertyRowMapper<T>
RowMapper
implementation that converts a row into a new instance
of the specified mapped target class. The mapped target class must be a
top-level class and may either expose a data class constructor with named
parameters corresponding to column names or classic bean property setters
(or even a combination of both).
Note that this class extends BeanPropertyRowMapper
and can
therefore serve as a common choice for any mapped target class, flexibly
adapting to constructor style versus setter methods in the mapped class.
logger
Constructor and Description |
---|
DataClassRowMapper()
Create a new
DataClassRowMapper for bean-style configuration. |
DataClassRowMapper(Class<T> mappedClass)
Create a new
DataClassRowMapper . |
Modifier and Type | Method and Description |
---|---|
protected T |
constructMappedInstance(ResultSet rs,
TypeConverter tc)
Construct an instance of the mapped class for the current row.
|
protected void |
initialize(Class<T> mappedClass)
Initialize the mapping meta-data for the given class.
|
static <T> DataClassRowMapper<T> |
newInstance(Class<T> mappedClass)
Static factory method to create a new
DataClassRowMapper . |
static <T> DataClassRowMapper<T> |
newInstance(Class<T> mappedClass,
ConversionService conversionService)
Static factory method to create a new
DataClassRowMapper . |
getColumnValue, getColumnValue, getConversionService, getMappedClass, initBeanWrapper, isCheckFullyPopulated, isPrimitivesDefaultedForNullValue, lowerCaseName, mapRow, setCheckFullyPopulated, setConversionService, setMappedClass, setPrimitivesDefaultedForNullValue, suppressProperty, underscoreName
public DataClassRowMapper()
DataClassRowMapper
for bean-style configuration.protected void initialize(Class<T> mappedClass)
BeanPropertyRowMapper
initialize
in class BeanPropertyRowMapper<T>
mappedClass
- the mapped classprotected T constructMappedInstance(ResultSet rs, TypeConverter tc) throws SQLException
BeanPropertyRowMapper
constructMappedInstance
in class BeanPropertyRowMapper<T>
rs
- the ResultSet to map (pre-initialized for the current row)tc
- a TypeConverter with this RowMapper's conversion serviceSQLException
- if an SQLException is encounteredpublic static <T> DataClassRowMapper<T> newInstance(Class<T> mappedClass)
DataClassRowMapper
.mappedClass
- the class that each row should be mapped tonewInstance(Class, ConversionService)
public static <T> DataClassRowMapper<T> newInstance(Class<T> mappedClass, @Nullable ConversionService conversionService)
DataClassRowMapper
.mappedClass
- the class that each row should be mapped toconversionService
- the ConversionService
for binding
JDBC values to bean properties, or null
for nonenewInstance(Class)
,
BeanPropertyRowMapper.setConversionService(org.springframework.core.convert.ConversionService)