Пример #1
0
 public List getPartySelectPage(
     String stype, String sdesc, String sname, String saddress, int nPage) {
   try {
     String sQuery;
     getSession();
     stype = stype.trim();
     if (stype.equals("")) {
       sQuery =
           "select p from Party p left outer join p.partyRoles r where r.roleTypeId = ? and (?='' or p.description like ?) and (?='' or link_man like ?) and (?='' or address like ?)";
     } else {
       sQuery =
           "select p from Party p left outer join p.partyRoles r where r.roleTypeId <> ? and (?='' or p.description like ?) and (?='' or link_man like ?) and (?='' or address like ?)";
     }
     Query rs = session.createQuery(sQuery);
     rs.setString(0, PartyKeys.CUSTOMER_ROLE_KEY);
     rs.setString(1, sdesc);
     rs.setString(2, "%" + sdesc + "%");
     rs.setString(3, sname);
     rs.setString(4, "%" + sname + "%");
     rs.setString(5, saddress);
     rs.setString(6, "%" + saddress + "%");
     rs.setFirstResult((nPage) * QueryListKeys.QUERY_IN_EACH_PAGE);
     rs.setMaxResults(QueryListKeys.QUERY_IN_EACH_PAGE);
     return rs.list();
   } catch (HibernateException e) {
     return null;
   } finally {
     closeSession();
   }
 }
Пример #2
0
  public List getPartyUser(String stype, String spartyname, String susername, int nPage)
      throws HibernateException {
    try {
      String sQuery;
      stype = stype.trim();
      if (stype.equals("")) {
        sQuery =
            "select u from UserLogin u,Party p left outer join p.partyRoles r where  u.enable='y' and p.partyId=u.party and r.roleTypeId = ? and (?='' or p.description like ?) and (?='' or u.name like ?)";
      } else {
        sQuery =
            "select u from UserLogin u,Party p left outer join p.partyRoles r where  u.enable='y' and p.partyId=u.party and r.roleTypeId <> ? and (?='' or p.description like ?) and (?='' or u.name like ?)";
      }
      getSession();
      Query rs = session.createQuery(sQuery);
      rs.setString(0, PartyKeys.CUSTOMER_ROLE_KEY);
      rs.setString(1, spartyname);
      rs.setString(2, "%" + spartyname + "%");
      rs.setString(3, susername);
      rs.setString(4, "%" + susername + "%");
      rs.setFirstResult((nPage) * QueryListKeys.QUERY_IN_EACH_PAGE);
      rs.setMaxResults(QueryListKeys.QUERY_IN_EACH_PAGE);
      return rs.list();

    } finally {
      closeSession();
    }
  }
Пример #3
0
  /**
   * Query by query sentence
   *
   * @param sql String Sql sentence
   * @param firstResult int First result
   * @param maxResult int Last result
   * @return List Return query results
   */
  public List listByCriteria(String sql, int firstResult, int maxResult) {

    Session session;
    List results = null;
    HbConn hbconn = new HbConn();
    try {
      session = hbconn.getSession();
      Query qry = session.createQuery(sql);
      if (maxResult > 0) {
        qry.setFirstResult(firstResult);
        qry.setMaxResults(maxResult);
      }
      qry.setCacheable(false);
      results = qry.list();
    } catch (Exception e) {
      // modified by xt	System.out.println("Exception)");
    } finally {
      try {
        hbconn.closeSession();
      } catch (Exception e2) {
        // modified by xt	System.out.println("Exception closing session)");
      }
      return results;
    }
  }
Пример #4
0
  public List getPartyUserPage(String spartyid, int nPage) {
    try {
      String sQuery = "select ul from UserLogin as ul where  ul.enable='y' and ul.party=?";
      getSession();
      Query rs = session.createQuery(sQuery);
      rs.setString(0, spartyid);
      rs.setFirstResult((nPage) * QueryListKeys.QUERY_IN_EACH_PAGE);
      rs.setMaxResults(QueryListKeys.QUERY_IN_EACH_PAGE);
      return rs.list();

    } catch (HibernateException e) {
      return null;
    } finally {
      closeSession();
    }
  }