0

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?

Ankur
  • 19
  • 5
  • The parameter should just be wrapped in a `map` so you should be able to do a `foreach` using both `collection="varietyList"` and `collection="errorCode"` separately in the query. – kendavidson May 04 '22 at 18:00

1 Answers1

0

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);
shun chen
  • 38
  • 6