Package org.hibernate

Examples of org.hibernate.Query


    }
    hql.append("?)");
    Session ssn = getSession();
    try{
      beginTransaction();
      Query q = ssn.createQuery(hql.toString());
      q.setInteger(0, ownerId);
      int i=0;
      for(;i<friendIds.length;i++){
        String s_id = (String)friendIds[i];
        int id = -1;
        try{
          id = Integer.parseInt(s_id);
        }catch(Exception e){}
        q.setInteger(i+1, id);
      }
      q.setInteger(i+1, -1);
      int er = q.executeUpdate();
      commit();
      return er;
    }catch(HibernateException e){
      rollback();
      throw e;
View Full Code Here


    }
    hql.append("?)");
    Session ssn = getSession();
    try{
      beginTransaction();
      Query q = ssn.createQuery(hql.toString());
      q.setInteger(0, ownerId);
      int i=0;
      for(;i<otherIds.length;i++){
        String s_id = (String)otherIds[i];
        int id = -1;
        try{
          id = Integer.parseInt(s_id);
        }catch(Exception e){}
        q.setInteger(i+1, id);
      }
      q.setInteger(i+1, -1);
      int er = q.executeUpdate();
      commit();
      return er;
    }catch(HibernateException e){
      rollback();
      throw e;
View Full Code Here

    Session ssn = getSession();
    if(ssn == null)
      return -1;
    try{
      beginTransaction();
      Query q = ssn.getNamedQuery(manual_logout?"USER_LOGOUT_1":"USER_LOGOUT_2");
      q.setInteger("online_status", UserBean.STATUS_OFFLINE);
      if(manual_logout)
        q.setInteger("keep_day", 0);
      q.setInteger("user_id", userid);
      q.setTimestamp("last_time", lastLogin);
      int er = q.executeUpdate();
      commit();
      return er;
    }catch(HibernateException e){
      rollback();
      throw e;
View Full Code Here

    obj.setSortOrder(order_value - (up ? 1 : 0));
    try {
      beginTransaction();
      ssn.save(obj);
      // ���¶�ȡ�����б�����˳���������
      Query q = ssn.getNamedQuery("LIST_FORUMS");
      q.setInteger(0, obj.getSite().getId());
      List links = q.list();
      if (links.size() >= ConfigDAO.getMaxCatalogCount(obj.getSite()
          .getId()))
        throw new CapacityExceedException(links.size());
      if (links.size() > 1) {
        for (int i = 0; i < links.size(); i++) {
View Full Code Here

   * @param args
   * @return
   */
  protected static List executeQuery(String hql, int fromIdx, int fetchCount, Object[] args){
    Session ssn = getSession();
    Query q = ssn.createQuery(hql);
    for(int i=0;args!=null&&i<args.length;i++){
      q.setParameter(i, args[i]);
    }
    if(fromIdx > 0)
      q.setFirstResult(fromIdx);
    if(fetchCount > 0)
      q.setMaxResults(fetchCount);
    return q.list();
  }
View Full Code Here

   * @param args
   * @return
   */
  protected static int executeUpdate(String hql, Object[] args){
    Session ssn = getSession();
    Query q = ssn.createQuery(hql);
    for(int i=0;args!=null&&i<args.length;i++){
      q.setParameter(i, args[i]);
    }
    return q.executeUpdate();
  }
View Full Code Here

   */
  protected static int commitUpdate(String hql, Object[] args){
    try{
      Session ssn = getSession();
      beginTransaction();
      Query q = ssn.createQuery(hql);
      for(int i=0;args!=null&&i<args.length;i++){
        q.setParameter(i, args[i]);
      }
      int er = q.executeUpdate();
      commit();
      return er;
    }catch(HibernateException e){
      rollback();
      throw e;
View Full Code Here

   * @param args
   * @return
   */
  protected static Object uniqueResult(String hql, Object[] args){
    Session ssn = getSession();
    Query q = ssn.createQuery(hql);
    for(int i=0;args!=null&&i<args.length;i++){
      q.setParameter(i, args[i]);
    }
    q.setMaxResults(1);
    return q.uniqueResult();
  }
View Full Code Here

   * @param args
   * @return
   */
  protected static List executeNamedQuery(String hql, int fromIdx, int fetchCount, Object[] args){
    Session ssn = getSession();
    Query q = ssn.getNamedQuery(hql);
    for(int i=0;args!=null&&i<args.length;i++){
      q.setParameter(i, args[i]);
    }
    if(fromIdx > 0)
      q.setFirstResult(fromIdx);
    if(fetchCount > 0)
      q.setMaxResults(fetchCount);
    return q.list();
  }
View Full Code Here

   * @param args
   * @return
   */
  protected static Object namedUniqueResult(String hql, Object[] args){
    Session ssn = getSession();
    Query q = ssn.getNamedQuery(hql);
    for(int i=0;args!=null&&i<args.length;i++){
      q.setParameter(i, args[i]);
    }
    q.setMaxResults(1);
    return q.uniqueResult();
  }
View Full Code Here

TOP

Related Classes of org.hibernate.Query

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.