Package org.hibernate

Examples of org.hibernate.Session$LockRequest


      //�ų��û�û��Ȩ�޷��ʵķ���
      hql.append(" AND r.photo.album.type=:album_type");
      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", PhotoReplyBean.STATUS_NORMAL);
    q.setInteger("photo_status", PhotoBean.STATUS_NORMAL);
    q.setInteger("site", site.getId());
    if(!is_owner){
      q.setInteger("album_type", AlbumBean.TYPE_PUBLIC);
View Full Code Here


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

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

    URL xml = Main.class.getResource("old_hibernate.cfg.xml");
    old_hb = Hibernate.init(xml.getPath());
    xml = Main.class.getResource("new_hibernate.cfg.xml");
    new_hb = Hibernate.init(xml.getPath());

    Session old_ssn = old_hb.getSession();
    Session new_ssn = new_hb.getSession();
    Transaction tx = new_ssn.beginTransaction();
   
    try{
      upgradeUsers(old_ssn, new_ssn);
      System.out.println("============== Users upgraded.=================");
     
View Full Code Here

   * @param site
   * @param count
   * @return
   */
  public static List listHotTags(int site, int count){
    Session ssn = getSession();
    StringBuffer sql = new StringBuffer("SELECT tag_name,COUNT(*) FROM dlog_tag");
    if(site>0)
      sql.append(" WHERE site_id=?");
    sql.append(" GROUP BY tag_name ORDER BY 2 DESC");
    SQLQuery query = ssn.createSQLQuery(sql.toString());
    if(site>0)
      query.setInteger(0, site);
    query.setMaxResults(count);
    List tags = new ArrayList();
    List results = query.list();
View Full Code Here

   * @param bean
   */
  public static boolean save(BookmarkBean bookmark){
    if(exists(bookmark.getOwner().getId(), bookmark.getParentId(), bookmark.getParentType()))
      return false;
    Session ssn = getSession();
    try{
      beginTransaction();
      if(bookmark.getCreateTime()==null)
        bookmark.setCreateTime(new Date());
      bookmark.getOwner().getCount().incBookmarkCount(1);
      ssn.save(bookmark);
      commit();     
    }catch(HibernateException e){
      rollback();
      throw e;
    }
View Full Code Here

    StringBuffer hql = new StringBuffer("DELETE FROM BookmarkBean AS f WHERE f.owner=? AND f.id IN (");
    for(int i=0;i<bookmarkIds.length;i++){
      hql.append("?,");
    }
    hql.append("?)");
    Session ssn = getSession();
    try{
      beginTransaction();
      Query q = ssn.createQuery(hql.toString());
      q.setInteger(0, ownerId);
      int i=0;
      for(;i<bookmarkIds.length;i++){
        String s_id = (String)bookmarkIds[i];
        int id = -1;
View Full Code Here

    }
    try {
      Hits hits = getHits( searcher );
      int first = first();
      int max = max( first, hits );
      Session sess = (Session) this.session;

      int size = max - first + 1 < 0 ? 0 : max - first + 1;
      List<EntityInfo> infos = new ArrayList<EntityInfo>( size );
      DocumentExtractor extractor = new DocumentExtractor( searchFactoryImplementor, indexProjection );
      for (int index = first; index <= max; index++) {
View Full Code Here

    Hits hits;
    try {
      hits = getHits( searcher );
      int first = first();
      int max = max( first, hits );
      Session sess = (Session) this.session;

      int size = max - first + 1 < 0 ? 0 : max - first + 1;
      List<EntityInfo> infos = new ArrayList<EntityInfo>( size );
      DocumentExtractor extractor = new DocumentExtractor( searchFactoryImplementor, indexProjection );
      for (int index = first; index <= max; index++) {
View Full Code Here

  @Override
  public Object execute(Object[] parameters) {
    if (parameters.length == 0)
      return null;
    Session session = getContext().getSession();
    if (parameters[0].getClass().isArray()) {
      for (Object obj : (Object[]) parameters[0]) {
        session.save(obj);
      }
    } else {
      session.save(parameters[0]);
    }
    return null;
  }
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.