|
|
|
@ -41,6 +41,7 @@ import org.springframework.jdbc.core.RowMapper; |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Jens Schauder |
|
|
|
* @author Jens Schauder |
|
|
|
* @author Oliver Gierke |
|
|
|
* @author Oliver Gierke |
|
|
|
|
|
|
|
* @author Mark Paluch |
|
|
|
* @since 1.0 |
|
|
|
* @since 1.0 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class EntityRowMapper<T> implements RowMapper<T> { |
|
|
|
public class EntityRowMapper<T> implements RowMapper<T> { |
|
|
|
@ -63,8 +64,7 @@ public class EntityRowMapper<T> implements RowMapper<T> { |
|
|
|
this.context = context; |
|
|
|
this.context = context; |
|
|
|
this.instantiators = instantiators; |
|
|
|
this.instantiators = instantiators; |
|
|
|
this.accessStrategy = accessStrategy; |
|
|
|
this.accessStrategy = accessStrategy; |
|
|
|
|
|
|
|
this.idProperty = entity.getIdProperty(); |
|
|
|
idProperty = entity.getIdProperty(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/* |
|
|
|
@ -74,7 +74,7 @@ public class EntityRowMapper<T> implements RowMapper<T> { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public T mapRow(ResultSet resultSet, int rowNumber) throws SQLException { |
|
|
|
public T mapRow(ResultSet resultSet, int rowNumber) throws SQLException { |
|
|
|
|
|
|
|
|
|
|
|
T result = createInstance(resultSet); |
|
|
|
T result = createInstance(entity, resultSet, ""); |
|
|
|
|
|
|
|
|
|
|
|
ConvertingPropertyAccessor propertyAccessor = new ConvertingPropertyAccessor(entity.getPropertyAccessor(result), |
|
|
|
ConvertingPropertyAccessor propertyAccessor = new ConvertingPropertyAccessor(entity.getPropertyAccessor(result), |
|
|
|
conversions); |
|
|
|
conversions); |
|
|
|
@ -97,12 +97,6 @@ public class EntityRowMapper<T> implements RowMapper<T> { |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private T createInstance(ResultSet rs) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return instantiators.getInstantiatorFor(entity) //
|
|
|
|
|
|
|
|
.createInstance(entity, new ResultSetParameterValueProvider(rs, entity, conversions, "")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Read a single value or a complete Entity from the {@link ResultSet} passed as an argument. |
|
|
|
* Read a single value or a complete Entity from the {@link ResultSet} passed as an argument. |
|
|
|
* |
|
|
|
* |
|
|
|
@ -138,8 +132,8 @@ public class EntityRowMapper<T> implements RowMapper<T> { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
S instance = instantiators.getInstantiatorFor(entity) //
|
|
|
|
S instance = |
|
|
|
.createInstance(entity, new ResultSetParameterValueProvider(rs, entity, conversions, prefix)); |
|
|
|
createInstance(entity, rs, prefix); |
|
|
|
|
|
|
|
|
|
|
|
PersistentPropertyAccessor accessor = entity.getPropertyAccessor(instance); |
|
|
|
PersistentPropertyAccessor accessor = entity.getPropertyAccessor(instance); |
|
|
|
ConvertingPropertyAccessor propertyAccessor = new ConvertingPropertyAccessor(accessor, conversions); |
|
|
|
ConvertingPropertyAccessor propertyAccessor = new ConvertingPropertyAccessor(accessor, conversions); |
|
|
|
@ -151,6 +145,12 @@ public class EntityRowMapper<T> implements RowMapper<T> { |
|
|
|
return instance; |
|
|
|
return instance; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private <S> S createInstance(JdbcPersistentEntity<S> entity, ResultSet rs, String prefix) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return instantiators.getInstantiatorFor(entity) //
|
|
|
|
|
|
|
|
.createInstance(entity, new ResultSetParameterValueProvider(rs, entity, conversions, prefix)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@RequiredArgsConstructor |
|
|
|
@RequiredArgsConstructor |
|
|
|
private static class ResultSetParameterValueProvider implements ParameterValueProvider<JdbcPersistentProperty> { |
|
|
|
private static class ResultSetParameterValueProvider implements ParameterValueProvider<JdbcPersistentProperty> { |
|
|
|
|
|
|
|
|
|
|
|
|