首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

IBatis3.0 中1点典型特性

2012-10-25 
IBatis3.0 中一点典型特性keyPropertyblogid insert into Blog(author,subject,content, publishTime

IBatis3.0 中一点典型特性
keyProperty="blogid" >
insert into Blog(author,subject,content, publishTime,blogid)
values(#{author}#,#{subject}#,#{content}#,#{publishTime}#,#{blogid})
</insert> <selectKey keyProperty="blogid" resultType="int" order="BEFORE">
select seq_order.nextval() from dual
</selectKey>
insert into Blog(author,subject,content, publishTime,blogid)
values(#{author}#,#{subject}#,#{content}#,#{publishTime}#,#{blogid})
</insert>

<!--
多表查询的使用
-->
<select id="selectBlogDetails" parameterType="int" resultMap="blogResultMap" >
select
B.id as blogid,
A.author as author
from Blog B
left outer join Author A
on B.author_id=A.id
where B.id=#{id}
</select>

<!--select * from Blog
where state='ACTIVE'
<if test="title!=null">
and title like #{title}
</if>
<if test="author!=null and author.name!=null">
and title like #{author.name}
</if>
</select>


<select id="findActionBlogLike" parameterType="Blog" resultType="Blog">
select * from Blog where state='ACTIVE'
<choose>
<when test="title!=null">
and title like #{title }
</when>
<when test="author!=null and author.name!=null">
and title like #{author.name}
</when>
<otherwise>
and featured=1
</otherwise>
</choose>
</select>

?


可以指定生成主键是个不错的特性,IBatis2.x 无法标识Entity主键的确是个设计遗憾。


可以指定生成主键是个不错的特性,IBatis2.x 无法标识Entity主键的确是个设计遗憾。



ibatis本来就是一个sql mapping,并不要求一定要有主键的,设计的目的就是处理任何的sql,执行什么sql他就不关心的 4 楼 zhangygood 2010-02-24   好东西,学习一下

热点排行