Package org.hibernate

Examples of org.hibernate.Session$LockRequest


    }
    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

   * @throws HibernateException
   * @throws SQLException
   */
  public static void create(DiaryBean journal, boolean add_bookmark){
    try{
      Session ssn = getSession();
      beginTransaction();
      if(journal.getStatus()==DiaryBean.STATUS_NORMAL){
        journal.getCatalog().incArticleCount(1);
        journal.getOwner().getCount().incArticleCount(1);
      }
      ssn.save(journal)
      if(journal.getCatalog().getType()==CatalogBean.TYPE_GENERAL){
        //ֻ�й��������е��ռDzſ������ñ�ǩ
        List tags = journal.getKeywords();
        if(tags!=null && tags.size()>0){
          int tag_count = 0;
          for(int i=0;i<tags.size();i++){
            if(tag_count>=MAX_TAG_COUNT)
              break;
            String tag_name = (String)tags.get(i);
            if(tag_name.getBytes().length > MAX_TAG_LENGTH)
              continue;
            TagBean tag = new TagBean();
            tag.setSite(journal.getSite());
            tag.setRefId(journal.getId());
            tag.setRefType(DiaryBean.TYPE_DIARY);
            tag.setName(tag_name);
            ssn.save(tag);
            tag_count ++;
          }
        }
      }
      if(add_bookmark){
        BookmarkBean bmb = new BookmarkBean();
        bmb.setOwner(journal.getOwner());
        bmb.setSite(journal.getSite());
        bmb.setCreateTime(new Date());
        bmb.setParentId(journal.getId());
        bmb.setParentType(_BeanBase.TYPE_DIARY);
        bmb.setTitle(journal.getTitle());
        journal.getOwner().getCount().incBookmarkCount(1);
        ssn.save(bmb);
      }
      commit();
    }catch(HibernateException e){
      rollback();
      throw e;
View Full Code Here

      hql.append(" AND a.catalog.id=:catalog");
    if(year > 0 || month > 0 || date > 0){
      hql.append(" AND a.writeTime >= :beginTime AND a.writeTime < :endTime");
    }
    try {
      Session ssn = getSession();
      Query q = ssn.createQuery(hql.toString());
      q.setInteger("status", DiaryBean.STATUS_NORMAL);
      q.setInteger("site", site.getId());
      if(!site.isOwner(user)){
        q.setInteger("cat_type", CatalogBean.TYPE_OWNER);
        if(user != null){
View Full Code Here

    if(year > 0 || month > 0 || date > 0){
      hql.append(" AND a.writeTime >= :beginTime AND a.writeTime < :endTime");
    }
    hql.append(" ORDER BY a.id DESC");
    try {
      Session ssn = getSession();
      Query q = ssn.createQuery(hql.toString());
      q.setInteger("status", DiaryBean.STATUS_NORMAL);
      q.setInteger("cat_type", CatalogBean.TYPE_OWNER);
      if(year > 0 || month > 0 || date > 0){
        Calendar[] cals = genTimeParams(year,month,date);
        q.setTimestamp("beginTime", cals[0].getTime());
View Full Code Here

    if(year > 0 || month > 0 || date > 0){
      hql.append(" AND a.writeTime >= :beginTime AND a.writeTime < :endTime");
    }
    hql.append(" ORDER BY a.id DESC");
    try {
      Session ssn = getSession();
      Query q = ssn.createQuery(hql.toString());
      q.setInteger("status", DiaryBean.STATUS_NORMAL);
      q.setInteger("site", site.getId());
      if(user==null || site.getOwner().getId() != user.getId()){
        q.setInteger("cat_type", CatalogBean.TYPE_OWNER);
        if(user != null){
View Full Code Here

        hql.append(" OR (r.diary.catalog.type=:cat_type AND r.diary.catalog.id IN (SELECT p.key.catalog FROM CatalogPermBean AS p WHERE p.key.user=:userid))");
      hql.append(')');
      hql.append(" AND (r.ownerOnly = 0 OR r.user.id = :userid)");
    }
    hql.append(" ORDER BY r.id DESC");
    Session ssn = getSession();
    Query q = ssn.createQuery(hql.toString());
    q.setInteger("status", DiaryReplyBean.STATUS_NORMAL);
    q.setInteger("site", site.getId());
    q.setInteger("diary_status", DiaryOutlineBean.STATUS_NORMAL);
    if(!site.isOwner(user)){
      q.setInteger("cat_type", CatalogBean.TYPE_OWNER);
View Full Code Here

      hql.append(" AND (r.diary.catalog.type<>?");
      if(user != null)
        hql.append(" OR (r.diary.catalog.type=? AND r.diary.catalog.id IN (SELECT p.key.catalog FROM CatalogPermBean AS p WHERE p.key.user=?))");
      hql.append(')');
    }
    Session ssn = getSession();
    Query q = ssn.createQuery(hql.toString());
    q.setInteger(0, DiaryReplyBean.STATUS_NORMAL);
    q.setInteger(1, site.getId());
    if(!site.isOwner(user)){
      q.setInteger(2, CatalogBean.TYPE_OWNER);
      if(user != null){
View Full Code Here

  /**
   * ɾ���ռ�����,�Զ����ٶ�Ӧ�ռǵ�������
   * @param reply
   */
  public static void deleteDiaryReply(DiaryReplyBean reply){
    Session ssn = getSession();
    try{
      beginTransaction();
      if(reply.getDiary()!=null)
        reply.getDiary().incReplyCount(-1);
      if(reply.getUser()!=null)
        reply.getUser().getCount().incArticleReply(-1);
      ssn.delete(reply);
      commit();
    }catch(HibernateException e){
      rollback();
    }
  }
View Full Code Here

   * �����������������������������Զ�����
   * @param reply
   */
  public static void createDiaryReply(DiaryReplyBean reply){
    try{
      Session ssn = getSession();
      int max_reply_count = ConfigDAO.getMaxReplyCount(reply.getSite().getId());
      beginTransaction()
      reply.getDiary().incReplyCount(1);
      if(reply.getDiary().getReplyCount()>=max_reply_count && max_reply_count > 0)
        reply.getDiary().setLock(1);
      reply.getDiary().setLastReplyTime(new Date());
      if(reply.getUser()!=null)
        reply.getUser().getCount().incArticleReply(1);
      ssn.save(reply);
      commit();
    }catch(HibernateException e){
      rollback();
      throw e;
    }
View Full Code Here

TOP

Related Classes of org.hibernate.Session$LockRequest

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.