From 3ff31e5f89e8f55ba3738d3ab7eea1c16d1b5985 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Fri, 8 Apr 2016 18:50:57 +0200 Subject: [PATCH] DATACMNS-840 - ReturnedType's need for custom construction no includes availability of input properties. The indicator of whether custom construction is needed for a class based return type now includes whether input properties are available in the first place. --- .../org/springframework/data/repository/query/ReturnedType.java | 2 +- .../data/repository/query/ReturnedTypeUnitTests.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/springframework/data/repository/query/ReturnedType.java b/src/main/java/org/springframework/data/repository/query/ReturnedType.java index 822bcc44e..0131c30e4 100644 --- a/src/main/java/org/springframework/data/repository/query/ReturnedType.java +++ b/src/main/java/org/springframework/data/repository/query/ReturnedType.java @@ -262,7 +262,7 @@ public abstract class ReturnedType { * @see org.springframework.data.repository.query.ResultFactory.ReturnedType#needsCustomConstruction() */ public boolean needsCustomConstruction() { - return isDto(); + return isDto() && !inputProperties.isEmpty(); } /* diff --git a/src/test/java/org/springframework/data/repository/query/ReturnedTypeUnitTests.java b/src/test/java/org/springframework/data/repository/query/ReturnedTypeUnitTests.java index a37521ef0..08afcd423 100644 --- a/src/test/java/org/springframework/data/repository/query/ReturnedTypeUnitTests.java +++ b/src/test/java/org/springframework/data/repository/query/ReturnedTypeUnitTests.java @@ -139,6 +139,7 @@ public class ReturnedTypeUnitTests { ReturnedType type = getReturnedType("dtoWithMultipleConstructors"); assertThat(type.getInputProperties(), is(empty())); + assertThat(type.needsCustomConstruction(), is(false)); } private static ReturnedType getReturnedType(String methodName, Class... parameters) throws Exception {