<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # 21.4\. 級聯與`未保存值`(Cascades and `unsaved-value`) 假設我們從`Session`中裝入了一個`Parent`對象,用戶界面對其進行了修改,然后希望在一個新的Session里面調用`update()`來保存這些修改。對象`Parent`包含了子對象的集合,由于打開了級聯更新,Hibernate需要知道哪些Child對象是新實例化的,哪些代表數據庫中已經存在的記錄。我們假設`Parent`和`Child`對象的標識屬性都是自動生成的,類型為`java.lang.Long`。Hibernate會使用標識屬性的值,和version 或 timestamp 屬性,來判斷哪些子對象是新的。(參見[第 10.7 節 “自動狀態檢測”](../Text/pr01_split_000.html "10.7\. 自動狀態檢測").) _在 Hibernate3 中,顯式指定`unsaved-value`不再是必須的了。_ 下面的代碼會更新`parent`和`child`對象,并且插入`newChild`對象。 ``` //parent and child were both loaded in a previous session parent.addChild(child); Child newChild = new Child(); parent.addChild(newChild); session.update(parent); session.flush(); ``` Well, that's all very well for the case of a generated identifier, but what about assigned identifiers and composite identifiers? This is more difficult, since Hibernate can't use the identifier property to distinguish between a newly instantiated object (with an identifier assigned by the user) and an object loaded in a previous session. In this case, Hibernate will either use the timestamp or version property, or will actually query the second-level cache or, worst case, the database, to see if the row exists. 這對于自動生成標識的情況是非常好的,但是自分配的標識和復合標識怎么辦呢?這是有點麻煩,因為Hibernate沒有辦法區分新實例化的對象(標識被用戶指定了)和前一個Session裝入的對象。在這種情況下,Hibernate會使用timestamp或version屬性,或者查詢第二級緩存,或者最壞的情況,查詢數據庫,來確認是否此行存在。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看