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

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

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

    Neil的備忘錄

    just do it
    posts - 66, comments - 8, trackbacks - 0, articles - 0

    Flushing the Session

    Posted on 2008-11-01 10:11 Neil's NoteBook 閱讀(119) 評論(0)  編輯  收藏

    From time to time the Session will execute the SQL statements needed to synchronize the JDBC connection's state with the state of objects held in memory. This process, flush, occurs by default at the following points

    • before some query executions

    • from org.hibernate.Transaction.commit()

    • from Session.flush()

    The SQL statements are issued in the following order

    1. all entity insertions, in the same order the corresponding objects were saved using Session.save()

    2. all entity updates

    3. all collection deletions

    4. all collection element deletions, updates and insertions

    5. all collection insertions

    6. all entity deletions, in the same order the corresponding objects were deleted using Session.delete()

    (An exception is that objects using native ID generation are inserted when they are saved.)

    Except when you explicity flush(), there are absolutely no guarantees about when the Session executes the JDBC calls, only the order in which they are executed. However, Hibernate does guarantee that the Query.list(..) will never return stale data; nor will they return the wrong data.

    It is possible to change the default behavior so that flush occurs less frequently. The FlushMode class defines three different modes: only flush at commit time (and only when the Hibernate Transaction API is used), flush automatically using the explained routine, or never flush unless flush() is called explicitly. The last mode is useful for long running units of work, where a Session is kept open and disconnected for a long time (see Section 11.3.2, “Extended session and automatic versioning”).

    sess = sf.openSession();
    Transaction tx = sess.beginTransaction();
    sess.setFlushMode(FlushMode.COMMIT); // allow queries to return stale state
    Cat izi = (Cat) sess.load(Cat.class, id);
    izi.setName(iznizi);
    // might return stale data
    sess.find("from Cat as cat left outer join cat.kittens kitten");
    // change to izi is not flushed!
    ...
    tx.commit(); // flush occurs
    sess.close();

    During flush, an exception might occur (e.g. if a DML operation violates a constraint). Since handling exceptions involves some understanding of Hibernate's transactional behavior, we discuss it in Chapter 11, Transactions And Concurrency.  


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


    網站導航:
     
    主站蜘蛛池模板: 免费在线黄色网址| 四虎影视www四虎免费| 亚洲大片在线观看| 日本免费大黄在线观看| 亚洲性69影院在线观看| 成年美女黄网站18禁免费| 亚洲成AV人片在WWW| 亚洲第一网站男人都懂| 花蝴蝶免费视频在线观看高清版| 亚洲va久久久噜噜噜久久狠狠| 国产精品亚洲精品日韩电影| 免费高清在线爱做视频| 亚洲国产成人综合精品| 亚洲综合激情另类专区| 精品无码国产污污污免费网站 | 午夜国产大片免费观看| 国产福利免费视频 | 伊人久久大香线蕉亚洲五月天| 国内少妇偷人精品视频免费| 亚洲福利一区二区精品秒拍| 日韩中文无码有码免费视频 | 6080午夜一级毛片免费看| 久久国产亚洲精品| 亚洲免费视频播放| WWW亚洲色大成网络.COM | 男人天堂2018亚洲男人天堂| 亚洲成av人在线视| 亚洲国产综合久久天堂| 美女被免费喷白浆视频| 在线毛片片免费观看| 一级女人18片毛片免费视频| 亚洲日本久久久午夜精品| 亚洲影院在线观看| 亚洲黄片毛片在线观看| 成全视频免费高清| 18未年禁止免费观看| 你是我的城池营垒免费看| 免费一级全黄少妇性色生活片 | 亚洲热线99精品视频| 国产三级免费电影| 免费a级毛片无码a∨蜜芽试看|