简体   繁体   中英

ibatis isNotEmpty with multiple variables

Suppose I have a massive table called inactiveUsers and a search form. I want to conditionally join the inactiveUsers table if any user related characteristic is chosen (address, name, phoneNumber, etc...). Is there any way to do this without the following:

<isNotEmpty property="address">JOIN inactiveUsers</isNotEmpty>
<isNotEmpty property="phoneNumber">JOIN inactiveUsers</isNotEmpty>
<isNotEmpty property="name">JOIN inactiveUsers</isNotEmpty>

and so on for another 10-20 isNotEmpty clauses. I would like to do something like:

<isAnyNotEmpty properties="address, phoneNumber, name, ....">JOIN inactiveUsers</isNotEmpty>

Is this possible with ibatis? If so, how?

I would create a boolean property useJoin

public boolean isUseJoin() {
        if(!adress.equals("") && !phoneNumber.equals("")&&!name.equals("")) {
            return true;
        } else {
            return false;
        }
    }

not perfect but seems better than multiple statements in IBATIS clause.

I believe that's not possible (simply) with iBatis2 . iBatis3 has a <if> tag, but nevertheless the syntax would not be very simple.

I'd rather code a pseudoproperty in the object (if you can touch it) to ask for this condition, that would be much simpler.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM