<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.  


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


    網站導航:
     
    主站蜘蛛池模板: 亚洲黄色免费电影| 亚洲av无码一区二区三区不卡 | 中文字幕一精品亚洲无线一区| 亚洲最大激情中文字幕| 亚洲日本精品一区二区| 亚洲精品国产国语| 日日狠狠久久偷偷色综合免费 | 亚洲视频在线免费| 亚洲AV日韩精品久久久久久久| 亚洲国产综合精品| 色噜噜的亚洲男人的天堂| 久久免费视频一区| 99久久99久久精品免费看蜜桃| 日本不卡在线观看免费v| 亚洲欧洲国产精品香蕉网| 亚洲成年人免费网站| 国产成人高清亚洲一区久久| aaa毛片免费观看| 免费看黄视频网站| 亚洲成A人片在线观看无码3D| 久久精品亚洲视频| 亚洲欧美aⅴ在线资源| 中国人免费观看高清在线观看二区| **真实毛片免费观看| 免费一级毛片女人图片| 亚洲福利视频一区| 国产亚洲欧美日韩亚洲中文色| 日本一区午夜艳熟免费| 免费看无码自慰一区二区| 亚洲乱码精品久久久久..| 亚洲中文字幕无码中文字| a级成人毛片免费视频高清| 免费羞羞视频网站| 亚洲伦另类中文字幕| 国产亚洲Av综合人人澡精品| 精品一区二区三区免费毛片爱| 国产一级大片免费看| 亚洲综合一区二区精品久久| 日本高清不卡中文字幕免费| 亚洲国产精品免费观看| 亚洲人成网亚洲欧洲无码久久|