Package org.hibernate

Examples of org.hibernate.Session.createQuery()


   * @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


        hql.append("?,");
        hql2.append("?,");
      }
      hql.append("?)")
      hql2.append("?)");     
      Query q = ssn.createQuery(hql.toString());
      q.setInteger(0, siteid);
      i=0;
      for(;i<ids.length;i++){
        q.setInteger(i+1, ids[i]);
      }
View Full Code Here

      q.setInteger(i+1, ids[0]);
      List musics = q.list();
      if(musics.size()>0){
        beginTransaction();
        //����ռ��жԸ����ֵ�����
        Query q2 = ssn.createQuery(hql2.toString());
        i=0;
        q2.setParameter(0, null);
        for(;i<ids.length;i++){
          q2.setInteger(i+1, ids[i]);
        }
View Full Code Here

    @SuppressWarnings("unchecked")
  public static ProcessInstanceLog findProcessInstance(long processInstanceId) {
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
        List<ProcessInstanceLog> result = session.createQuery(
            "from ProcessInstanceLog as log where log.processInstanceId = ?")
                .setLong(0, processInstanceId).list();
        session.getTransaction().commit();
        return result == null || result.size() == 0 ? null : result.get(0);
    }
View Full Code Here

    @SuppressWarnings("unchecked")
  public static List<NodeInstanceLog> findNodeInstances(long processInstanceId) {
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
        List<NodeInstanceLog> result = session.createQuery(
            "from NodeInstanceLog as log where log.processInstanceId = ?")
                .setLong(0, processInstanceId).list();
        session.getTransaction().commit();
        return result;
    }
View Full Code Here

    @SuppressWarnings("unchecked")
  public static List<NodeInstanceLog> findNodeInstances(long processInstanceId, String nodeId) {
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
        List<NodeInstanceLog> result = session.createQuery(
            "from NodeInstanceLog as log where log.processInstanceId = ? and log.nodeId = ?")
                .setLong(0, processInstanceId)
                .setString(1, nodeId).list();
        session.getTransaction().commit();
        return result;
View Full Code Here

  @SuppressWarnings("unchecked")
  public static void clear() {
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
        List<ProcessInstanceLog> processInstances =
          session.createQuery("from ProcessInstanceLog").list();
        for (ProcessInstanceLog processInstance: processInstances) {
          session.delete(processInstance);
        }
        List<NodeInstanceLog> nodeInstances =
          session.createQuery("from NodeInstanceLog").list();
View Full Code Here

          session.createQuery("from ProcessInstanceLog").list();
        for (ProcessInstanceLog processInstance: processInstances) {
          session.delete(processInstance);
        }
        List<NodeInstanceLog> nodeInstances =
          session.createQuery("from NodeInstanceLog").list();
        for (NodeInstanceLog nodeInstance: nodeInstances) {
          session.delete(nodeInstance);
        }
        session.getTransaction().commit();
    }
View Full Code Here

    }
   
    private void updateProcessLog(long processInstanceId) {
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
        List<ProcessInstanceLog> result = session.createQuery(
        "from ProcessInstanceLog as log where log.processInstanceId = ? and log.end is null")
            .setLong(0, processInstanceId).list();
        if (result != null && result.size() != 0) {
          ProcessInstanceLog log = result.get(result.size() - 1);
          log.setEnd(new Date());
View Full Code Here

      hql.append(" AND t.site.id=:site");
    if(fbean!=null)
      hql.append(" AND t.forum.id=:forum");
    hql.append(" AND (t.type=:elite OR t.type=:top_elite)");
    Session ssn = getSession();
    Query q = ssn.createQuery(hql.toString());
    q.setInteger("status", TopicBean.STATUS_NORMAL);
    q.setInteger("elite", TopicBean.INFO_TYPE_ELITE);
    q.setInteger("top_elite", TopicBean.INFO_TYPE_TOP_ELITE);
    if(site!=null)
      q.setInteger("site", site.getId());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.