Annotation Type DefineList


@Retention(RUNTIME) @Target(PARAMETER) public @interface DefineList
Defines a named attribute as a comma-separated String from the elements of the annotated array or List argument. Attributes are stored on the StatementContext, and may be used by the template engine. For example:
 @SqlUpdate("insert into <table> (<columns>) values (<values>)")
 int insert(@Define String table, @DefineList List<String> columns, @BindList List<Object> values);

 @SqlQuery("select <columns> from <table> where id = :id")
 ResultSet select(@DefineList("columns") List<String> columns, @Define("table") String table, @Bind("id") long id);
 

An array or List argument passed to @DefineList will be converted to a comma-separated String and set as a whole as a single specified attribute. Duplicate members in the List may cause SQL exceptions. An empty List or null members in the List will result in an IllegalArgumentException.

Be aware of the list members you're binding with @DefineList, as there is no input sanitization! Blindly passing Strings through @DefineList may make your application vulnerable to SQL Injection.

See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The attribute name to define.
  • Element Details

    • value

      String value
      The 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 key
      Default:
      ""