ibatis中#和$有什么区别?

ouyka 2006-11-15 02:36:49
#和$有什么区别,即select * from topic where id=#id#和select * from topic where id=$id$有区别吗?

还有我要执行这个语句select * from topic where boardid in (1,2,3),配置文件如下:

这样写会报错:
<select id="getLists" resultMap="topicListResult" parameterClass="topicInfo">
select * from topic
<dynamic prepend="where">
<isNotNull prepend="and" property="boardid">
boardid in (#boardid#)
</isNotNull>
</dynamic>
</select>

这样写就没事,即用$替换#
<select id="getLists" resultMap="topicListResult" parameterClass="topicInfo">
select * from topic
<dynamic prepend="where">
<isNotNull prepend="and" property="boardid">
boardid in ($boardid$)
</isNotNull>
</dynamic>
</select>

这是为什么?
...全文
678 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
baron_yb 2006-12-06
  • 打赏
  • 举报
回复
<select id="users" resultMap="user">select * from a $name$</select>好像不行吧,
应该这样得
<select id="users" resultMap="user">select * from a ‘$name$'</select>
huhuan107 2006-11-30
  • 打赏
  • 举报
回复
看来这个问题可以结贴了 ~~~
youfly 2006-11-29
  • 打赏
  • 举报
回复
#表示参数的方式传入类似于sql语句里的?,$就是简单的字符串替换,用相应的值替换$$里的内容。
huhuan107 2006-11-27
  • 打赏
  • 举报
回复
十八哥 把你说的 举个例子被~~
ouyka 2006-11-21
  • 打赏
  • 举报
回复
感谢楼上的两位兄弟
ilovemilk 2006-11-21
  • 打赏
  • 举报
回复
用$$ 有点宏替换的意思,如下列映射:
<select id="users" resultMap="user">select * from a $name$</select>,则在传入参数可以queryForList("users", "where name='张三'");
用##则是预编译处理,传入的是什么类型就是什么类型,如下列映射:
<select id="users" resultMap="user">select * from a where a.name=#name#</select>,
你在传入参数时可以queryForList("users", "张三");则生成的sql语句是select * from a where a.name='张三'。
sbgphl 2006-11-21
  • 打赏
  • 举报
回复
用$$ 在控制台打印一条完整的sql
用##则是?,预编译处理
huhuan107 2006-11-21
  • 打赏
  • 举报
回复
多么好的一个问题啊 怎么没人回答呢 等待学习中
micro1984 2006-11-16
  • 打赏
  • 举报
回复
好像$$之间可以直接接收一个String
GODProbe 2006-11-16
  • 打赏
  • 举报
回复
micro1984 2006-11-16
  • 打赏
  • 举报
回复
只用过##的
那种的还真用过
我也记一下
huhuan107 2006-11-16
  • 打赏
  • 举报
回复
做个记号 还真没碰过这种情况

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧