MyBatis Query instance, how does the in SQL write in MyBatis--the query condition with list

Source: Internet
Author: User

in the service, put the parameters in the HashMap list<String> list =NewArraylist<string>(); List.add ("X"); List.add ("Y"); List.add ("Z"); String s= "A"Date D=NewDate (); HashMap<String,Object> param =NewHashmap<string,object>();p aram.put ("List", list);p Aram.put ("S", s);p Aram.put ("D", D); Xxxdao.queryxxx (param); in MyBatis's mapper, it reads:<select id = "Queryxxx", Resulttype = "XXX", Paramtertype = "Java.lang.HashMap" >Select* from tab where Zi_duan1 = #{s} and zi_duan2 =#{d}and zi_duan3 in<foreach item= "Item" index= "index" collection= "list" open= "("Separator= "," close= ")" >#{item}</foreach></select>
In the service, place the parameters in the HashMap list<string> list = new arraylist<string>() list.add ("x"); List.add ("Y" ); List.add ("Z"); String s = "A"Date d = new date (); hashmap<string,object> param = new hashmap<string,object>();p aram.put ("list", list);p aram.put (" S ", s);p aram.put (" D ", D); Xxxdao.queryxxx (param); in MyBatis's mapper, it reads: <select id = "Queryxxx", Resulttype = "XXX", Paramtertype = " Java.lang.HashMap ">select * from tab where Zi_duan1 = #{s} and zi_duan2 = #{d}and zi_duan3 in <foreach ite M= "Item" index= "index" collection= "list" open= "(" separator= "," close= ")" > #{item} </foreach></ select>             

MyBatis Query instance, how does the in SQL write in MyBatis--the query condition with list

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.