Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6751415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:55:29+00:00 2026-05-26T12:55:29+00:00

I have a personal website which uses iBATIS 2.3.x. Recently I’m adding a complex

  • 0

I have a personal website which uses iBATIS 2.3.x. Recently I’m adding a complex searching feature to the site, need to query the data by a list of object, likes:

public Class PromotionAttribute {
    String attributeName;
    String attributeValue;
}

The query looks like:

select p.* from promotions p
join promotion_attributes pa on p.id=pa.id
where 
<foreach item="PromotionAttribute" index="index" collection="list" open="(" separator=" or " close=")">
pa.attribute_name=#{attributeName} and pa.attribute_value=#{attributeValue}#
</foreach>

For the above query, it’s only a pseudocode since I didn’t use the higher version of iBATIS, its meaning is I want to generate a dynamic query condition.

My question is:
I’m not sure whether iBATIS 2.3.x supports “foreach” tag, if not, how to implement this kind of query?

Thanks,
Shuiqing

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:55:29+00:00Added an answer on May 26, 2026 at 12:55 pm

    You can use “iterate” in 2.3.* in place of foreach like below. Only iBATIS 3/ MyBATIS uses OGNL based expressions like choose, foreach, trim…

    in Java,
    
            Map paramMap = new HashMap();
            paramMap.put("productTypes", productTypes);
            sqlMapClient.queryForList("getProducts", paramMap);
    in xml,
    
    <select id="getProducts" parameterClass="java.util.Map" 
    resultClass="Product">
    SELECT * FROM Products
    <dynamic prepend="WHERE productType IN ">
    <iterate property="productTypes"
        open="(" close=")"
        conjunction=",">
        productType=#productType#
     </iterate>
     </dynamic>
     </select>
    

    You can use parameterClass as “java.util.Map” and pass list value by setting “productTypes” as key.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have very large website which uses a lot of cookies. There are approx.
i have a website (personal site) where i upload my music. i am a
I'm building a small-scale website (a personal one) in which each page would have
I am currently developing my personal website and part of my site I have
I have a personal website with a MediaWiki installation on a shared host. The
At my personal website while viewing a single post, i have an overview DIV,
I have a database for my personal site and at the moment it is
Lets say i have a website mysite.com that will store some sensitive personal data
I am trying to have tooltip for my personal website http://www.stacked.in . when I
I have written an ASP.NET page for a customer which uses the C# Facebook

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.