Package org.hibernate

Examples of org.hibernate.Session$LockRequest


   * @throws SQLException
   * @throws CapacityExceedException
   */
  public static void create(int parentId, AlbumBean obj, int pos, int direction)
      throws CapacityExceedException {
    Session ssn = getSession();
    int order_value = 1;
    if (pos > 0) {
      AlbumBean friend = getAlbumByID(pos);
      order_value = friend.getSortOrder();
    }
    // ���ڵ�
    if (parentId > 0){
      AlbumBean parent = (AlbumBean)DAO.getBean(AlbumBean.class, parentId);
      if(parent!=null)
        obj.setParent(parent);
    }

    obj.setSortOrder(order_value - ((direction==1) ? 1 : 0));
    try {
      beginTransaction();
      ssn.save(obj);
      // ���¶�ȡ�����б�����˳���������
      List albums = findNamedAll("LIST_ALBUM",obj.getSite().getId());
      if (albums.size() >= ConfigDAO.getMaxAlbumCount(obj.getSite().getId()))
        throw new CapacityExceedException(albums.size());
      if (albums.size() > 1) {
View Full Code Here


    if(site!=null)
      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

    if(site!=null)
      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) ORDER BY ROUND(t.type / 16, 0) DESC, t.id DESC");
    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

  public static List listHotTopics(SiteBean site, ForumBean forum, int fromIdx, int count, int days){
    StringBuffer hql = new StringBuffer("FROM TopicOutlineBean AS t WHERE t.site.id=? AND t.status=? AND t.createTime >= ? AND t.replyCount > 0");
    if(forum != null)
      hql.append(" AND t.forum.id=?");
    hql.append(" ORDER BY ROUND(t.type / 16, 0) DESC, t.replyCount DESC, t.id DESC");
    Session ssn = getSession();
    try{
      Query q = ssn.createQuery(hql.toString());
      q.setInteger(0, site.getId());
      q.setInteger(1, TopicOutlineBean.STATUS_NORMAL);
      Calendar cur_time = Calendar.getInstance();
      cur_time.add(Calendar.DATE, -days);
      q.setTimestamp(2, new Timestamp(cur_time.getTime().getTime()));
View Full Code Here

   */
  public static void create(TopicBean topic, boolean add_bookmark) {
    try {
      if (topic.getCreateTime() == null)
        topic.setCreateTime(new Date());
      Session ssn = getSession();
      beginTransaction();
      topic.getUser().getCount().incTopicCount(1);
      topic.getForum().incTopicCount(1);
      topic.getForum().setLastPostTime(new Date());
      topic.getForum().setLastUser(topic.getUser());
      topic.getForum().setLastUsername(topic.getUsername());
      topic.getForum().setLastTopic(topic);

      List tags = topic.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(topic.getSite());
          tag.setRefId(topic.getId());
          tag.setRefType(DiaryBean.TYPE_BBS);
          tag.setName(tag_name);
          ssn.save(tag);
          tag_count ++;
        }
      }     
     
      ssn.save(topic);
      if (add_bookmark) {
        BookmarkBean bmb = new BookmarkBean();
        bmb.setOwner(topic.getUser());
        bmb.setSite(topic.getSite());
        bmb.setCreateTime(new Date());
        bmb.setParentId(topic.getId());
        bmb.setParentType(_BeanBase.TYPE_BBS);
        bmb.setTitle(topic.getTitle());
        ssn.save(bmb);
      }
      commit();
    } catch (HibernateException e) {
      rollback();
      throw e;
View Full Code Here

   * @throws IOException
   */
  public static void delete(TopicOutlineBean topic) throws Exception {
    if(topic==null)
      return ;
    Session ssn = getSession();
    try {
      beginTransaction();
      // ��̳����������һ
      topic.getForum().incTopicCount(-1);
      //��̳��������
      if (topic.getForum().getLastTopic() != null
          && topic.getForum().getLastTopic().getId() == topic.getId()) {
        topic.getForum().setLastTopic(null);
        topic.getForum().setLastPostTime(null);
        topic.getForum().setLastUsername(null);
        topic.getForum().setLastUser(null);
      }
      topic.getUser().getCount().incTopicCount(-1);
     
      List rpls = topic.getReplies();
      for(int i=rpls.size()-1;i>=0;i--){
        TopicReplyBean rbean = (TopicReplyBean)rpls.get(i);
        if(rbean.getUser()!=null)
          rbean.getUser().getCount().incTopicReplyCount(-1);
      }
     
      ssn.delete(topic);

      //ɾ����ǩ
      TagDAO.deleteTagByRefId(topic.getId(), TagBean.TYPE_BBS);

      //ɾ������
View Full Code Here

   * @throws Exception
   */
  public static void writeStatData(int siteid, int uvCount, int source) throws Exception{
    Calendar cal = Calendar.getInstance();
    int statDate = cal.get(Calendar.YEAR)*10000 + cal.get(Calendar.MONTH)*100 + cal.get(Calendar.DATE);
    Session ssn = getSession();
    try{
      beginTransaction();
      Query update_q = ssn.getNamedQuery((siteid>0)?"UPDATE_SITE_STAT_1":"UPDATE_SITE_STAT_2");
      update_q.setInteger(0, uvCount);
      update_q.setInteger(1, statDate);
      update_q.setInteger(2, source);
      if(siteid>0)
        update_q.setInteger(3, siteid);
      if(update_q.executeUpdate()<1){
        SiteStatBean ssb = new SiteStatBean();
        ssb.setSiteId(siteid);
        ssb.setUvCount(uvCount);
        ssb.setUpdateTime(new Date());
        ssb.setSource(source);
        ssb.setStatDate(statDate);
        ssn.save(ssb);
      }
      commit();
    }catch(Exception e){
      rollback();
      throw e;
View Full Code Here

      if(i > 0) hql.append(',');
      hql.append('?');
    }
    hql.append(')');
    try{
      Session ssn = getSession();
      beginTransaction();
      Query q = ssn.createQuery(hql.toString());
      q.setInteger(0, incCount);
      for(int i=1;i<=music_ids.length;i++){
        q.setParameter(i, new Integer(music_ids[i-1]));
      }
      int er = q.executeUpdate();
View Full Code Here

   * ���ݱ�Ż�ȡ������Ϣ
   * @param ids
   * @return
   */
  public static List listSongs(List ids){
    Session ssn = getSession();
    StringBuffer hql = new StringBuffer("FROM MusicBean m WHERE m.id IN (");
    int i=0;
    for(;i<ids.size();i++){
      hql.append("?,");
    }
    hql.append("?) ORDER BY m.id DESC");     
    Query q = ssn.createQuery(hql.toString());
    for(i=0;i<ids.size();i++){
      int id = ((Number)ids.get(i)).intValue();
      q.setInteger(i, id);
    }
    q.setInteger(i, -1);
View Full Code Here

   * @param site
   * @param key
   * @return
   */
  public static List search(String key){
    Session ssn = getSession();
    Query q = ssn.getNamedQuery("SEARCH_MUSIC");
    String pattern = '%' + key + '%';
    q.setString("key", pattern);
    q.setMaxResults(20);
    List res = q.list();
    List songs = new ArrayList();
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.