ibatis isNotEmpty 具有多个变量
假设我有一个名为 inactiveUsers 的大型表和一个搜索表单。如果选择了任何与用户相关的特征(地址、姓名、电话号码等),我想有条件地加入 inactiveUsers 表。有没有办法在不使用以下内容的情况下执行此操作:
<isNotEmpty property="address">JOIN inactiveUsers</isNotEmpty>
<isNotEmpty property="phoneNumber">JOIN inactiveUsers</isNotEmpty>
<isNotEmpty property="name">JOIN inactiveUsers</isNotEmpty>
等等另外 10-20 个 isNotEmpty 子句。我想做这样的事情:
<isAnyNotEmpty properties="address, phoneNumber, name, ....">JOIN inactiveUsers</isNotEmpty>
ibatis 可以做到这一点吗?如果是这样,怎么办?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会创建一个布尔属性 useJoin
并不完美,但似乎比 IBATIS 子句中的多个语句更好。
I would create a boolean property useJoin
not perfect but seems better than multiple statements in IBATIS clause.
我相信这对于 iBatis2 来说是不可能的。 iBatis3 有一个
标签,但语法仍然不是很简单。我宁愿在对象中编写一个伪属性(如果你可以触摸它)来询问这个条件,那会简单得多。
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.