2222import java .sql .JDBCType ;
2323import java .sql .ResultSet ;
2424import java .util .ArrayList ;
25+ import java .util .Iterator ;
2526import java .util .List ;
2627import java .util .Properties ;
2728import java .util .Set ;
2829import java .util .stream .Stream ;
2930
3031import org .assertj .core .api .Assertions ;
32+ import org .jetbrains .annotations .NotNull ;
3133import org .junit .jupiter .api .BeforeEach ;
3234import org .junit .jupiter .api .Test ;
3335import org .mockito .ArgumentCaptor ;
@@ -211,7 +213,6 @@ void convertsEnumCollectionParameterUsingCustomConverterWhenRegisteredForType()
211213 assertThat (sqlParameterSource .getValue ("directions" )).asList ().containsExactlyInAnyOrder (-1 , 1 );
212214 }
213215
214-
215216 @ Test // GH-1212
216217 void doesNotConvertNonCollectionParameter () {
217218
@@ -222,6 +223,18 @@ void doesNotConvertNonCollectionParameter() {
222223 assertThat (sqlParameterSource .getValue ("value" )).isEqualTo (1 );
223224 }
224225
226+ @ Test // GH-1343
227+ void appliesConverterToIterable () {
228+
229+ SqlParameterSource sqlParameterSource = forMethod ("findByListContainer" , ListContainer .class ) //
230+ .withCustomConverters (ListContainerToStringConverter .INSTANCE )
231+ .withArguments (new ListContainer ("one" , "two" , "three" )) //
232+ .extractParameterSource ();
233+
234+ assertThat (sqlParameterSource .getValue ("value" )).isEqualTo ("one" );
235+
236+ }
237+
225238 QueryFixture forMethod (String name , Class ... paramTypes ) {
226239 return new QueryFixture (createMethod (name , paramTypes ));
227240 }
@@ -321,6 +334,9 @@ interface MyRepository extends Repository<Object, Long> {
321334 @ Query (value = "some sql statement" )
322335 List <Object > findBySimpleValue (Integer value );
323336
337+ @ Query (value = "some sql statement" )
338+ List <Object > findByListContainer (ListContainer value );
339+
324340 @ Query ("SELECT * FROM table WHERE c = :#{myext.testValue} AND c2 = :#{myext.doSomething()}" )
325341 Object findBySpelExpression (Object object );
326342 }
@@ -417,6 +433,32 @@ public Direction convert(Integer source) {
417433 }
418434 }
419435
436+ static class ListContainer implements Iterable <String > {
437+
438+ private final List <String > values ;
439+
440+ ListContainer (String ... values ) {
441+ this .values = List .of (values );
442+ }
443+
444+ @ NotNull
445+ @ Override
446+ public Iterator <String > iterator () {
447+ return values .iterator ();
448+ }
449+ }
450+
451+ @ WritingConverter
452+ enum ListContainerToStringConverter implements Converter <ListContainer , String > {
453+
454+ INSTANCE ;
455+
456+ @ Override
457+ public String convert (ListContainer source ) {
458+ return source .values .get (0 );
459+ }
460+ }
461+
420462 private static class DummyEntity {
421463 private Long id ;
422464
0 commit comments