ibatis mysql转换成Oracle,执行语句中# #好像不生效,不能正确选择出数据(很急)
ibatis 中的Oracle语句中# #好像不生效,不能正确选择出数据(很急)
我原来用的是mysql+ibatis ,最近换成:oracle+ ibatis,原来是可以使用的,但是换成了oracle后,感觉##不正确,不能选择出正确的数据:
resultMap是:
Java code
<resultMap class="menu" id="menuResult"> <result column="MENUID" property="menuId" /> <result column="MENUNAME" property="menuName" /> <result column="TYPE" property="type" /> <result column="ACTIONID" property="action" select="menu.getActionById" /> <result column="PARENTID" property="parentId" /> <result column="SORTORDER" property="sortOrder" /> <result column="REMARK" property="remark" /> </resultMap>
Java code
<select id="getMenu" resultMap="menuResult"> select * from sys_menu <dynamic prepend="where"> <isNotEmpty property="menu.menuId" prepend="and"> menuId=#menu.menuId# </isNotEmpty> <isNotEmpty property="menu.parentId" prepend="and"> parentId=#menu.parentId# </isNotEmpty> <isNotEmpty property="roleList" prepend="and"> exists (select id from sys_rolemenu where sys_rolemenu.menuid=sys_menu.menuid <iterate property="roleList" prepend="and" open="(" close=")" conjunction="or"> roleid=#roleList[].roleId# </iterate> ) </isNotEmpty> </dynamic> order by sortOrder </select>
执行过程:
DEBUG - Getting transaction for [net.sansheng.scm.system.service.MenuManageService.getMenuTree]
DEBUG - {conn-100033} Connection
DEBUG - {conn-100033} Preparing Statement: select * from sys_menu where parentId=? order by sortOrder
DEBUG - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@8ca0d9] for key [org.apache.commons.dbcp.BasicDataSource@abc00] bound to thread [http-8080-2]
DEBUG - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@8ca0d9] for key [org.apache.commons.dbcp.BasicDataSource@abc00] bound to thread [http-8080-2]
DEBUG - {pstm-100034} Executing Statement: select * from sys_menu where parentId=? order by sortOrder
DEBUG - {pstm-100034} Parameters: [TREEROOT]
DEBUG - {pstm-100034} Types: [java.lang.String]
DEBUG - {rset-100035} ResultSet
可以看出是出入了参数的[TREEROOT] 的,但是选择不出结果:
在oracle中:
select * from sys_menu where parentId='TREEROOT' 是可以选择出数据的;
感觉传递给oracle中,没有将TREEROOT 这个参数增加单引号的感觉,请教大师??急!!!
自己测试了一下,直接写条件是可以的:
DEBUG - {conn-100036} Preparing Statement: select * from sys_menu where parentId=? order by sortOrder
DEBUG - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@49c5cd] for key [org.apache.commons.dbcp.BasicDataSource@16a0676] bound to thread [http-8080-6]
DEBUG - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@49c5cd] for key [org.apache.commons.dbcp.BasicDataSource@16a0676] bound to th