3838 * @author Jens Schauder
3939 * @author Oliver Gierke
4040 * @author Mark Paluch
41+ * @author Maciej Walkowiak
4142 */
4243public class EntityRowMapper <T > implements RowMapper <T > {
4344
@@ -76,7 +77,7 @@ public T mapRow(ResultSet resultSet, int rowNumber) {
7677 idValue = readFrom (resultSet , idProperty , prefix );
7778 }
7879
79- T result = createInstance (entity , resultSet , idValue );
80+ T result = createInstance (entity , resultSet , idValue , prefix );
8081
8182 return entity .requiresPropertyPopulation () //
8283 ? populateProperties (result , resultSet ) //
@@ -97,21 +98,21 @@ private T populateProperties(T result, ResultSet resultSet) {
9798 continue ;
9899 }
99100
100- propertyAccessor .setProperty (property , readOrLoadProperty (resultSet , id , property ));
101+ propertyAccessor .setProperty (property , readOrLoadProperty (resultSet , id , property , "" ));
101102 }
102103
103104 return propertyAccessor .getBean ();
104105 }
105106
106107 @ Nullable
107- private Object readOrLoadProperty (ResultSet resultSet , @ Nullable Object id , RelationalPersistentProperty property ) {
108+ private Object readOrLoadProperty (ResultSet resultSet , @ Nullable Object id , RelationalPersistentProperty property , String prefix ) {
108109
109110 if (property .isCollectionLike () && id != null ) {
110111 return accessStrategy .findAllByProperty (id , property );
111112 } else if (property .isMap () && id != null ) {
112113 return ITERABLE_OF_ENTRY_TO_MAP_CONVERTER .convert (accessStrategy .findAllByProperty (id , property ));
113114 } else {
114- return readFrom (resultSet , property , "" );
115+ return readFrom (resultSet , property , prefix );
115116 }
116117 }
117118
@@ -159,7 +160,7 @@ private <S> S readEntityFrom(ResultSet rs, RelationalPersistentProperty property
159160 return null ;
160161 }
161162
162- S instance = createInstance (entity , rs , idValue );
163+ S instance = createInstance (entity , rs , idValue , prefix );
163164
164165 PersistentPropertyAccessor <S > accessor = converter .getPropertyAccessor (entity , instance );
165166
@@ -180,7 +181,7 @@ private Object getObjectFromResultSet(ResultSet rs, String backreferenceName) {
180181 }
181182 }
182183
183- private <S > S createInstance (RelationalPersistentEntity <S > entity , ResultSet rs , @ Nullable Object idValue ) {
184+ private <S > S createInstance (RelationalPersistentEntity <S > entity , ResultSet rs , @ Nullable Object idValue , String prefix ) {
184185
185186 return converter .createInstance (entity , parameter -> {
186187
@@ -190,7 +191,7 @@ private <S> S createInstance(RelationalPersistentEntity<S> entity, ResultSet rs,
190191
191192 RelationalPersistentProperty property = entity .getRequiredPersistentProperty (parameterName );
192193
193- return readOrLoadProperty (rs , idValue , property );
194+ return readOrLoadProperty (rs , idValue , property , prefix );
194195 });
195196 }
196197}
0 commit comments