DATACMNS-734 - Allow comma separated list of values to be bound to an array.

We now convert comma separated values for an array property by splitting values and converting each of them. This allows to convert address.location=40.740337,-73.995146 to 

class Address {
  Double[] location;
}
This commit is contained in:
Christoph Strobl
2015-07-20 10:36:16 +02:00
committed by Oliver Gierke
parent ac080bacf7
commit 11056be292
3 changed files with 41 additions and 7 deletions

View File

@@ -191,7 +191,8 @@ public class QuerydslPredicateBuilder {
*/
private Collection<Object> convertToPropertyPathSpecificType(List<String> source, PropertyPath path) {
Class<?> targetType = path.getLeafProperty().getType();
Class<?> targetType = path.getLeafProperty().getOwningType().getProperty(path.getLeafProperty().getSegment())
.getType();
if (source.isEmpty() || isSingleElementCollectionWithoutText(source)) {
return Collections.emptyList();
@@ -201,8 +202,8 @@ public class QuerydslPredicateBuilder {
for (String value : source) {
target.add(conversionService.canConvert(value.getClass(), targetType)
? conversionService.convert(value, targetType) : value);
target.add(conversionService.canConvert(String.class, targetType) ? conversionService.convert(
targetType.isArray() ? value.split(",") : value, targetType) : value);
}
return target;