ResultSet
The JDBC module uses the IResultSet interface to encapsulate the result sets of data queries and integrates paging parameters. The following code introduces how to use the IResultSet object:
IResultSet<User> _results = JDBC.get().openSession(new ISessionExecutor<IResultSet<User>>() { public IResultSet<User> execute(ISession session) throws Exception { return session.find(EntitySQL.create(User.class), Page.create(1).pageSize(10)); } }); // 返回当前是否分页查询 boolean _isPaginated = _results.isPaginated(); // 当前结果集是否可用,即是否为空或元素数量为0 boolean _isAvailable = _results.isResultsAvailable(); // 返回当前页号 int _pNumber = _results.getPageNumber(); // 返回每页记录数 int _pSize = _results.getPageSize(); // 返回总页数 int _pCount = _results.getPageCount(); // 返回总记录数 long _rCount = _results.getRecordCount(); // 返回结果集数据 List<User> _users = _results.getResultData();
Note:
- Page paging parameters will affect whether the return value of the total number of pages and total number of records is 0;
When Page.create(1).pageSize(10).count(false) is executed, the count calculation of the total number of records will not be performed;
- Non-page query The paging parameter values returned when are all 0;