七郎's JavaBlog

          草木竹石皆可為劒。至人之用人若鏡,不將不迎,應而不藏,故能勝物而不傷。
          posts - 60, comments - 14, trackbacks - 0, articles - 0

          Hibernate3.0批量更新,刪除

          Posted on 2007-04-16 15:25 七郎歸來 閱讀(250) 評論(0)  編輯  收藏
           

          Hibernate3.0執行批量更新
          Session session = sessionFactory.openSession();
          Transaction tx = session.beginTransaction();
          String hqlUpdate = "update Customer set name = :newName where name = :oldName";
          int updatedEntities = s.createQuery( hqlUpdate )
          .setString( "newName", newName )
          .setString( "oldName", oldName )
          .executeUpdate();
          tx.commit();
          session.close();

          Hibernate3.0執行批量刪除
          Session session = sessionFactory.openSession();
          Transaction tx = session.beginTransaction();
          String hqlDelete = "delete Customer where name = :oldName";
          int deletedEntities = s.createQuery( hqlDelete )
          .setString( "oldName", oldName )
          .executeUpdate();
          tx.commit();
          session.close();


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 东辽县| 兰考县| 阿拉尔市| 兰坪| 绥芬河市| 永定县| 兴和县| 当雄县| 本溪市| 东方市| 金秀| 南漳县| 合川市| 措美县| 瑞丽市| 若羌县| 依安县| 清河县| 鄂温| 丹凤县| 普格县| 麻城市| 瑞昌市| 桦南县| 普洱| 绥宁县| 大安市| 二连浩特市| 延津县| 黑山县| 会理县| 七台河市| 南宫市| 泰和县| 康定县| 阿瓦提县| 定襄县| 商水县| 甘孜县| 安多县| 临夏县|