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


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


    網站導航:
    博客園   IT新聞   Chat2DB   C++博客   博問  
     
    主站蜘蛛池模板: 国产亚洲精品一品区99热| 亚洲狠狠爱综合影院婷婷| 亚洲中文无码永久免费| 永久久久免费浮力影院| 一级做a爰全过程免费视频毛片| 国产亚洲精久久久久久无码77777| 日本免费在线观看| 亚洲av无码不卡久久| 免费午夜爽爽爽WWW视频十八禁| 日本免费A级毛一片| 亚洲综合色婷婷在线观看| 大胆亚洲人体视频| 久久久免费的精品| 亚洲国产高清国产拍精品| 亚洲人成人一区二区三区| 西西大胆无码视频免费| 一区免费在线观看| 亚洲乱码一二三四区国产| 亚洲精品国产高清不卡在线| 亚洲免费电影网站| 老司机福利在线免费观看| 亚洲综合区图片小说区| 亚洲精品无码av天堂| 97性无码区免费| 国产午夜精品理论片免费观看| 国产亚洲玖玖玖在线观看| 亚洲精品无码永久在线观看你懂的| 可以免费看黄视频的网站| 久久久久久噜噜精品免费直播| 成人区精品一区二区不卡亚洲| 国产亚洲AV无码AV男人的天堂| 日本成人在线免费观看| 最近的中文字幕大全免费8| 2022国内精品免费福利视频| 亚洲日韩精品国产一区二区三区| 亚洲成Av人片乱码色午夜| 在线a亚洲v天堂网2018| 在线观看免费污视频| 亚欧免费视频一区二区三区| 国产成人AV免费观看| 人成电影网在线观看免费|