Skip to content

Commit 80e44a3

Browse files
committed
DATACMNS-89 - Returned type now does not consider Number types DTO types.
1 parent d03ca30 commit 80e44a3

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/main/java/org/springframework/data/repository/query/ReturnedType.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ private boolean isDto() {
296296
return !Object.class.equals(type) && //
297297
!isDomainSubtype() && //
298298
!isPrimitiveOrWrapper() && //
299+
!Number.class.isAssignableFrom(type) && //
299300
!VOID_TYPES.contains(type) && //
300301
!type.getPackage().getName().startsWith("java.lang");
301302
}

src/test/java/org/springframework/data/repository/query/ReturnedTypeUnitTests.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static org.junit.Assert.*;
2020

2121
import java.lang.reflect.Method;
22+
import java.math.BigInteger;
2223
import java.util.List;
2324

2425
import org.junit.Test;
@@ -116,6 +117,19 @@ public void detectsOpenProjection() throws Exception {
116117
assertThat(type.getTypeToRead(), is(typeCompatibleWith(Sample.class)));
117118
}
118119

120+
/**
121+
* @see DATACMNS-89
122+
*/
123+
@Test
124+
public void detectsComplexNumberTypes() throws Exception {
125+
126+
ReturnedType type = getReturnedType("countQuery");
127+
128+
assertThat(type.isProjecting(), is(false));
129+
assertThat(type.needsCustomConstruction(), is(false));
130+
assertThat(type.getTypeToRead(), is(typeCompatibleWith(BigInteger.class)));
131+
}
132+
119133
private static ReturnedType getReturnedType(String methodName, Class<?>... parameters) throws Exception {
120134
return getQueryMethod(methodName, parameters).getResultProcessor().getReturnedType();
121135
}
@@ -146,6 +160,8 @@ interface SampleRepository extends Repository<Sample, Long> {
146160
OpenProjection findOneOpenProjection();
147161

148162
Page<SampleProjection> findPageProjection(Pageable pageable);
163+
164+
BigInteger countQuery();
149165
}
150166

151167
static class Sample {

0 commit comments

Comments
 (0)