七郎's JavaBlog

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

          Hibernate3.0批量更新,刪除

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

          Hibernate3.0執(zhí)行批量更新
          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執(zhí)行批量刪除
          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();


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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 科技| 电白县| 宜宾市| 望奎县| 郧西县| 基隆市| 来安县| 万安县| 沅陵县| 彰武县| 伽师县| 新密市| 牡丹江市| 长春市| 武功县| 寿宁县| 屏边| 临湘市| 清河县| 三台县| 久治县| 镶黄旗| 万宁市| 克拉玛依市| 电白县| 敦煌市| 宁城县| 海阳市| 福清市| 温州市| 平潭县| 河曲县| 磴口县| 旅游| 井研县| 兴国县| 海伦市| 贡嘎县| 邻水| 新巴尔虎左旗| 平定县|