Package com.jfinal.plugin.activerecord

Examples of com.jfinal.plugin.activerecord.Page


      if (size == 1)
        totalRow = ((Number)result.get(0)).longValue();    // totalRow = (Long)result.get(0);
      else if (size > 1)
        totalRow = result.size();
      else
        return new Page(new ArrayList(0), pageNumber, pageSize, 0, 0)// totalRow = 0;
     
      totalPage = (int) (totalRow / pageSize);
      if (totalRow % pageSize != 0) {
        totalPage++;
      }
     
      // --------
      StringBuilder sql = new StringBuilder();
      sql.append(select).append(" ").append(sqlExceptSelect);
      PreparedStatement pst = conn.prepareStatement(sql.toString(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
      for (int i=0; i<paras.length; i++) {
        pst.setObject(i + 1, paras[i]);
      }
      ResultSet rs = pst.executeQuery();
     
      // move the cursor to the start
      int offset = pageSize * (pageNumber - 1);
      for (int i=0; i<offset; i++)
        if (!rs.next())
          break;
     
      List list = buildModel(rs, modelClass, pageSize);
      if (rs != null) rs.close();
      if (pst != null) pst.close();
      return new Page(list, pageNumber, pageSize, totalPage, (int)totalRow);
    } catch (Exception e) {
      throw new ActiveRecordException(e);
    } finally {
      DbKit.close(conn);
    }
View Full Code Here


    if (size == 1)
      totalRow = ((Number)result.get(0)).longValue();    // totalRow = (Long)result.get(0);
    else if (size > 1)
      totalRow = result.size();
    else
      return new Page(new ArrayList(0), pageNumber, pageSize, 0, 0)// totalRow = 0;
   
    totalPage = (int) (totalRow / pageSize);
    if (totalRow % pageSize != 0) {
      totalPage++;
    }
   
    // --------
    StringBuilder sql = new StringBuilder();
    sql.append(select).append(" ").append(sqlExceptSelect);
    PreparedStatement pst = conn.prepareStatement(sql.toString(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
    for (int i=0; i<paras.length; i++) {
      pst.setObject(i + 1, paras[i]);
    }
    ResultSet rs = pst.executeQuery();
   
    // move the cursor to the start
    int offset = pageSize * (pageNumber - 1);
    for (int i=0; i<offset; i++)
      if (!rs.next())
        break;
   
    List list = buildModel(rs, modelClass, pageSize);
    if (rs != null) rs.close();
    if (pst != null) pst.close();
    return new Page(list, pageNumber, pageSize, totalPage, (int)totalRow);
  }
View Full Code Here

        config();
        Controller controller;
        controller = ai.getController();
        PageInfo pageInfo = PageInfoKit.injectPageInfo(model, controller,relations);
        extendsPageInfo(pageInfo);
        Page page = PageInfoKit.populate(pageInfo, this);
        controller.setAttr("pageInfo", pageInfo);
        controller.setAttr("page", page);
        ai.invoke();
    }
View Full Code Here

    if (size == 1)
      totalRow = ((Number)result.get(0)).longValue();    // totalRow = (Long)result.get(0);
    else if (size > 1)
      totalRow = result.size();
    else
      return new Page(new ArrayList(0), pageNumber, pageSize, 0, 0)// totalRow = 0;
   
    totalPage = (int) (totalRow / pageSize);
    if (totalRow % pageSize != 0) {
      totalPage++;
    }
   
    // --------
    StringBuilder sql = new StringBuilder();
    sql.append(select).append(" ").append(sqlExceptSelect);
    PreparedStatement pst = conn.prepareStatement(sql.toString(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
    for (int i=0; i<paras.length; i++) {
      pst.setObject(i + 1, paras[i]);
    }
    ResultSet rs = pst.executeQuery();
   
    // move the cursor to the start
    int offset = pageSize * (pageNumber - 1);
    for (int i=0; i<offset; i++)
      if (!rs.next())
        break;
   
    List list = buildModel(rs, modelClass, pageSize);
    if (rs != null) rs.close();
    if (pst != null) pst.close();
    return new Page(list, pageNumber, pageSize, totalPage, (int)totalRow);
  }
View Full Code Here

      if (size == 1)
        totalRow = ((Number)result.get(0)).longValue();    // totalRow = (Long)result.get(0);
      else if (size > 1)
        totalRow = result.size();
      else
        return new Page(new ArrayList(0), pageNumber, pageSize, 0, 0)// totalRow = 0;
     
      totalPage = (int) (totalRow / pageSize);
      if (totalRow % pageSize != 0) {
        totalPage++;
      }
     
      // --------
      StringBuilder sql = new StringBuilder();
      sql.append(select).append(" ").append(sqlExceptSelect);
      PreparedStatement pst = conn.prepareStatement(sql.toString(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
      for (int i=0; i<paras.length; i++) {
        pst.setObject(i + 1, paras[i]);
      }
      ResultSet rs = pst.executeQuery();
     
      // move the cursor to the start
      int offset = pageSize * (pageNumber - 1);
      for (int i=0; i<offset; i++)
        if (!rs.next())
          break;
     
      List list = buildModel(rs, modelClass, pageSize);
      if (rs != null) rs.close();
      if (pst != null) pst.close();
      return new Page(list, pageNumber, pageSize, totalPage, (int)totalRow);
    } catch (Exception e) {
      throw new ActiveRecordException(e);
    } finally {
      DbKit.close(conn);
    }
View Full Code Here

TOP

Related Classes of com.jfinal.plugin.activerecord.Page

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.