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

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # 8.1\. 依賴對象(Dependent objects) 組件(Component)是一個被包含的對象,在持久化的過程中,它被當作值類型,而并非一個實體的引用。在這篇文檔中,組件這一術語指的是面向對象的合成概念(而并不是系統構架層次上的組件的概念)。舉個例子, 你對人(Person)這個概念可以像下面這樣來建模: ``` public class Person { private java.util.Date birthday; private Name name; private String key; public String getKey() { return key; } private void setKey(String key) { this.key=key; } public java.util.Date getBirthday() { return birthday; } public void setBirthday(java.util.Date birthday) { this.birthday = birthday; } public Name getName() { return name; } public void setName(Name name) { this.name = name; } ...... ...... } ``` ``` public class Name { char initial; String first; String last; public String getFirst() { return first; } void setFirst(String first) { this.first = first; } public String getLast() { return last; } void setLast(String last) { this.last = last; } public char getInitial() { return initial; } void setInitial(char initial) { this.initial = initial; } } ``` 在持久化的過程中,`姓名(Name)`可以作為`人(Person)`的一個組件。需要注意的是:你應該為`姓名`的持久化屬性定義getter和setter方法,但是你不需要實現任何的接口或申明標識符字段。 以下是這個例子的Hibernate映射文件: ``` <class name="eg.Person" table="person"> <id name="Key" column="pid" type="string"> <generator class="uuid"/> </id> <property name="birthday" type="date"/> <component name="Name" class="eg.Name"> <!-- class attribute optional --> <property name="initial"/> <property name="first"/> <property name="last"/> </component> </class> ``` 人員(Person)表中將包括`pid`, `birthday`, `initial`, `first`和 `last`等字段。 就像所有的值類型一樣, 組件不支持共享引用。 換句話說,兩個人可能重名,但是兩個Person對象應該包含兩個獨立的Name對象,只不過這兩個Name對象具有“同樣”的值。 組件的值可以為空,其定義如下。 每當Hibernate重新加載一個包含組件的對象,如果該組件的所有字段為空,Hibernate將假定整個組件為空。 在大多數情況下,這樣假定應該是沒有問題的。 組件的屬性可以是任意一種Hibernate類型(包括集合, 多對多關聯, 以及其它組件等等)。嵌套組件不應該被當作一種特殊的應用(Nested components should not be considered an exotic usage)。 Hibernate傾向于支持細致的(fine-grained)對象模型。 `&lt;component&gt;` 元素還允許有 `&lt;parent&gt;`子元素,用來表明component類中的一個屬性是指向包含它的實體的引用。 ``` <class name="eg.Person" table="person"> <id name="Key" column="pid" type="string"> <generator class="uuid"/> </id> <property name="birthday" type="date"> <component name="Name" class="eg.Name" unique="true"> <parent name="namedPerson"/> <!-- reference back to the Person --> <property name="initial"/> <property name="first"/> <property name="last"/> </component&gt; </class> ```
                  <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>

                              哎呀哎呀视频在线观看