|
37 | 37 | import org.junit.jupiter.api.BeforeEach;
|
38 | 38 | import org.junit.jupiter.api.Test;
|
39 | 39 | import org.junit.jupiter.api.extension.ExtendWith;
|
40 |
| - |
41 | 40 | import org.springframework.beans.factory.annotation.Autowired;
|
42 | 41 | import org.springframework.beans.factory.config.PropertiesFactoryBean;
|
43 | 42 | import org.springframework.context.ApplicationListener;
|
|
70 | 69 | import org.springframework.jdbc.core.JdbcTemplate;
|
71 | 70 | import org.springframework.jdbc.core.RowMapper;
|
72 | 71 | import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
| 72 | +import org.springframework.lang.Nullable; |
73 | 73 | import org.springframework.test.context.TestExecutionListeners;
|
74 | 74 | import org.springframework.test.context.junit.jupiter.SpringExtension;
|
75 | 75 | import org.springframework.test.jdbc.JdbcTestUtils;
|
@@ -559,6 +559,22 @@ void queryByAggregateReference() {
|
559 | 559 | assertThat(result).extracting(e -> e.idProp).containsExactly(two.idProp);
|
560 | 560 | }
|
561 | 561 |
|
| 562 | + @Test // GH-1167 |
| 563 | + void stringResult() { |
| 564 | + |
| 565 | + repository.save(createDummyEntity()); // just ensure we have data in the table |
| 566 | + |
| 567 | + assertThat(repository.returnInput("HELLO")).isEqualTo("HELLO"); |
| 568 | + } |
| 569 | + |
| 570 | + @Test // GH-1167 |
| 571 | + void nullStringResult() { |
| 572 | + |
| 573 | + repository.save(createDummyEntity()); // just ensure we have data in the table |
| 574 | + |
| 575 | + assertThat(repository.returnInput(null)).isNull(); |
| 576 | + } |
| 577 | + |
562 | 578 | private Instant createDummyBeforeAndAfterNow() {
|
563 | 579 |
|
564 | 580 | Instant now = Instant.now();
|
@@ -640,6 +656,10 @@ interface DummyEntityRepository extends CrudRepository<DummyEntity, Long> {
|
640 | 656 | List<DummyEntity> findByRef(int ref);
|
641 | 657 |
|
642 | 658 | List<DummyEntity> findByRef(AggregateReference<DummyEntity, Long> ref);
|
| 659 | + |
| 660 | + @Query("SELECT CAST(:hello AS CHAR(5)) FROM DUMMY_ENTITY") |
| 661 | + @Nullable |
| 662 | + String returnInput(@Nullable String hello); |
643 | 663 | }
|
644 | 664 |
|
645 | 665 | @Configuration
|
|
0 commit comments