From 84379b28e9d1d21fd3746aac86583e4b96059fd1 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Tue, 21 Aug 2018 11:04:11 +0200 Subject: [PATCH] DATAJDBC-252 - Polishing. Original pull request: #86. --- .../data/jdbc/core/EntityRowMapper.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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 9ff594c41..dbaa053ef 100644 --- a/src/main/java/org/springframework/data/jdbc/core/EntityRowMapper.java +++ b/src/main/java/org/springframework/data/jdbc/core/EntityRowMapper.java @@ -70,11 +70,9 @@ public class EntityRowMapper implements RowMapper { T result = createInstance(entity, resultSet, ""); - if (entity.requiresPropertyPopulation()) { - return populateProperties(result, resultSet); - } - - return result; + return entity.requiresPropertyPopulation() // + ? populateProperties(result, resultSet) // + : result; } private T populateProperties(T result, ResultSet resultSet) { @@ -92,12 +90,16 @@ public class EntityRowMapper implements RowMapper { } if (property.isCollectionLike() && id != null) { + propertyAccessor.setProperty(property, accessStrategy.findAllByProperty(id, property)); + } else if (property.isMap() && id != null) { Iterable allByProperty = accessStrategy.findAllByProperty(id, property); propertyAccessor.setProperty(property, ITERABLE_OF_ENTRY_TO_MAP_CONVERTER.convert(allByProperty)); + } else { + propertyAccessor.setProperty(property, readFrom(resultSet, property, "")); } }