|
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;
|
|
68 | 67 | import org.springframework.jdbc.core.JdbcTemplate;
|
69 | 68 | import org.springframework.jdbc.core.RowMapper;
|
70 | 69 | import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
| 70 | +import org.springframework.lang.Nullable; |
71 | 71 | import org.springframework.test.context.TestExecutionListeners;
|
72 | 72 | import org.springframework.test.context.junit.jupiter.SpringExtension;
|
73 | 73 | import org.springframework.test.jdbc.JdbcTestUtils;
|
@@ -549,6 +549,22 @@ void queryByAggregateReference() {
|
549 | 549 | assertThat(result).extracting(e -> e.idProp).containsExactly(two.idProp);
|
550 | 550 | }
|
551 | 551 |
|
| 552 | + @Test // GH-1167 |
| 553 | + void stringResult() { |
| 554 | + |
| 555 | + repository.save(createDummyEntity()); // just ensure we have data in the table |
| 556 | + |
| 557 | + assertThat(repository.returnInput("HELLO")).isEqualTo("HELLO"); |
| 558 | + } |
| 559 | + |
| 560 | + @Test // GH-1167 |
| 561 | + void nullStringResult() { |
| 562 | + |
| 563 | + repository.save(createDummyEntity()); // just ensure we have data in the table |
| 564 | + |
| 565 | + assertThat(repository.returnInput(null)).isNull(); |
| 566 | + } |
| 567 | + |
552 | 568 | private Instant createDummyBeforeAndAfterNow() {
|
553 | 569 |
|
554 | 570 | Instant now = Instant.now();
|
@@ -625,6 +641,10 @@ interface DummyEntityRepository extends CrudRepository<DummyEntity, Long> {
|
625 | 641 |
|
626 | 642 | List<DummyEntity> findByRef(int ref);
|
627 | 643 | List<DummyEntity> findByRef(AggregateReference<DummyEntity, Long> ref);
|
| 644 | + |
| 645 | + @Query("SELECT CAST(:hello AS CHAR(5)) FROM DUMMY_ENTITY") |
| 646 | + @Nullable |
| 647 | + String returnInput(@Nullable String hello); |
628 | 648 | }
|
629 | 649 |
|
630 | 650 | @Configuration
|
|
0 commit comments