Browse Source

DATAJDBC-252 - Polishing.

Original pull request: #86.
pull/87/head
Oliver Gierke 7 years ago
parent
commit
84379b28e9
  1. 12
      src/main/java/org/springframework/data/jdbc/core/EntityRowMapper.java

12
src/main/java/org/springframework/data/jdbc/core/EntityRowMapper.java

@ -70,11 +70,9 @@ public class EntityRowMapper<T> implements RowMapper<T> { @@ -70,11 +70,9 @@ public class EntityRowMapper<T> implements RowMapper<T> {
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<T> implements RowMapper<T> { @@ -92,12 +90,16 @@ public class EntityRowMapper<T> implements RowMapper<T> {
}
if (property.isCollectionLike() && id != null) {
propertyAccessor.setProperty(property, accessStrategy.findAllByProperty(id, property));
} else if (property.isMap() && id != null) {
Iterable<Object> allByProperty = accessStrategy.findAllByProperty(id, property);
propertyAccessor.setProperty(property, ITERABLE_OF_ENTRY_TO_MAP_CONVERTER.convert(allByProperty));
} else {
propertyAccessor.setProperty(property, readFrom(resultSet, property, ""));
}
}

Loading…
Cancel
Save