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 6363 </subsection >
6464 <subsection name =" choose、when、otherwise" id =" chooseWhenOtherwise" >
6565 <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 >
6767 <source ><![CDATA[ <select id="findActiveBlogLike"
6868 resultType="Blog">
6969 SELECT * FROM BLOG WHERE state = ‘ACTIVE’
8181</select>]]> </source >
8282 </subsection >
8383 <subsection name =" trim、where、set" id =" trimWhereSet" >
84- <p >前面几个例子已经合宜地解决了一个臭名昭著的动态 SQL 问题。现在回到之前的 “if” 示例,这次我们将 “state = ‘ACTIVE’” 设置成动态条件,看看会发生什么。</p >
84+ <p >前面几个例子已经方便地解决了一个臭名昭著的动态 SQL 问题。现在回到之前的 “if” 示例,这次我们将 “state = ‘ACTIVE’” 设置成动态条件,看看会发生什么。</p >
8585 <source ><![CDATA[ <select id="findActiveBlogLike"
8686 resultType="Blog">
8787 SELECT * FROM BLOG
You can’t perform that action at this time.
0 commit comments