当前位置: 移动技术网 > IT编程>开发语言>Java > Mybatis RowBounds 限制查询条数的实现代码

Mybatis RowBounds 限制查询条数的实现代码

2019年07月22日  | 移动技术网IT编程  | 我要评论

oracle 数据库,查询增加rowbounds限制查询条数,默认是0到1000条

private final static int rowlimit = 1000; 
//限制查询条数 
private final static rowbounds query_limit=new rowbounds(0,rowlimit); 
public list<t> select(string sqlid, t t) throws dbexception, 
recordnotfoundexception { 
list<t> ret; 
try { 
if ("".equals(sqlid) || (null == sqlid)) { 
ret = getsqlsession().selectlist(t.getmappername() + select, t,query_limit); 
} else { 
ret = getsqlsession().selectlist(t.getmappername() + mapper + sqlid, 
t,query_limit); 
} 
} catch (exception e) { 
logger.error(e.getmessage(), e); 
logger.debug(t.tostring()); 
throw new dbexception(e); 
} 
if (ret == null && checknull) { 
throw new recordnotfoundexception(t.gettablename()); 
} 
return ret; 
}

以上所述是小编给大家介绍的mybatis rowbounds 限制查询条数的实现代码,希望对大家有所帮助

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网