七郎's JavaBlog

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

          Hibernate3.0批量更新,刪除

          Posted on 2007-04-16 15:25 七郎歸來 閱讀(249) 評論(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();


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


          網站導航:
           
          主站蜘蛛池模板: 临猗县| 大荔县| 虎林市| 汤原县| 衡山县| 连南| 嵊泗县| 长葛市| 杭锦旗| 大名县| 梓潼县| 上蔡县| 大宁县| 成都市| 宁明县| 大名县| 梓潼县| 宿松县| 阿拉尔市| 定陶县| 包头市| 惠来县| 出国| 绥宁县| 绥江县| 庆安县| 慈利县| 湟中县| 东城区| 大丰市| 修武县| 宜黄县| 双牌县| 临沭县| 中方县| 平原县| 舒城县| 湖州市| 瓦房店市| 太原市| 平凉市|