首页 > 代码库 > ibatis的result标签中用select详解
ibatis的result标签中用select详解
标签:详解 ibatis的result标签中用select
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://zorro.blog.51cto.com/2139862/821777
<resultMap id="usermoduleprivilege"
class="com.webex.webapp.l10n.common.pojo.UserModulePrivilege">
<result property="projectId" column="projectid" nullValue="" />
<result property="userId" column="userid" nullValue="0" />
<result property="userName" column="username" nullValue="" />
<result property="firstName" column="firstname" nullValue="" />
<result property="lastName" column="lastname" nullValue="" />
<result property="modulePrivilege"
column="{userId=userid, projectId=projectid}"
select="findassignedusermoduleprivilege" />
</resultMap>
class="com.webex.webapp.l10n.common.pojo.UserModulePrivilege">
<result property="projectId" column="projectid" nullValue="" />
<result property="userId" column="userid" nullValue="0" />
<result property="userName" column="username" nullValue="" />
<result property="firstName" column="firstname" nullValue="" />
<result property="lastName" column="lastname" nullValue="" />
<result property="modulePrivilege"
column="{userId=userid, projectId=projectid}"
select="findassignedusermoduleprivilege" />
</resultMap>
<select id="findassignedusermoduleprivilege"
resultMap="moduleprivilege" cacheModel="Project-cache">
select t.projectid,m.moduleid,m.modulename,t.status,t.privilege from
wbxl10nprojectprivilege t,wbxl10nmodule m where
t.moduleid=m.moduleid and t.userid=#userId# and
t.projectid=#projectId#
</select>
resultMap="moduleprivilege" cacheModel="Project-cache">
select t.projectid,m.moduleid,m.modulename,t.status,t.privilege from
wbxl10nprojectprivilege t,wbxl10nmodule m where
t.moduleid=m.moduleid and t.userid=#userId# and
t.projectid=#projectId#
</select>
<select id="findassigneduserprivilege"
resultMap="usermoduleprivilege">
select
distinct(u.userid),p.projectid,u.username,u.firstName,u.lastName
from wbxl10nproject p ,wbxl10nprojectprivilege t,wbxl10nuser u
where t.userid=u.userid and t.projectid=p.projectid and
t.projectid=#projectId#
</select>
resultMap="usermoduleprivilege">
select
distinct(u.userid),p.projectid,u.username,u.firstName,u.lastName
from wbxl10nproject p ,wbxl10nprojectprivilege t,wbxl10nuser u
where t.userid=u.userid and t.projectid=p.projectid and
t.projectid=#projectId#
</select>
column="{userId=userid, projectId=projectid}"
select="findassignedusermoduleprivilege" /> 将column指定的一项或多项作为参数(userId=userid, projectId=projectid),传入并执行指定的select语句(findassignedusermoduleprivilege),并将查询结果赋给property="modulePrivilege"
本文出自 “左罗CTO” 博客,请务必保留此出处http://zorro.blog.51cto.com/2139862/821777
ibatis的result标签中用select详解
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。