Annotation Interface BindList
Binds each value in the annotated
Iterable or array/varargs argument, and defines a named attribute as a
comma-separated list of each bound parameter name. Common use cases:
@SqlQuery("select * from things where id in (<ids>)")
List<Thing> getThings(@BindList int... ids)
@SqlUpdate("insert into things (<columnNames>) values (<values>)")
void insertThings(@DefineList List<String> columnNames, @BindList List<Object> values)
Throws IllegalArgumentException if the argument is not an array or Iterable. How null and empty collections are handled can be configured with onEmpty:EmptyHandling - throws IllegalArgumentException by default.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumdescribes what needs to be done if the passed argument is null or empty -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionWhat to do when the argument is null or empty.How to render each bound element into the defined attribute.The attribute name to define.
-
Element Details
-
value
String valueThe attribute name to define. If omitted, the name of the annotated parameter is used. It is an error to omit the name when there is no parameter naming information in your class files.- Returns:
- the attribute name.
- Default:
""
-
onEmpty
BindList.EmptyHandling onEmptyWhat to do when the argument is null or empty.- Returns:
- The strategy for handling an empty list. By default, throw an
IllegalArgumentException. - See Also:
- Default:
THROW
-
style
How to render each bound element into the defined attribute.BindListStyle.ROWSwraps each element in parentheses for use with the SQLVALUESlist constructor:@SqlQuery("select id from (values <ids>) as t(id)") List<Integer> ids(@BindList(style = BindListStyle.ROWS) List<Integer> ids)This value replaces anyBindListStyleconfigured on the statement or handle, so a style set on theJdbihas no effect on@BindListparameters.- Returns:
- the rendering style. By default, a plain comma-separated list.
- Default:
PLAIN
-