ibatis多条件查询
我想分页,怎么查出查询结果的记录数,怎么补充,求高手指导,谢谢多条件查询语句,该怎么补充<selectid="queryOrgans"resultClass="organ...
我想分页,怎么查出 查询结果 的记录数,怎么补充,求高手指导,谢谢
多条件查询语句,该怎么补充
<select id="queryOrgans" resultClass="organ" parameterClass="organ">
select * from (select a.*, rownum row_num from (
select * from organ
<dynamic prepend=" where ">
<isNotEmpty prepend=" and " property="orgName">orgName Like '%$orgName$%'</isNotEmpty>
<isNotEmpty prepend=" and " property="orgLevel">orgLevel=#orgLevel#</isNotEmpty>
<isNotEmpty prepend=" and " property="orgType">orgType=#orgType#</isNotEmpty>
<isNotEmpty prepend=" and " property="orgState">orgState=#orgState#</isNotEmpty>
</dynamic>
order by orgId asc) a
where #end#>rownum) b where b.row_num>=#start#
</select> 展开
多条件查询语句,该怎么补充
<select id="queryOrgans" resultClass="organ" parameterClass="organ">
select * from (select a.*, rownum row_num from (
select * from organ
<dynamic prepend=" where ">
<isNotEmpty prepend=" and " property="orgName">orgName Like '%$orgName$%'</isNotEmpty>
<isNotEmpty prepend=" and " property="orgLevel">orgLevel=#orgLevel#</isNotEmpty>
<isNotEmpty prepend=" and " property="orgType">orgType=#orgType#</isNotEmpty>
<isNotEmpty prepend=" and " property="orgState">orgState=#orgState#</isNotEmpty>
</dynamic>
order by orgId asc) a
where #end#>rownum) b where b.row_num>=#start#
</select> 展开
展开全部
ibatis 有自带分页功能方法:getSqlMapClientTemplate().queryForList(statementName, skipResults, maxResults);
和
getSqlMapClientTemplate().queryForList(statementName, parameterObject, skipResults, maxResults);
只需要传入相关参数即可。SQL和查询全部一样,ibatis会自动根据你所传参数过滤并返回结果。
这样避免写嵌套SQL,XML文件完整如下:
<select id="queryOrgans" resultClass="organ" parameterClass="organ">
select * from organ
<dynamic prepend=" where ">
<isNotEmpty prepend=" and " property="orgName">orgName Like '%$orgName$%'</isNotEmpty>
<isNotEmpty prepend=" and " property="orgLevel">orgLevel=#orgLevel#</isNotEmpty>
<isNotEmpty prepend=" and " property="orgType">orgType=#orgType#</isNotEmpty>
<isNotEmpty prepend=" and " property="orgState">orgState=#orgState#</isNotEmpty>
</dynamic>
order by orgId asc
</select>
和
getSqlMapClientTemplate().queryForList(statementName, parameterObject, skipResults, maxResults);
只需要传入相关参数即可。SQL和查询全部一样,ibatis会自动根据你所传参数过滤并返回结果。
这样避免写嵌套SQL,XML文件完整如下:
<select id="queryOrgans" resultClass="organ" parameterClass="organ">
select * from organ
<dynamic prepend=" where ">
<isNotEmpty prepend=" and " property="orgName">orgName Like '%$orgName$%'</isNotEmpty>
<isNotEmpty prepend=" and " property="orgLevel">orgLevel=#orgLevel#</isNotEmpty>
<isNotEmpty prepend=" and " property="orgType">orgType=#orgType#</isNotEmpty>
<isNotEmpty prepend=" and " property="orgState">orgState=#orgState#</isNotEmpty>
</dynamic>
order by orgId asc
</select>
考试派丨美洽教育
2024-05-28 广告
2024-05-28 广告
作为世界经济的发动机,中国对于国际化的会计师是供不应求的。为了帮助中国培养更多的国际化的会计师团体,国际会计师公会AIA本着对CICPA专业考试的认可和尊重,为取得CICPA并且工作满三年的学员专门设计三门课程(其中一门免考),通过考试后即...
点击进入详情页
本回答由考试派丨美洽教育提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询