@ -56,12 +56,12 @@ import org.springframework.util.StringUtils;
@@ -56,12 +56,12 @@ import org.springframework.util.StringUtils;
* properties . The names are matched either directly or by transforming a name
* separating the parts with underscores to the same name using "camel" case .
*
* < p > Mapping is provided for field s in the target class for many common types & mdash ;
* < p > Mapping is provided for propertie s in the target class for many common types & mdash ;
* for example : String , boolean , Boolean , byte , Byte , short , Short , int , Integer ,
* long , Long , float , Float , double , Double , BigDecimal , { @code java . util . Date } , etc .
*
* < p > To facilitate mapping between columns and field s that don ' t have matching names ,
* try using column aliases in the SQL statement like
* < p > To facilitate mapping between columns and propertie s that don ' t have matching
* names , try using column aliases in the SQL statement like
* { @code "select fname as first_name from customer" } , where { @code first_name }
* can be mapped to a { @code setFirstName ( String ) } method in the target class .
*
@ -107,13 +107,13 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
@@ -107,13 +107,13 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
@Nullable
private ConversionService conversionService = DefaultConversionService . getSharedInstance ( ) ;
/** Map of the field s we provide mapping for. */
/** Map of the propertie s we provide mapping for. */
@Nullable
private Map < String , PropertyDescriptor > mappedField s ;
private Map < String , PropertyDescriptor > mappedPropertie s ;
/** Set of bean properti es we provide mapping for. */
/** Set of bean property nam es we provide mapping for. */
@Nullable
private Set < String > mappedProperti es ;
private Set < String > mappedPropertyNam es ;
/ * *
@ -137,7 +137,7 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
@@ -137,7 +137,7 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
* Create a new { @code BeanPropertyRowMapper } .
* @param mappedClass the class that each row should be mapped to
* @param checkFullyPopulated whether we ' re strictly validating that
* all bean properties have been mapped from corresponding database field s
* all bean properties have been mapped from corresponding database column s
* /
public BeanPropertyRowMapper ( Class < T > mappedClass , boolean checkFullyPopulated ) {
initialize ( mappedClass ) ;
@ -170,7 +170,7 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
@@ -170,7 +170,7 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
/ * *
* Set whether we ' re strictly validating that all bean properties have been mapped
* from corresponding database field s.
* from corresponding database column s.
* < p > Default is { @code false } , accepting unpopulated properties in the target bean .
* /
public void setCheckFullyPopulated ( boolean checkFullyPopulated ) {
@ -179,21 +179,21 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
@@ -179,21 +179,21 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
/ * *
* Return whether we ' re strictly validating that all bean properties have been
* mapped from corresponding database field s.
* mapped from corresponding database column s.
* /
public boolean isCheckFullyPopulated ( ) {
return this . checkFullyPopulated ;
}
/ * *
* Set whether a { @code NULL } database field value should be ignored when
* Set whether a { @code NULL } database column value should be ignored when
* mapping to a corresponding primitive property in the target class .
* < p > Default is { @code false } , throwing an exception when nulls are mapped
* to Java primitives .
* < p > If this flag is set to { @code true } and you use an < em > ignored < / em >
* primitive property value from the mapped bean to update the database , the
* value in the database will be changed from { @code NULL } to the current value
* of that primitive property . That value may be the field ' s initial value
* of that primitive property . That value may be the property ' s initial value
* ( potentially Java ' s default value for the respective primitive type ) , or
* it may be some other value set for the property in the default constructor
* ( or initialization block ) or as a side effect of setting some other property
@ -240,31 +240,31 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
@@ -240,31 +240,31 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
* /
protected void initialize ( Class < T > mappedClass ) {
this . mappedClass = mappedClass ;
this . mappedField s = new HashMap < > ( ) ;
this . mappedProperti es = new HashSet < > ( ) ;
this . mappedPropertie s = new HashMap < > ( ) ;
this . mappedPropertyNam es = new HashSet < > ( ) ;
for ( PropertyDescriptor pd : BeanUtils . getPropertyDescriptors ( mappedClass ) ) {
if ( pd . getWriteMethod ( ) ! = null ) {
String lowerCaseName = lowerCaseName ( pd . getName ( ) ) ;
this . mappedField s . put ( lowerCaseName , pd ) ;
this . mappedPropertie s . put ( lowerCaseName , pd ) ;
String underscoreName = underscoreName ( pd . getName ( ) ) ;
if ( ! lowerCaseName . equals ( underscoreName ) ) {
this . mappedField s . put ( underscoreName , pd ) ;
this . mappedPropertie s . put ( underscoreName , pd ) ;
}
this . mappedProperti es . add ( pd . getName ( ) ) ;
this . mappedPropertyNam es . add ( pd . getName ( ) ) ;
}
}
}
/ * *
* Remove the specified property from the mapped field s.
* Remove the specified property from the mapped propertie s.
* @param propertyName the property name ( as used by property descriptors )
* @since 5 . 3 . 9
* /
protected void suppressProperty ( String propertyName ) {
if ( this . mappedField s ! = null ) {
this . mappedField s . remove ( lowerCaseName ( propertyName ) ) ;
this . mappedField s . remove ( underscoreName ( propertyName ) ) ;
if ( this . mappedPropertie s ! = null ) {
this . mappedPropertie s . remove ( lowerCaseName ( propertyName ) ) ;
this . mappedPropertie s . remove ( underscoreName ( propertyName ) ) ;
}
}
@ -326,8 +326,8 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
@@ -326,8 +326,8 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
for ( int index = 1 ; index < = columnCount ; index + + ) {
String column = JdbcUtils . lookupColumnName ( rsmd , index ) ;
String field = lowerCaseName ( StringUtils . delete ( column , " " ) ) ;
PropertyDescriptor pd = ( this . mappedField s ! = null ? this . mappedFields . get ( field ) : null ) ;
String property = lowerCaseName ( StringUtils . delete ( column , " " ) ) ;
PropertyDescriptor pd = ( this . mappedPropertie s ! = null ? this . mappedProperties . get ( property ) : null ) ;
if ( pd ! = null ) {
try {
Object value = getColumnValue ( rs , index , pd ) ;
@ -363,9 +363,9 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
@@ -363,9 +363,9 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
}
}
if ( populatedProperties ! = null & & ! populatedProperties . equals ( this . mappedProperti es ) ) {
throw new InvalidDataAccessApiUsageException ( "Given ResultSet does not contain all field s " +
"necessary to populate object of " + this . mappedClass + ": " + this . mappedProperti es ) ;
if ( populatedProperties ! = null & & ! populatedProperties . equals ( this . mappedPropertyNam es ) ) {
throw new InvalidDataAccessApiUsageException ( "Given ResultSet does not contain all propertie s " +
"necessary to populate object of " + this . mappedClass + ": " + this . mappedPropertyNam es ) ;
}
return mappedObject ;