浏览 9742 次
锁定老帖子 主题:有关于IBatis中的statement
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2006-01-16
定义动态参数的时候 有时候用 #param# 有时候用 $param$ 请问这两种有什么区别???? 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2006-01-16
以前遇到过:
http://forum.iteye.com/viewtopic.php?t=16152 |
|
返回顶楼 | |
发表时间:2006-01-16
去看了 谢谢
可是里面没有说原理 在哪种情况下用哪句??? |
|
返回顶楼 | |
发表时间:2006-01-16
Cliton Begin 在 iBATIS SQL Maps Developer Guide 有这个问题的说明呀:
找 Simple Dynamic SQL Elements 一节就可以了,很详细的。 本来想把原文贴上来,太长,还是自己找吧。 |
|
返回顶楼 | |
发表时间:2006-01-17
Despite the power of the full Dynamic Mapped Statement API discussed above, sometimes you just need a simple, small piece of your SQL to be dynamic. For this, SQL statements and statements can contain simple dynamic SQL elements to help implement dynamic order by clauses, dynamic select columns or pretty much any part of the SQL statement. The concept works much like inline parameter maps, but uses a slightly different syntax. Consider the following example: <statement id=”getProduct” resultMap=”get-product-result”> select * from PRODUCT order by $preferredOrder$ </statement> In the above example the preferredOrder dynamic element will be replaced by the value of the preferredOrder property of the parameter object (just like a parameter map);. The difference is that this is a fundamental change to the SQL statement itself, which is much more serious than simply setting a parameter value. A mistake made in a Dynamic SQL Element can introduce security, performance and stability risks. Take care to do a lot of redundant checks to ensure that the simple dynamic SQL elements are being used appropriately. Also, be mindful of your design, as there is potential for database specifics to encroach on your business object model. For example, you may not want a column name intended for an order by clause to end up as a property in your business object, or as a field value on your JSP page. Simple dynamic elements can be included within <statements> and come in handy when there is a need to modify the SQL statement itself. For example: <statement id=”getProduct” resultMap=”get-product-result”> SELECT * FROM PRODUCT <dynamic prepend=”WHERE”> <isNotEmpty property=”description”> PRD_DESCRIPTION $operator$ #description# </isNotEmpty> </dynamic> </statement> 哪位牛牛帮忙简单的翻译翻译 E文实在是不行 看不太懂 |
|
返回顶楼 | |
发表时间:2006-01-17
啊啊 不用了不用了 已经看明白了
谢谢谢谢 |
|
返回顶楼 | |
发表时间:2006-12-15
知道了,其中$operator$ 对应参数类的一个属性.是这样的吧?
|
|
返回顶楼 | |
发表时间:2006-12-15
$operator$ #operator#都会从传入参数(基本类型、类、Map)中获取值。但是#operator#会作为生成的perparestatement中的一个占位符。
|
|
返回顶楼 | |