七郎'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();


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


          網站導航:
           
          主站蜘蛛池模板: 六枝特区| 苗栗市| 峨山| 北宁市| 南和县| 孙吴县| 宣化县| 商城县| 奎屯市| 上栗县| 东兴市| 堆龙德庆县| 安图县| 富阳市| 双城市| 衢州市| 井冈山市| 宁陵县| 龙江县| 无极县| 海原县| 株洲县| 靖宇县| 陕西省| 富川| 雷山县| 菏泽市| 中卫市| 安徽省| 长白| 桐柏县| 永昌县| 巴林右旗| 贞丰县| 景德镇市| 贡觉县| 张北县| 鸡东县| 湘乡市| 保康县| 肇庆市|