<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 閱讀(120) 評論(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.  


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


    網站導航:
     
    主站蜘蛛池模板: 亚洲人精品午夜射精日韩| 亚洲三级在线免费观看| 处破痛哭A√18成年片免费| 久久久婷婷五月亚洲97号色| 91精品成人免费国产| 国产美女亚洲精品久久久综合| 亚洲成a∧人片在线观看无码| 日本免费一区二区三区最新| 亚洲日本va在线观看| 成年女人喷潮毛片免费播放| 亚洲人精品亚洲人成在线| 免费无码A片一区二三区| 中文有码亚洲制服av片| 日韩一区二区三区免费体验| 亚洲熟女综合色一区二区三区| 黑人粗长大战亚洲女2021国产精品成人免费视频 | 国产成人高清亚洲| 免费看内射乌克兰女| 亚洲国产成人VA在线观看| jizz在线免费观看| 亚洲一区AV无码少妇电影☆| 91福利免费网站在线观看| 久久久久久亚洲Av无码精品专口| 91成人免费观看| 亚洲深深色噜噜狠狠网站| 国产在线不卡免费播放| 成人特级毛片69免费观看| 污污网站免费观看| 亚洲av无码一区二区三区乱子伦| 韩国免费A级毛片久久| 亚洲av午夜福利精品一区| 88av免费观看| 67194在线午夜亚洲| 免费理论片51人人看电影| 四虎成人精品国产永久免费无码| 久久影院亚洲一区| 6080午夜一级毛片免费看6080夜福利 | 亚洲人成网亚洲欧洲无码| 国产一区二区三区免费在线观看| a级在线免费观看| 亚洲乱码日产精品BD在线观看|