Ibatis realization of the use of iterate

Source: Internet
Author: User

<iterate

Property= ""/* optional, use the property name in the passed-in parameter collection to get the value, this must be a list type, otherwise it will appear outofrangeexception, usually the parameter uses JAVA.UTIL.MAP  is used only if the passed in parameter itself is a java.util.List and cannot be used only with this property.   /

Conjunction= ""/* optional, iterate can be seen as a loop that specifies the symbols added after each loop , such as making each loop or, set this property to or*/

Open= ""/* optional, looping start symbol */

Close= ""/* optional, Loop end symbol */

Prepend= ""/* optional, plus the symbol before the open specified symbol */

>

1. Enquiry

<!--iterate, queries based on multiple matching criteria, like in (a,b,c)--

<select id= "Selectbyiterate" parameterclass= "java.util.List" resultclass= "User" >

SELECT * from the USERS WHERE user_id in

<iterate conjunction= "," open= "(" close= ")" >

#ids []#

</iterate>

</select>

Note: Do not attribute property, otherwise error. String index out of range: 1

2. However, if the parameter has multiple incoming one is list, the other is not, Parameterclass is a map, the property attribute is required to differentiate the collection to traverse.

2. Delete

<!--Bulk Delete objects, iterate do not property properties--

<delete id= "Delstudybook" parameterclass= "Java.util.List" >

Delete from Studybook WHERE ID in

<iterate conjunction= "," open= "(" close= ")" >

#bookList []#

</iterate>

</delete>

http://hongzhguan.iteye.com/blog/1222353

Ibatis realization of the use of iterate

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.