diff --git a/src/main/java/org/springframework/data/jdbc/core/EntityRowMapper.java b/src/main/java/org/springframework/data/jdbc/core/EntityRowMapper.java index 653eac450..1160a3637 100644 --- a/src/main/java/org/springframework/data/jdbc/core/EntityRowMapper.java +++ b/src/main/java/org/springframework/data/jdbc/core/EntityRowMapper.java @@ -41,6 +41,7 @@ import org.springframework.jdbc.core.RowMapper; * * @author Jens Schauder * @author Oliver Gierke + * @author Mark Paluch * @since 1.0 */ public class EntityRowMapper implements RowMapper { @@ -63,8 +64,7 @@ public class EntityRowMapper implements RowMapper { this.context = context; this.instantiators = instantiators; this.accessStrategy = accessStrategy; - - idProperty = entity.getIdProperty(); + this.idProperty = entity.getIdProperty(); } /* @@ -74,7 +74,7 @@ public class EntityRowMapper implements RowMapper { @Override 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), conversions); @@ -97,12 +97,6 @@ public class EntityRowMapper implements RowMapper { 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. * @@ -138,8 +132,8 @@ public class EntityRowMapper implements RowMapper { return null; } - S instance = instantiators.getInstantiatorFor(entity) // - .createInstance(entity, new ResultSetParameterValueProvider(rs, entity, conversions, prefix)); + S instance = + createInstance(entity, rs, prefix); PersistentPropertyAccessor accessor = entity.getPropertyAccessor(instance); ConvertingPropertyAccessor propertyAccessor = new ConvertingPropertyAccessor(accessor, conversions); @@ -151,6 +145,12 @@ public class EntityRowMapper implements RowMapper { return instance; } + private S createInstance(JdbcPersistentEntity entity, ResultSet rs, String prefix) { + + return instantiators.getInstantiatorFor(entity) // + .createInstance(entity, new ResultSetParameterValueProvider(rs, entity, conversions, prefix)); + } + @RequiredArgsConstructor private static class ResultSetParameterValueProvider implements ParameterValueProvider {