Package org.hibernate

Examples of org.hibernate.Session


public class ProcessInstanceDbLog {
   
    @SuppressWarnings("unchecked")
  public static List<ProcessInstanceLog> findProcessInstances() {
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
        List<ProcessInstanceLog> result = session.createQuery("from ProcessInstanceLog").list();
        session.getTransaction().commit();
        return result;
    }
View Full Code Here


        return result;
    }

    @SuppressWarnings("unchecked")
  public static List<ProcessInstanceLog> findProcessInstances(String processId) {
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
        List<ProcessInstanceLog> result = session.createQuery(
            "from ProcessInstanceLog as log where log.processId = ?")
                .setString(0, processId).list();
        session.getTransaction().commit();
        return result;
    }
View Full Code Here

        session.getTransaction().commit();
        return result;
    }

  public static List<ProcessInstanceLog> findActiveProcessInstances(String processId) {
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
        List<ProcessInstanceLog> result = session.createQuery(
            "from ProcessInstanceLog as log where log.processId = ? AND log.end is null")
                .setString(0, processId).list();
        session.getTransaction().commit();
        return result;
    }
View Full Code Here

        return result;
    }

    @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

  /**
   * ���������лָ��ռ�
   * @param log
   */
  public static void unDelete(DiaryOutlineBean log){
    Session ssn = getSession();
    try{
      beginTransaction();
      log.setStatus(DiaryBean.STATUS_NORMAL);
      log.getCatalog().incArticleCount(1);
      log.getOwner().getCount().incArticleCount(1);
     
      //���в�����ռ������ߵ��ռ���������һ
      List rpls = log.getReplies();
      for(int i=0;rpls!=null && i<rpls.size();i++){
        DiaryReplyBean prb = (DiaryReplyBean)rpls.get(i);
        if(prb.getUser()!=null)
          prb.getUser().getCount().incArticleReply(1);
      }     
     
      ssn.update(log);
      commit();     
    }catch(HibernateException e){
      rollback();
      throw e;
    }
View Full Code Here

      if(user != null)
        hql.append(" OR (j.catalog.type=:cat_type AND j.catalog.id IN (SELECT p.key.catalog FROM CatalogPermBean AS p WHERE p.key.user=:user))");
      hql.append(')');
    }
   
    Session ssn = getSession();
   
    try{
      Query q = ssn.createQuery(hql.toString()).setCacheable(true);
      q.setTimestamp("beginTime", firstDate.getTime());
      q.setTimestamp("endTime", nextMonthFirstDate.getTime());
      q.setInteger("status", DiaryBean.STATUS_NORMAL);
      q.setInteger("site", site.getId());
      if(!site.isOwner(user)){
View Full Code Here

   * @param log_id
   * @throws SQLException
   * @throws IOException
   */
  public static void forceDelete(int log_id) throws Exception{
    Session ssn = getSession();
    try{
      DiaryBean log = (DiaryBean)ssn.load(DiaryBean.class, new Integer(log_id));
      beginTransaction();
      //����������ռ����Ӧ�ķ����ռ�����һ
      if(log.getStatus()==DiaryBean.STATUS_NORMAL){
        log.getCatalog().incArticleCount(-1);
      }
      //ɾ����ǩ
      TagDAO.deleteTagByRefId(log_id, TagBean.TYPE_DIARY);
     
      //ɾ������
      FCKUploadFileDAO.deleteFilesByRef(ssn, log.getSite().getId(), log_id,
          DiaryBean.TYPE_DIARY);

      //���в������Ƭ�����ߵ������������һ
      cleanupReplies(ssn, log_id);
     
      //ɾ���ռ�
      ssn.delete(log);
      commit();
    }catch(HibernateException e){
      rollback();
      throw e;
    }
View Full Code Here

   */
  public static void cleanupTrash(int site_id) throws Exception{
    List logs = findNamedAll("QUERY_TRASH_BEFORE_CLEANUP",site_id, DiaryBean.STATUS_DELETED);
    if(logs!=null && logs.size()>0){
      try{
        Session ssn = getSession();
        beginTransaction()
        for(int i=0;i<logs.size();i++){
          DiaryOutlineBean log = (DiaryOutlineBean)logs.get(i);
         
          //ɾ�����ռǵ���������
          cleanupReplies(ssn, log.getId());
          //ɾ����ǩ
          TagDAO.deleteTagByRefId(log.getId(), TagBean.TYPE_DIARY);         
          //ɾ������
          FCKUploadFileDAO.deleteFilesByRef(ssn, site_id, log.getId(), DiaryBean.TYPE_DIARY);
          //ɾ���ռ�
          ssn.delete(log);
        }
        commit();
      }catch(HibernateException e){
        rollback();
        throw e;
View Full Code Here

    }
    if (cat_id > 0){
      hql.append(" AND j.catalog.id=:catalog");
    }
    hql.append(" ORDER BY j.id DESC");
    Session ssn = getSession();
    try{
      Query q = ssn.createQuery(hql.toString());
      q.setInteger("site", site.getId());
      q.setInteger("status", DiaryBean.STATUS_NORMAL);
      q.setInteger("diary", log_id);
      if(cat_id > 0)
        q.setInteger("catalog", cat_id);
View Full Code Here

    }
    if (cat_id > 0){
      hql.append(" AND j.catalog.id=:catalog");
    }
    hql.append(" ORDER BY j.id ASC");
    Session ssn = getSession();
    try{
      Query q = ssn.createQuery(hql.toString());
      q.setInteger("site", site.getId());
      q.setInteger("status", DiaryBean.STATUS_NORMAL);
      q.setInteger("diary", log_id);
      if(cat_id > 0)
        q.setInteger("catalog", cat_id);
View Full Code Here

TOP

Related Classes of org.hibernate.Session

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.