Skip to content

Commit dc8dd02

Browse files
author
Andreas Skomedal
committed
spring data 2.4 native projection bug
1 parent e2db961 commit dc8dd02

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/test/java/org/springframework/data/jpa/repository/UserRepositoryFinderTests.java

+5
Original file line numberDiff line numberDiff line change
@@ -288,4 +288,9 @@ void rejectsStreamExecutionIfNoSurroundingTransactionActive() {
288288
void executesNamedQueryWithConstructorExpression() {
289289
userRepository.findByNamedQueryWithConstructorExpression();
290290
}
291+
292+
@Test
293+
void returnProjectedTimestampNativeQuery() {
294+
assertThat(userRepository.findTimestampDtoByNativeQuery().get(0).getCreatedAt()).isNotNull();
295+
}
291296
}

src/test/java/org/springframework/data/jpa/repository/sample/UserRepository.java

+9
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package org.springframework.data.jpa.repository.sample;
1717

18+
import java.time.LocalDateTime;
1819
import java.util.Collection;
1920
import java.util.Date;
2021
import java.util.List;
@@ -612,6 +613,14 @@ Page<User> findAllOrderedBySpecialNameMultipleParams(@Param("name") String name,
612613
// DATAJPA-1303
613614
Page<User> findByAttributesIgnoreCaseIn(Pageable pageable, String... attributes);
614615

616+
@Query(value = "select createdAt from SD_User", nativeQuery = true)
617+
List<Java8DateTimeInterface> findTimestampDtoByNativeQuery();
618+
619+
interface Java8DateTimeInterface {
620+
621+
LocalDateTime getCreatedAt();
622+
}
623+
615624
interface RolesAndFirstname {
616625

617626
String getFirstname();

0 commit comments

Comments
 (0)