Skip to content

Commit b10e889

Browse files
committed
Simplify code after fix in Commons.
1 parent 8fb217f commit b10e889

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/FetchableFluentQueryByPredicate.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ private void applyQuerySettings(ReturnedType returnedType, int limit, AbstractJP
219219

220220
List<String> inputProperties = returnedType.getInputProperties();
221221

222-
if (returnedType.needsCustomConstruction() && !inputProperties.isEmpty()) {
222+
if (returnedType.needsCustomConstruction()) {
223223

224224
Collection<String> requiredSelection;
225225
if (scrollPosition instanceof KeysetScrollPosition && returnedType.getReturnedType().isInterface()) {

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ private <S extends T> TypedQuery<S> getQuery(ReturnedType returnedType, @Nullabl
772772

773773
List<String> inputProperties = returnedType.getInputProperties();
774774

775-
if (returnedType.needsCustomConstruction() && !inputProperties.isEmpty()) {
775+
if (returnedType.needsCustomConstruction()) {
776776
query = (CriteriaQuery) (returnedType.getReturnedType().isInterface() ? builder.createTupleQuery()
777777
: builder.createQuery(returnedType.getReturnedType()));
778778
} else {
@@ -781,7 +781,7 @@ private <S extends T> TypedQuery<S> getQuery(ReturnedType returnedType, @Nullabl
781781

782782
Root<S> root = applySpecificationToCriteria(spec, domainClass, query);
783783

784-
if (returnedType.needsCustomConstruction() && !inputProperties.isEmpty()) {
784+
if (returnedType.needsCustomConstruction()) {
785785

786786
Collection<String> requiredSelection;
787787

spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/UserRepositoryTests.java

+10
Original file line numberDiff line numberDiff line change
@@ -2958,6 +2958,16 @@ void dynamicProjectionReturningList() {
29582958
assertThat(users).hasSize(1);
29592959
}
29602960

2961+
@Test // GH-2327
2962+
void dynamicOpenProjectionReturningList() {
2963+
2964+
flushTestUsers();
2965+
2966+
List<UserProjectionUsingSpEL> users = repository.findAsListByFirstnameLike("%O%", UserProjectionUsingSpEL.class);
2967+
2968+
assertThat(users).hasSize(1);
2969+
}
2970+
29612971
@Test // DATAJPA-1179
29622972
void duplicateSpelsWorkAsIntended() {
29632973

0 commit comments

Comments
 (0)