Package org.hibernate

Examples of org.hibernate.Session$LockRequest


  /**
   * Ǩ���ռ�����
   * @throws Exception
   */
  protected static void transfer_diary_replies() throws Exception{
    Session ssn = HibernateUtils.getSession();
    try{
      HibernateUtils.beginTransaction();
      List rpls = ssn.createQuery("FROM DiaryReplyBean AS r ORDER BY r.id").list();
      for(int i=0;i<rpls.size();i++){
        DiaryReplyBean rpl = (DiaryReplyBean)rpls.get(i);
        CommentBean cb = new CommentBean();
        cb.setClient(rpl.getClient());
        AuthorInfo author = new AuthorInfo();
        author.setEmail(rpl.getAuthorEmail());
        author.setName(rpl.getAuthor());
        author.setUrl(rpl.getAuthorURL());
        if(rpl.getUser()!=null){
          author.setId(rpl.getUser().getId());
        }
        cb.setAuthor(author);
        cb.setContent(rpl.getContent());
        cb.setCreateTime(rpl.getReplyTime());
        cb.setEid(rpl.getDiary().getId());
        cb.setEtype(DiaryReplyBean.TYPE_DIARY);
        cb.setSite(rpl.getSite());
        cb.setStatus(rpl.getStatus());
        cb.setTitle(StringUtils.abbreviate(rpl.getContent(), 20));
        ssn.save(cb);
        System.out.println("DiaryReplyBean: " + rpl.getId() + " -> " + cb.getId());
      }
      HibernateUtils.commit();
    }catch(Exception e){
      HibernateUtils.rollback();
View Full Code Here


  /**
   * Ǩ���������
   * @throws Exception
   */
  protected static void transfer_photo_replies() throws Exception{
    Session ssn = HibernateUtils.getSession();
    try{
      HibernateUtils.beginTransaction();
      List rpls = ssn.createQuery("FROM PhotoReplyBean AS r ORDER BY r.id").list();
      for(int i=0;i<rpls.size();i++){
        PhotoReplyBean rpl = (PhotoReplyBean)rpls.get(i);
        CommentBean cb = new CommentBean();
        cb.setClient(rpl.getClient());
        AuthorInfo author = new AuthorInfo();
        author.setEmail(rpl.getAuthorEmail());
        author.setUrl(rpl.getAuthorURL());
        author.setName(rpl.getAuthor());
        if(rpl.getUser()!=null){
          author.setId(rpl.getUser().getId());
        }
        cb.setAuthor(author);
        cb.setContent(rpl.getContent());
        cb.setCreateTime(rpl.getReplyTime());
        cb.setEid(rpl.getPhoto().getId());
        cb.setEtype(DiaryReplyBean.TYPE_PHOTO);
        cb.setSite(rpl.getSite());
        cb.setStatus(rpl.getStatus());
        cb.setTitle(StringUtils.abbreviate(rpl.getContent(), 20));
        ssn.save(cb);
        System.out.println("PhotoReplyBean: " + rpl.getId() + " -> " + cb.getId());
      }
      HibernateUtils.commit();
    }catch(Exception e){
      HibernateUtils.rollback();
View Full Code Here

  /**
   * Ǩ����̳����
   * @throws Exception
   */
  protected static void transfer_bbs_replies() throws Exception{
    Session ssn = HibernateUtils.getSession();
    try{
      HibernateUtils.beginTransaction();
      List rpls = ssn.createQuery("FROM TopicReplyBean AS r ORDER BY r.id").list();
      for(int i=0;i<rpls.size();i++){
        TopicReplyBean rpl = (TopicReplyBean)rpls.get(i);
        CommentBean cb = new CommentBean();
        cb.setClient(rpl.getClient());
        AuthorInfo author = new AuthorInfo();
        author.setEmail(rpl.getAuthorEmail());
        author.setName(rpl.getAuthor());
        author.setUrl(rpl.getAuthorURL());
        if(rpl.getUser()!=null){
          author.setName(rpl.getUser().getNickname());
          author.setId(rpl.getUser().getId());
        }
        else
          author.setName("����");
        cb.setAuthor(author);
        cb.setContent(rpl.getContent());
        cb.setCreateTime(rpl.getReplyTime());
        cb.setEid(rpl.getTopic().getId());
        cb.setEtype(DiaryReplyBean.TYPE_BBS);
        cb.setSite(rpl.getSite());
        cb.setStatus(rpl.getStatus());
        cb.setTitle(rpl.getTitle());
        ssn.save(cb);
        System.out.println("TopicReplyBean: " + rpl.getId() + " -> " + cb.getId());
      }
      HibernateUtils.commit();
    }catch(Exception e){
      HibernateUtils.rollback();
View Full Code Here

   * @param up
   * @throws CapacityExceedException
   */
  public static void createForum(ForumBean obj, int pos, boolean up)
      throws CapacityExceedException {
    Session ssn = getSession();
    int order_value = 1;
    if (pos > 0) {
      ForumBean friend = (ForumBean) ssn.get(ForumBean.class,
          new Integer(pos));
      order_value = friend.getSortOrder();
    }
    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());
View Full Code Here

   * @param bean
   */
  public static void create(TrackBackBean bean){
    if(bean.getTrackTime()==null)
      bean.setTrackTime(new Date());
    Session ssn = getSession();
    try{
      beginTransaction();
      ssn.save(bean);
      if(bean.getParentType()==_BeanBase.TYPE_DIARY){
        DiaryDAO.incTrackBackCount(ssn, bean.getParentId(), 1);
      }
      commit();
    }catch(HibernateException e){
View Full Code Here

   * ��Ӷ���
   * @param cbean
   */
  public static void save(Object cbean){
    try{
      Session ssn = getSession();
      beginTransaction();
      ssn.save(cbean);
      commit();
    }catch(HibernateException e){
      rollback();
      throw e;
    }
View Full Code Here

   * ��Ӷ���
   * @param cbean
   */
  protected static void saveOrUpdate(Object cbean){
    try{
      Session ssn = getSession();
      beginTransaction();
      ssn.saveOrUpdate(cbean);
      commit();
    }catch(HibernateException e){
      rollback();
      throw e;
    }
View Full Code Here

   * ɾ������
   * @param cbean
   */
  protected static void delete(Object cbean){
    try{
      Session ssn = getSession();
      beginTransaction();
      ssn.delete(cbean);
      commit();
    }catch(HibernateException e){
      rollback();
      throw e;
    }
View Full Code Here

  /**
   * д�����ݵ����ݿ�
   */
  public static void flush(){
    try{
      Session ssn = getSession();
      if(ssn.isDirty()){
        beginTransaction();
        ssn.flush();
        commit();
      }
    }catch(HibernateException e){
      rollback();
      throw e;
View Full Code Here

   * @param hql
   * @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);
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.