mybatis 3张表查询,为什么查询出了值但获取时却为空
1个回答
展开全部
apper namespace="com.hwsensor.framework.dao.IRolePermissionDao">
<!-- 联合permission,role,per-role的查询 -->
<resultMap id="detailedPerRoleResultMap" type="RolePerPO">
<id property="id" column="ID" />
<result property="roleId" column="ROLE_ID" />
<result property="permId" column="PERM_ID" />
<result property="action" column="ACTION" />
<result property="available" column="AVAILABLE" />
<association property="permId" column="perm_id" javaType="PermissionPO">
<id property="id" column="ID" />
<result property="parentId" column="PARENTID" />
<result property="name" column="NAME" />
<result property="url" column="URL" />
<result property="image" column="IMAGE" />
<result property="available" column="AVAILABLE" />
<result property="admin" column="ADMIN" />
<result property="orderNum" column="ORDERNUM" />
<result property="description" column="DESCRIPTION" />
</association>
<collection property="roleId" ofType="RolePO">
<id property="id" column="ID" />
<result property="parentId" column="PARENTID" />
<result property="name" column="NAME" />
<result property="description" column="DESCRIPTION" />
</collection>
</resultMap>
<!-- 根据permission的id查询三张表 -->
<select id="retrievePerRoleDetails" parameterType="java.lang.String" resultMap="detailedPerRoleResultMap">
SELECT
RP.ID RPID,
RP.ROLE_ID RPROLEID,
RP.PERM_ID RPPERID,
RP.ACTION RPACTION,
RP.AVAILABLE RPAVAILABLE,
PER.ID PERID,
PER.PARENTID PERPARENTID,
PER.NAME PERNAME,
PER.URL PERURL,
PER.IMAGE PERIMAGE,
PER.AVAILABLE PERAVAILABLE,
PER.ADMIN PERADMIN,
PER.ORDERNUM PERORDERNUM,
PER.DESCRIPTION PERDESCRIPTION,
ROLE.ID ROLEID,
ROLE.NAME ROLENAME,
ROLE.DESCRIPTION ROLEDESCRIPTION
FROM SYS_ROLE_PERM RP,
SYS_PERMISSION PER,
SYS_ROLE ROLE
WHERE RP.ROLE_ID = ROLE.ID
AND RP.PERM_ID = PER.ID
AND RP.PERM_ID = #{permId}
</mapper>
在action中获得的对象的List<RolePermPO>为空,但是它的长度存在,在控制端也打印出了查询出的数据,就是获取的List<RolePermPO>为空?为什么啊?
这个是action代码:
rolePerList = new ArrayList<RolePermPO>();
rolePerList = rolePermissionService.retrievePerRoleDetails(rolePerPO.getPermId());
System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@:"+rolePerList.size());
for(RolePermPO rolePer:rolePerList){
System.out.println("---跳转功能角色权限编辑页面----:"+rolePer);
}
控制台打印:
16:37:40,214 DEBUG [java.sql.Connection] ==> Preparing: SELECT RP.ID AS RPID, RP.ROLE_ID AS RPROLEID, RP.PERM_ID AS RPPERID, RP.ACTION AS RPACTION, RP.AVAILABLE AS RPAVAILABLE, PER.ID AS PERID, PER.PARENTID AS PERPARENTID, PER.NAME AS PERNAME, PER.URL AS PERURL, PER.IMAGE AS PERIMAGE, PER.AVAILABLE AS PERAVAILABLE, PER.ADMIN AS PERADMIN, PER.ORDERNUM AS PERORDERNUM, PER.DESCRIPTION AS PERDESCRIPTION, ROLE.ID AS ROLEID, ROLE.NAME AS ROLENAME, ROLE.DESCRIPTION AS ROLEDESCRIPTION FROM SYS_ROLE_PERM RP, SYS_PERMISSION PER, SYS_ROLE ROLE WHERE RP.ROLE_ID = ROLE.ID AND RP.PERM_ID = PER.ID AND RP.PERM_ID = ?
16:37:40,393 DEBUG [java.sql.PreparedStatement] ==> Parameters: 491de6bd-5607-4c47-a8d9-67f1b5ad051d(String)
16:37:40,564 DEBUG [java.sql.ResultSet] <== Columns: RPID, RPROLEID, RPPERID, RPACTION, RPAVAILABLE, PERID, PERPARENTID, PERNAME, PERURL, PERIMAGE, PERAVAILABLE, PERADMIN, PERORDERNUM, PERDESCRIPTION, ROLEID, ROLENAME, ROLEDESCRIPTION
16:37:40,572 DEBUG [java.sql.ResultSet] <== Row: 2aac29dd-a9b1-4a5d-9466-443b9ba59854, 987a74d1-0225-4fc0-98af-7e648b37da1e, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 00000, 0, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 系统设置模块, pp, null, 0, 1, 0, null, 987a74d1-0225-4fc0-98af-7e648b37da1e, a角色, a角色描述
16:37:40,573 DEBUG [java.sql.ResultSet] <== Row: d875209d-5425-477d-a0b8-762d2252fe3f, f0c6046f-53d2-452f-a04d-c4ece35eabcc, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 10100, 0, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 系统设置模块, pp, null, 0, 1, 0, null, f0c6046f-53d2-452f-a04d-c4ece35eabcc, mmmm1, mmmmm
16:37:40,574 DEBUG [java.sql.ResultSet] <== Row: 62dfecae-9599-4bff-959e-43a496e5b61c, f7f50c6c-617f-4c18-851d-10bae545ff02, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 01010, 1, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 系统设置模块, pp, null, 0, 1, 0, null, f7f50c6c-617f-4c18-851d-10bae545ff02, test, test desc
16:37:40,574 DEBUG [java.sql.ResultSet] <== Row: f766f0ea-0cfd-4173-a363-81ce6068b5ed, d0a04544-6d82-4393-9266-ab39834bd2e8, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 01010, 1, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 系统设置模块, pp, null, 0, 1, 0, null, d0a04544-6d82-4393-9266-ab39834bd2e8, hello2334, nihao24
16:37:40,574 DEBUG [java.sql.ResultSet] <== Row: 426aea2f-5ae2-4ff3-a1ba-a1d8e2033808, 9d94020c-231a-4429-807a-3248b0be9e7b, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 01010, 1, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 系统设置模块, pp, null, 0, 1, 0, null, 9d94020c-231a-4429-807a-3248b0be9e7b, 管理员00, 管理员描述00
16:37:40,574 DEBUG [java.sql.ResultSet] <== Row: 18d0bb3a-ce33-4217-9bbe-621839c3e939, e73fe575-7542-416b-9ef1-e5c0e98ed48c, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 00000, 0, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 系统设置模块, pp, null, 0, 1, 0, null, e73fe575-7542-416b-9ef1-e5c0e98ed48c, 测试角色1, 测试角色1-sjl
16:37:40,575 DEBUG [java.sql.ResultSet] <== Row: 28962107-7b63-4054-bf95-d2835d94e9ff, 464ae26c-16dd-4758-9dce-29489ceb4607, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 10100, 0, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 系统设置模块, pp, null, 0, 1, 0, null, 464ae26c-16dd-4758-9dce-29489ceb4607, 测试角色2, --------------
16:37:40,575 DEBUG [java.sql.ResultSet] <== Row: 2f7cefdd-6a10-4826-a67b-e4a78294600f, f0b2c1ad-93ad-47d2-8a9c-b79b7c82afa6, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 01null01, 0, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 系统设置模块, pp, null, 0, 1, 0, null, f0b2c1ad-93ad-47d2-8a9c-b79b7c82afa6, 角色名称2, 描述
16:37:40,575 DEBUG [java.sql.ResultSet] <== Row: 0c8a1442-181b-48c6-a3a5-c61c1b024ccb, 89ea0332-1941-474e-8a7e-fb96e4378b63, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 10100, 0, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 系统设置模块, pp, null, 0, 1, 0, null, 89ea0332-1941-474e-8a7e-fb96e4378b63, 系统管理员, 系统管理员的描述
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@:9
---跳转功能角色权限编辑页面----:null
---跳转功能角色权限编辑页面----:null
---跳转功能角色权限编辑页面----:null
---跳转功能角色权限编辑页面----:null
---跳转功能角色权限编辑页面----:null
---跳转功能角色权限编辑页面----:null
---跳转功能角色权限编辑页面----:null
---跳转功能角色权限编辑页面----:null
---跳转功能角色权限编辑页面----:null
Java企业应用StrutsiBATISMyBatis
2012年5月21日 16:41
zc0725
21
0 0 1
添加评论
关注(0)
查看图片附件
1个答案按时间排序按投票排序
00
sql语句中查询出每列的别名 写成 小写
2012年6月01日 23:15
cfyme
14
0 0 3
添加评论
0 待解决问题
26168 已解决问题
95983 热门问题
我的问答FAQ | 勋章
已解决问题
使用Mybatis执行sql时如何统一校验输入参数?
js里这种表述式是啥意思?return (y1 - y2 > 0 ? "Up" : "Down");
请问基于云架构的J2EE架构应该怎么做?
spring ,hibernate 都是用到了asm字节码技术,请问它们具体都拿ASM来实现了什么功能?或者说在哪个功能上用到的
如何判断操作系统是32位还是64位?
DBA_OBJECTS + ROWNUM 和 DUAL + ROWNUM 一个结果比较
<!-- 联合permission,role,per-role的查询 -->
<resultMap id="detailedPerRoleResultMap" type="RolePerPO">
<id property="id" column="ID" />
<result property="roleId" column="ROLE_ID" />
<result property="permId" column="PERM_ID" />
<result property="action" column="ACTION" />
<result property="available" column="AVAILABLE" />
<association property="permId" column="perm_id" javaType="PermissionPO">
<id property="id" column="ID" />
<result property="parentId" column="PARENTID" />
<result property="name" column="NAME" />
<result property="url" column="URL" />
<result property="image" column="IMAGE" />
<result property="available" column="AVAILABLE" />
<result property="admin" column="ADMIN" />
<result property="orderNum" column="ORDERNUM" />
<result property="description" column="DESCRIPTION" />
</association>
<collection property="roleId" ofType="RolePO">
<id property="id" column="ID" />
<result property="parentId" column="PARENTID" />
<result property="name" column="NAME" />
<result property="description" column="DESCRIPTION" />
</collection>
</resultMap>
<!-- 根据permission的id查询三张表 -->
<select id="retrievePerRoleDetails" parameterType="java.lang.String" resultMap="detailedPerRoleResultMap">
SELECT
RP.ID RPID,
RP.ROLE_ID RPROLEID,
RP.PERM_ID RPPERID,
RP.ACTION RPACTION,
RP.AVAILABLE RPAVAILABLE,
PER.ID PERID,
PER.PARENTID PERPARENTID,
PER.NAME PERNAME,
PER.URL PERURL,
PER.IMAGE PERIMAGE,
PER.AVAILABLE PERAVAILABLE,
PER.ADMIN PERADMIN,
PER.ORDERNUM PERORDERNUM,
PER.DESCRIPTION PERDESCRIPTION,
ROLE.ID ROLEID,
ROLE.NAME ROLENAME,
ROLE.DESCRIPTION ROLEDESCRIPTION
FROM SYS_ROLE_PERM RP,
SYS_PERMISSION PER,
SYS_ROLE ROLE
WHERE RP.ROLE_ID = ROLE.ID
AND RP.PERM_ID = PER.ID
AND RP.PERM_ID = #{permId}
</mapper>
在action中获得的对象的List<RolePermPO>为空,但是它的长度存在,在控制端也打印出了查询出的数据,就是获取的List<RolePermPO>为空?为什么啊?
这个是action代码:
rolePerList = new ArrayList<RolePermPO>();
rolePerList = rolePermissionService.retrievePerRoleDetails(rolePerPO.getPermId());
System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@:"+rolePerList.size());
for(RolePermPO rolePer:rolePerList){
System.out.println("---跳转功能角色权限编辑页面----:"+rolePer);
}
控制台打印:
16:37:40,214 DEBUG [java.sql.Connection] ==> Preparing: SELECT RP.ID AS RPID, RP.ROLE_ID AS RPROLEID, RP.PERM_ID AS RPPERID, RP.ACTION AS RPACTION, RP.AVAILABLE AS RPAVAILABLE, PER.ID AS PERID, PER.PARENTID AS PERPARENTID, PER.NAME AS PERNAME, PER.URL AS PERURL, PER.IMAGE AS PERIMAGE, PER.AVAILABLE AS PERAVAILABLE, PER.ADMIN AS PERADMIN, PER.ORDERNUM AS PERORDERNUM, PER.DESCRIPTION AS PERDESCRIPTION, ROLE.ID AS ROLEID, ROLE.NAME AS ROLENAME, ROLE.DESCRIPTION AS ROLEDESCRIPTION FROM SYS_ROLE_PERM RP, SYS_PERMISSION PER, SYS_ROLE ROLE WHERE RP.ROLE_ID = ROLE.ID AND RP.PERM_ID = PER.ID AND RP.PERM_ID = ?
16:37:40,393 DEBUG [java.sql.PreparedStatement] ==> Parameters: 491de6bd-5607-4c47-a8d9-67f1b5ad051d(String)
16:37:40,564 DEBUG [java.sql.ResultSet] <== Columns: RPID, RPROLEID, RPPERID, RPACTION, RPAVAILABLE, PERID, PERPARENTID, PERNAME, PERURL, PERIMAGE, PERAVAILABLE, PERADMIN, PERORDERNUM, PERDESCRIPTION, ROLEID, ROLENAME, ROLEDESCRIPTION
16:37:40,572 DEBUG [java.sql.ResultSet] <== Row: 2aac29dd-a9b1-4a5d-9466-443b9ba59854, 987a74d1-0225-4fc0-98af-7e648b37da1e, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 00000, 0, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 系统设置模块, pp, null, 0, 1, 0, null, 987a74d1-0225-4fc0-98af-7e648b37da1e, a角色, a角色描述
16:37:40,573 DEBUG [java.sql.ResultSet] <== Row: d875209d-5425-477d-a0b8-762d2252fe3f, f0c6046f-53d2-452f-a04d-c4ece35eabcc, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 10100, 0, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 系统设置模块, pp, null, 0, 1, 0, null, f0c6046f-53d2-452f-a04d-c4ece35eabcc, mmmm1, mmmmm
16:37:40,574 DEBUG [java.sql.ResultSet] <== Row: 62dfecae-9599-4bff-959e-43a496e5b61c, f7f50c6c-617f-4c18-851d-10bae545ff02, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 01010, 1, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 系统设置模块, pp, null, 0, 1, 0, null, f7f50c6c-617f-4c18-851d-10bae545ff02, test, test desc
16:37:40,574 DEBUG [java.sql.ResultSet] <== Row: f766f0ea-0cfd-4173-a363-81ce6068b5ed, d0a04544-6d82-4393-9266-ab39834bd2e8, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 01010, 1, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 系统设置模块, pp, null, 0, 1, 0, null, d0a04544-6d82-4393-9266-ab39834bd2e8, hello2334, nihao24
16:37:40,574 DEBUG [java.sql.ResultSet] <== Row: 426aea2f-5ae2-4ff3-a1ba-a1d8e2033808, 9d94020c-231a-4429-807a-3248b0be9e7b, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 01010, 1, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 系统设置模块, pp, null, 0, 1, 0, null, 9d94020c-231a-4429-807a-3248b0be9e7b, 管理员00, 管理员描述00
16:37:40,574 DEBUG [java.sql.ResultSet] <== Row: 18d0bb3a-ce33-4217-9bbe-621839c3e939, e73fe575-7542-416b-9ef1-e5c0e98ed48c, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 00000, 0, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 系统设置模块, pp, null, 0, 1, 0, null, e73fe575-7542-416b-9ef1-e5c0e98ed48c, 测试角色1, 测试角色1-sjl
16:37:40,575 DEBUG [java.sql.ResultSet] <== Row: 28962107-7b63-4054-bf95-d2835d94e9ff, 464ae26c-16dd-4758-9dce-29489ceb4607, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 10100, 0, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 系统设置模块, pp, null, 0, 1, 0, null, 464ae26c-16dd-4758-9dce-29489ceb4607, 测试角色2, --------------
16:37:40,575 DEBUG [java.sql.ResultSet] <== Row: 2f7cefdd-6a10-4826-a67b-e4a78294600f, f0b2c1ad-93ad-47d2-8a9c-b79b7c82afa6, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 01null01, 0, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 系统设置模块, pp, null, 0, 1, 0, null, f0b2c1ad-93ad-47d2-8a9c-b79b7c82afa6, 角色名称2, 描述
16:37:40,575 DEBUG [java.sql.ResultSet] <== Row: 0c8a1442-181b-48c6-a3a5-c61c1b024ccb, 89ea0332-1941-474e-8a7e-fb96e4378b63, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 10100, 0, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 491de6bd-5607-4c47-a8d9-67f1b5ad051d, 系统设置模块, pp, null, 0, 1, 0, null, 89ea0332-1941-474e-8a7e-fb96e4378b63, 系统管理员, 系统管理员的描述
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@:9
---跳转功能角色权限编辑页面----:null
---跳转功能角色权限编辑页面----:null
---跳转功能角色权限编辑页面----:null
---跳转功能角色权限编辑页面----:null
---跳转功能角色权限编辑页面----:null
---跳转功能角色权限编辑页面----:null
---跳转功能角色权限编辑页面----:null
---跳转功能角色权限编辑页面----:null
---跳转功能角色权限编辑页面----:null
Java企业应用StrutsiBATISMyBatis
2012年5月21日 16:41
zc0725
21
0 0 1
添加评论
关注(0)
查看图片附件
1个答案按时间排序按投票排序
00
sql语句中查询出每列的别名 写成 小写
2012年6月01日 23:15
cfyme
14
0 0 3
添加评论
0 待解决问题
26168 已解决问题
95983 热门问题
我的问答FAQ | 勋章
已解决问题
使用Mybatis执行sql时如何统一校验输入参数?
js里这种表述式是啥意思?return (y1 - y2 > 0 ? "Up" : "Down");
请问基于云架构的J2EE架构应该怎么做?
spring ,hibernate 都是用到了asm字节码技术,请问它们具体都拿ASM来实现了什么功能?或者说在哪个功能上用到的
如何判断操作系统是32位还是64位?
DBA_OBJECTS + ROWNUM 和 DUAL + ROWNUM 一个结果比较
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询