File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change 63
63
</subsection >
64
64
<subsection name =" choose、when、otherwise" id =" chooseWhenOtherwise" >
65
65
<p >有时候,我们不想使用所有的条件,而只是想从多个条件中选择一个使用。针对这种情况,MyBatis 提供了 choose 元素,它有点像 Java 中的 switch 语句。</p >
66
- <p >还是上面的例子,但是策略变为:传入了 “title” 就按 “title” 查找,传入了 “author” 就按 “author” 查找的情形。若两者都没有传入,就返回标记为 featured 的 BLOG(这可能是管理员认为,与其返回大量的无意义随机 Blog,还不如返回一些由管理员挑选的 Blog)。</p >
66
+ <p >还是上面的例子,但是策略变为:传入了 “title” 就按 “title” 查找,传入了 “author” 就按 “author” 查找的情形。若两者都没有传入,就返回标记为 featured 的 BLOG(这可能是管理员认为,与其返回大量的无意义随机 Blog,还不如返回一些由管理员精选的 Blog)。</p >
67
67
<source ><![CDATA[ <select id="findActiveBlogLike"
68
68
resultType="Blog">
69
69
SELECT * FROM BLOG WHERE state = ‘ACTIVE’
81
81
</select>]]> </source >
82
82
</subsection >
83
83
<subsection name =" trim、where、set" id =" trimWhereSet" >
84
- <p >前面几个例子已经合宜地解决了一个臭名昭著的动态 SQL 问题。现在回到之前的 “if” 示例,这次我们将 “state = ‘ACTIVE’” 设置成动态条件,看看会发生什么。</p >
84
+ <p >前面几个例子已经方便地解决了一个臭名昭著的动态 SQL 问题。现在回到之前的 “if” 示例,这次我们将 “state = ‘ACTIVE’” 设置成动态条件,看看会发生什么。</p >
85
85
<source ><![CDATA[ <select id="findActiveBlogLike"
86
86
resultType="Blog">
87
87
SELECT * FROM BLOG
You can’t perform that action at this time.
0 commit comments