<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    hibernate 一級緩存

    1 hibernate 一級緩存
    Session?
    ? evict(Object o) 從緩存中清除指定的持久化對象
    ? clear()???????? 清除緩存中所有對象
    2 批量更新于批量刪除
    ? 1) 批量更新
    ?? Iterator customers=session.find("from Customer c where c.age>0");
    ?? while(customers.hasNext()){
    ???? Customer customer=(Customer)customers.next();
    ???? customer.setAge(customer.getAge()+1);
    ?? }
    ?? tx.commit();
    ?? session.close();

    ? 缺點:內(nèi)存中加載了大量數(shù)據(jù)
    ??????? 執(zhí)行了多次update 語句
    ?
    ?? 改進
    ?? Iterator customers=session.find("from Customer c where c.age>0");
    ?? while(customers.hasNext()){
    ???? Customer customer=(Customer)customers.next();
    ???? customer.setAge(customer.getAge()+1);
    ???? session.flush();
    ???? session.evict(customer);
    ?? }
    ?? tx.commit();
    ?? session.close();
    ?? 遺留問題
    ?? 執(zhí)行了多次update 語句
    ??
    ?? 采用jdbc api 進行調(diào)用
    ?? Connection con=session.connection();
    ?? PrepareStatement stmt=con.prepareStatement("update customers set age=age+1 where age>0");
    ?? stmt.executeUpdate();
    ?? tx.commit();
    ?? 另外,也可以調(diào)用底層的存儲過程進行批量更新
    ?? create or replace procedure batchUpdateCustomer(p_age,in number) as
    ?? begin
    ????? update customer set age=age+1 where age>p_age;
    ?? end;
    ??
    ?? tx=session.beginTransaction();
    ?? Connection con=session.connection();
    ?? CallableStatement cstmt=con.prepareCall(batchUpdateCustomer);
    ?? cstmt.setInt(1,0);
    ?? cstmt.eqecuteUpdate();
    ?? tx.commit();
    ?? 2) 批量數(shù)據(jù)的刪除
    ??? session.delete("from? Customer c where c.age>0");
    ??? 實際調(diào)用的過程
    ??? session * from Customer where age>0;
    ??? 在把所有數(shù)據(jù)加載到內(nèi)存之后執(zhí)行多條delete 語句
    ??? delete from customer where id=i;
    ???? .......................
    ?? 改進辦法采用jdbc api 進行批量數(shù)據(jù)的刪除
    ?????
    ?? tx=session.beginTransaction();
    ?? Connection con=session.connection();
    ?? con.execute("delete from customers where age>0");
    ?? tx.commit();

    posted on 2006-09-14 09:22 康文 閱讀(469) 評論(0)  編輯  收藏 所屬分類: java

    <2006年9月>
    272829303112
    3456789
    10111213141516
    17181920212223
    24252627282930
    1234567

    導航

    統(tǒng)計

    常用鏈接

    留言簿(1)

    隨筆分類

    隨筆檔案

    文章檔案

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 四虎影视永久免费观看| 成人au免费视频影院| 亚洲情侣偷拍精品| 美女被免费视频网站| 国产成人高清精品免费鸭子| 亚洲日韩中文字幕一区| 午夜一级免费视频| 黄色a三级免费看| 国产亚洲色婷婷久久99精品91| 精品国产免费一区二区三区| 亚洲综合日韩久久成人AV| 九九99热免费最新版| 亚洲国产综合无码一区| 久久久久成人精品免费播放动漫| 亚洲av鲁丝一区二区三区| 最近中文字幕mv免费高清在线| 亚洲另类自拍丝袜第1页| 最近的中文字幕大全免费版| 国产偷国产偷亚洲清高APP| 亚洲男人天堂2020| 久久99热精品免费观看牛牛| 亚洲一线产区二线产区精华| 白白国产永久免费视频| 一级人做人a爰免费视频| 婷婷亚洲综合五月天小说| 亚洲人成电影网站免费| 国产亚洲男人的天堂在线观看| 亚洲无线码在线一区观看| 在线免费观看国产| 香港经典a毛片免费观看看| 亚洲AV无码一区二区二三区软件| 精品免费久久久久久久| 精品免费AV一区二区三区| 亚洲AV日韩AV天堂一区二区三区| 无人影院手机版在线观看免费| 婷婷亚洲综合五月天小说在线| 国产AV无码专区亚洲精品| 成人免费无毒在线观看网站| 三级黄色在线免费观看| 亚洲五月综合缴情婷婷| 亚洲第一黄色网址|