1616package org .springframework .data .r2dbc .repository ;
1717
1818import io .r2dbc .spi .ConnectionFactory ;
19+ import lombok .AllArgsConstructor ;
20+ import lombok .Data ;
1921import reactor .core .publisher .Flux ;
2022import reactor .core .publisher .Mono ;
23+ import reactor .test .StepVerifier ;
24+
25+ import java .time .LocalDateTime ;
2126
2227import javax .sql .DataSource ;
2328
2429import org .junit .ClassRule ;
30+ import org .junit .Test ;
2531import org .junit .runner .RunWith ;
2632
33+ import org .springframework .beans .factory .annotation .Autowired ;
2734import org .springframework .context .annotation .Bean ;
2835import org .springframework .context .annotation .ComponentScan .Filter ;
2936import org .springframework .context .annotation .Configuration ;
3037import org .springframework .context .annotation .FilterType ;
38+ import org .springframework .dao .DataAccessException ;
39+ import org .springframework .data .annotation .Id ;
3140import org .springframework .data .r2dbc .config .AbstractR2dbcConfiguration ;
3241import org .springframework .data .r2dbc .repository .config .EnableR2dbcRepositories ;
3342import org .springframework .data .r2dbc .repository .support .R2dbcRepositoryFactory ;
3443import org .springframework .data .r2dbc .testing .ExternalDatabase ;
3544import org .springframework .data .r2dbc .testing .MySqlTestSupport ;
45+ import org .springframework .data .repository .reactive .ReactiveCrudRepository ;
46+ import org .springframework .jdbc .core .JdbcTemplate ;
3647import org .springframework .test .context .ContextConfiguration ;
3748import org .springframework .test .context .junit4 .SpringRunner ;
3849
@@ -47,9 +58,12 @@ public class MySqlR2dbcRepositoryIntegrationTests extends AbstractR2dbcRepositor
4758
4859 @ ClassRule public static final ExternalDatabase database = MySqlTestSupport .database ();
4960
61+ @ Autowired DateTestsRepository dateTestsRepository ;
62+
5063 @ Configuration
5164 @ EnableR2dbcRepositories (considerNestedRepositories = true ,
52- includeFilters = @ Filter (classes = MySqlLegoSetRepository .class , type = FilterType .ASSIGNABLE_TYPE ))
65+ includeFilters = { @ Filter (classes = MySqlLegoSetRepository .class , type = FilterType .ASSIGNABLE_TYPE ),
66+ @ Filter (classes = DateTestsRepository .class , type = FilterType .ASSIGNABLE_TYPE ) })
5367 static class IntegrationTestConfiguration extends AbstractR2dbcConfiguration {
5468
5569 @ Bean
@@ -79,6 +93,29 @@ protected Class<? extends LegoSetRepository> getRepositoryInterfaceType() {
7993 return MySqlLegoSetRepository .class ;
8094 }
8195
96+ @ Test
97+ public void shouldUserJsr310Types () {
98+
99+ JdbcTemplate jdbcTemplate = createJdbcTemplate (createDataSource ());
100+
101+ try {
102+ jdbcTemplate .execute ("DROP TABLE date_tests" );
103+ } catch (DataAccessException e ) {}
104+
105+ jdbcTemplate .execute ("CREATE TABLE date_tests (id int, created_timestamp TIMESTAMP, created_date datetime);" );
106+
107+ dateTestsRepository .save (new DateTests (null , LocalDateTime .now (), LocalDateTime .now ())).as (StepVerifier ::create )
108+ .expectNextCount (1 ).verifyComplete ();
109+ }
110+
111+ @ Data
112+ @ AllArgsConstructor
113+ static class DateTests {
114+ @ Id Integer id ;
115+ LocalDateTime createdTimestamp ;
116+ LocalDateTime createdDate ;
117+ }
118+
82119 interface MySqlLegoSetRepository extends LegoSetRepository {
83120
84121 @ Override
@@ -93,4 +130,8 @@ interface MySqlLegoSetRepository extends LegoSetRepository {
93130 @ Query ("SELECT id FROM legoset" )
94131 Flux <Integer > findAllIds ();
95132 }
133+
134+ interface DateTestsRepository extends ReactiveCrudRepository <DateTests , Integer > {
135+
136+ }
96137}
0 commit comments