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.
精彩评论