'Mybatis, pass muliple list as parametres

String loadCandies(@Param("id") String id, @Param("varietyList") List varietyList, @Param("errorCode") List errorCodes)

How can I achieve this in mybatis xml, as for a single list in parameter we can directly use foreach tag in where tag clause but if there are 2 list like above, how can we achieve this?

Note* - for a single list already referred StackOverflow answer

Can I pass a List as a parameter to a MyBatis mapper?



Solution 1:[1]

you can build a Context, like following:

public class QueryConext {
    private String id ;
    private List<Example> examples;
    //get and set
}
public class Example {
   private String key;
   private Object value;
   //get and set
}

pass parameters like below

//build QueryContext.
String load(QueryContext queryConext);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 shun chen