hibernate-orm/doc/reference/ja/modules/example_parentchild.xml

362 lines
15 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="Shift_JIS"?>
<chapter id="example-parentchild">
<title><EFBFBD><EFBFBD><EFBFBD>F<EFBFBD>e/<2F>q<EFBFBD><71>
</title>
<para>
<20>V<EFBFBD>K<EFBFBD><4B><EFBFBD>[<5B>U<EFBFBD><55>Hibernate<74><65><EFBFBD>g<EFBFBD><67><EFBFBD>Ă܂<C482><DC82>ŏ<EFBFBD><C58F>Ɉ<EFBFBD><C988><EFBFBD><EFBFBD><EFBFBD><EFBFBD>f<EFBFBD><66><EFBFBD>̈<EFBFBD><CC88>‚ɁA<C981>e<EFBFBD>q<EFBFBD>^<5E>̃<EFBFBD><CC83>f<EFBFBD><66><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
<20><><EFBFBD>̃<EFBFBD><CC83>f<EFBFBD><66><EFBFBD><EFBFBD><EFBFBD>ɂ͓<C982><CD93>‚̃A<CC83>v<EFBFBD><76><EFBFBD>[<5B>`<60><><EFBFBD><EFBFBD><EFBFBD>݂<EFBFBD><DD82>܂<EFBFBD><DC82>B<EFBFBD>Ƃ<EFBFBD><C682><EFBFBD>V<EFBFBD>K<EFBFBD><4B><EFBFBD>[<5B>U<EFBFBD>ɂƂ<C982><C682>āA
<20><><EFBFBD>܂<EFBFBD><DC82>܂ȗ<DC82><C897>R<EFBFBD><52><EFBFBD><EFBFBD><EFBFBD>ł<EFBFBD><C582>֗<EFBFBD><D697><EFBFBD><EFBFBD>Ǝv<C68E><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A<EFBFBD>v<EFBFBD><76><EFBFBD>[<5B>`<60>́A<literal><EFBFBD>e</literal> <20><><EFBFBD><EFBFBD> <literal><EFBFBD>q<EFBFBD><EFBFBD></literal>
<20>ւ<EFBFBD> <literal>&lt;one-to-many&gt;</literal> <20>֘A<D698>ɂ<EFBFBD><C982><EFBFBD> <literal><EFBFBD>e</literal> <20><> <literal><EFBFBD>q<EFBFBD><EFBFBD></literal>
<20>̗<EFBFBD><CC97><EFBFBD><EFBFBD><EFBFBD><EFBFBD>G<EFBFBD><47><EFBFBD>e<EFBFBD>B<EFBFBD>e<EFBFBD>B<EFBFBD>N<EFBFBD><4E><EFBFBD>X<EFBFBD>Ƃ<EFBFBD><C682>ă<EFBFBD><C483>f<EFBFBD><66><EFBFBD><EFBFBD><EFBFBD>O<EFBFBD><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>@<40>ł<EFBFBD>
<20>i<EFBFBD><69><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>‚̕<C282><CC95>@<40>́A<literal><EFBFBD>q<EFBFBD><EFBFBD></literal> <20><> <literal>&lt;composite-element&gt;</literal> <20>Ƃ<EFBFBD><C682>Ē<EFBFBD><C492>`<60><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̂ł<CC82><C582>j<EFBFBD>B
<20><><EFBFBD><EFBFBD><EFBFBD>ŁiHibernate<74>ɂ<EFBFBD><C982><EFBFBD><EFBFBD><EFBFBD><EFBFBD>j<EFBFBD><6A><EFBFBD>Α<EFBFBD><CE91>֘A<D698>̃f<CC83>t<EFBFBD>H<EFBFBD><48><EFBFBD>g<EFBFBD>̃Z<CC83>}<7D><><EFBFBD>e<EFBFBD>B<EFBFBD>N<EFBFBD>X<EFBFBD><58><EFBFBD>A<EFBFBD>ʏ<EFBFBD><CA8F>̕<EFBFBD><CC95><EFBFBD><EFBFBD>v<EFBFBD>f<EFBFBD>̃}<7D>b<EFBFBD>s<EFBFBD><73><EFBFBD>O<EFBFBD><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A
<20>e<EFBFBD>q<EFBFBD>֌W<D68C>̃Z<CC83>}<7D><><EFBFBD>e<EFBFBD>B<EFBFBD>N<EFBFBD>X<EFBFBD><58><EFBFBD><EFBFBD><E78993><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682><EFBFBD><ED82A9><EFBFBD>܂<EFBFBD><DC82>B
<20><><EFBFBD><EFBFBD><EFBFBD>ł͐e<CD90>q<EFBFBD>֌W<D68C><57><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>I<EFBFBD><49><EFBFBD>ƒG<C283><47><EFBFBD>K<EFBFBD><4B><EFBFBD>g<EFBFBD>Ƀ<EFBFBD><C983>f<EFBFBD><66><EFBFBD><EFBFBD><EFBFBD>O<EFBFBD><4F><EFBFBD><EFBFBD>߂ɁA
<emphasis><EFBFBD>J<EFBFBD>X<EFBFBD>P<EFBFBD>[<5B>h<EFBFBD><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>o<EFBFBD><6F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Α<EFBFBD><CE91>֘A</emphasis> <20>̈<EFBFBD><CC88><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B<EFBFBD><42><EFBFBD><EFBFBD><EFBFBD>͂܂<CD82><DC82><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EF82B5><EFBFBD><EFBFBD><EFBFBD>̂ł͂<C582><CD82><EFBFBD><EFBFBD>܂<EFBFBD><DC82><EFBFBD><EFBFBD>B
</para>
<sect1 id="example-parentchild-collections">
<title><EFBFBD>R<EFBFBD><EFBFBD><EFBFBD>N<EFBFBD>V<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ɋւ<EFBFBD><EFBFBD><EFBFBD><EFBFBD></title>
<para>
Hibernate<74>̃R<CC83><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>͎<EFBFBD><CD8E>g<EFBFBD>̃G<CC83><47><EFBFBD>e<EFBFBD>B<EFBFBD>e<EFBFBD>B<EFBFBD>̘_<CC98><5F><EFBFBD>I<EFBFBD>ȕ<EFBFBD><C895><EFBFBD><EFBFBD>ƍl<C68D><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A
<20><><EFBFBD><EFBFBD><EFBFBD>ĕ<EFBFBD><C495>܂<EFBFBD><DC82><EFBFBD><EFBFBD>G<EFBFBD><47><EFBFBD>e<EFBFBD>B<EFBFBD>e<EFBFBD>B<EFBFBD>̂<EFBFBD><CC82>̂ł͂<C582><CD82><EFBFBD><EFBFBD>܂<EFBFBD><DC82><EFBFBD><EFBFBD>B<EFBFBD><42><EFBFBD><EFBFBD><EFBFBD>͒v<CD92><76><EFBFBD>I<EFBFBD>ȈႢ<C888>ł<EFBFBD><C582>I
<20><><EFBFBD><EFBFBD><EFBFBD>͈ȉ<CD88><C889>̂悤<CC82>Ȍ<EFBFBD><C88C>ʂɂȂ<C982><C882>܂<EFBFBD><DC82>F
</para>
<itemizedlist>
<listitem>
<para>
<20>I<EFBFBD>u<EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g<EFBFBD><67><EFBFBD>R<EFBFBD><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A<EFBFBD>܂<EFBFBD><DC82>̓R<CD83><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>ɒlj<C992><C789><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>A
<20>R<EFBFBD><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>̃I<CC83>[<5B>i<EFBFBD>[<5B>̃o<CC83>[<5B>W<EFBFBD><57><EFBFBD><EFBFBD><EFBFBD>ԍ<EFBFBD><D48D>̓C<CD83><43><EFBFBD>N<EFBFBD><4E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
</para>
</listitem>
<listitem>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD>R<EFBFBD><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><ED8F9C><EFBFBD><EFBFBD>I<EFBFBD>u<EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g<EFBFBD><67><EFBFBD>l<EFBFBD>^<5E>̃C<CC83><43><EFBFBD>X<EFBFBD>^<5E><><EFBFBD>X
<20>i<EFBFBD><EFBFBD>΃R<CE83><52><EFBFBD>|<7C>W<EFBFBD>b<EFBFBD>g<EFBFBD>G<EFBFBD><47><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>g)<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȃ<EFBFBD><C882>΁A<CE81><41><EFBFBD>̃I<CC83>u<EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g<EFBFBD>͉i<CD89><69><EFBFBD>I<EFBFBD>ł͂Ȃ<CD82><C882>Ȃ<EFBFBD><C882>A
<20><><EFBFBD>̏<EFBFBD><CC8F>Ԃ̓f<CD83>[<5B>^<5E>x<EFBFBD>[<5B>X<EFBFBD><58><EFBFBD><EFBFBD>S<EFBFBD>ɍ폜<C98D><ED8F9C><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɁA<C981>l<EFBFBD>^<5E>̃C<CC83><43><EFBFBD>X<EFBFBD>^<5E><><EFBFBD>X<EFBFBD><58><EFBFBD>R<EFBFBD><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>ɒlj<C992><C789><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƁA<C681><41><EFBFBD>̏<EFBFBD><CC8F>Ԃ͂<D482><CD82><EFBFBD><EFBFBD>ɉi<C989><69><EFBFBD>I<EFBFBD>ɂȂ<C982><C882>܂<EFBFBD><DC82>B
</para>
</listitem>
<listitem>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD>A<EFBFBD><41><EFBFBD><EFBFBD><EFBFBD>G<EFBFBD><47><EFBFBD>e<EFBFBD>B<EFBFBD>e<EFBFBD>B<EFBFBD><42><EFBFBD>R<EFBFBD><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>i<EFBFBD><69><EFBFBD>Α<EFBFBD><CE91>܂<EFBFBD><DC82>͑<EFBFBD><CD91>Α<EFBFBD><CE91>֘A)<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><ED8F9C><EFBFBD><EFBFBD><EFBFBD>Ă<EFBFBD><C482>A
<20>f<EFBFBD>t<EFBFBD>H<EFBFBD><48><EFBFBD>g<EFBFBD>ł͂<C582><CD82><EFBFBD><EFBFBD>͍폜<CD8D><ED8F9C><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82><EFBFBD><EFBFBD>B<EFBFBD><42><EFBFBD>̓<EFBFBD><CC93><EFBFBD><EFBFBD>͊<EFBFBD><CD8A>S<EFBFBD>Ɉ<EFBFBD><C988>т<EFBFBD><D182>Ă<EFBFBD><C482>܂<EFBFBD><DC82>B
<20><><EFBFBD>Ȃ킿<C882>A<EFBFBD><41><EFBFBD>̃G<CC83><47><EFBFBD>e<EFBFBD>B<EFBFBD>e<EFBFBD>B<EFBFBD>̓<EFBFBD><CC93><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԃ<EFBFBD><D482>ύX<CF8D><58><EFBFBD>Ă<EFBFBD><C482>A<EFBFBD>֘A<D698><41><EFBFBD><EFBFBD><EFBFBD>G<EFBFBD><47><EFBFBD>e<EFBFBD>B<EFBFBD>e<EFBFBD>B<EFBFBD><42><EFBFBD><EFBFBD><EFBFBD>ł<EFBFBD><C582>ׂ<EFBFBD><D782>ł͂Ȃ<CD82><C882>Ƃ<EFBFBD><C682><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƃł<C682><C582>B
<20><><EFBFBD>l<EFBFBD>ɁA<C981>G<EFBFBD><47><EFBFBD>e<EFBFBD>B<EFBFBD>e<EFBFBD>B<EFBFBD><42><EFBFBD>R<EFBFBD><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>ɒlj<C992><C789><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ă<EFBFBD><C482>A<EFBFBD>f<EFBFBD>t<EFBFBD>H<EFBFBD><48><EFBFBD>g<EFBFBD>ł͂<C582><CD82>̃G<CC83><47><EFBFBD>e<EFBFBD>B<EFBFBD>e<EFBFBD>B<EFBFBD>͉i<CD89><69><EFBFBD>I<EFBFBD>ɂ͂Ȃ<CD82><C882>܂<EFBFBD><DC82><EFBFBD><EFBFBD>B
</para>
</listitem>
</itemizedlist>
<para>
<20><><EFBFBD>̑<EFBFBD><CC91><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɁA<C981>f<EFBFBD>t<EFBFBD>H<EFBFBD><48><EFBFBD>g<EFBFBD>̓<EFBFBD><CC93><EFBFBD><EFBFBD>ł́A<CD81>G<EFBFBD><47><EFBFBD>e<EFBFBD>B<EFBFBD>e<EFBFBD>B<EFBFBD><42><EFBFBD>R<EFBFBD><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>ɒlj<C992><C789><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƒP<C692>ɓ<EFBFBD><C993>‚̃G<CC83><47><EFBFBD>e<EFBFBD>B<EFBFBD>e<EFBFBD>B<EFBFBD>Ԃ̃<D482><CC83><EFBFBD><EFBFBD>N<EFBFBD><4E><EFBFBD><EFBFBD><EC90AC><EFBFBD>A
<20><><EFBFBD><EFBFBD><EFBFBD>G<EFBFBD><47><EFBFBD>e<EFBFBD>B<EFBFBD>e<EFBFBD>B<EFBFBD><42><EFBFBD><EFBFBD><ED8F9C><EFBFBD><EFBFBD><EFBFBD>ƃ<EFBFBD><C683><EFBFBD><EFBFBD>N<EFBFBD><4E><EFBFBD><EFBFBD><ED8F9C><EFBFBD>܂<EFBFBD><DC82>B<EFBFBD><42><EFBFBD><EFBFBD><EFBFBD>͂<EFBFBD><CD82>ׂẴP<CC83>[<5B>X<EFBFBD>ɂ<EFBFBD><C982><EFBFBD><EFBFBD>Ĕ<EFBFBD><C494><EFBFBD><EFBFBD>ɓK<C993>؂ł<D882><C582>B
<20><><EFBFBD><EFBFBD>K<EFBFBD>؂łȂ<C582><C882>̂͐e/<2F>q<EFBFBD>֌W<D68C>̏ꍇ<CC8F>ł<EFBFBD><C582>B<EFBFBD><42><EFBFBD>̏ꍇ<CC8F>q<EFBFBD><71><EFBFBD>̐<EFBFBD><CC90><EFBFBD><EFBFBD>͐e<CD90>̃<EFBFBD><CC83>C<EFBFBD>t<EFBFBD>T<EFBFBD>C<EFBFBD>N<EFBFBD><4E><EFBFBD>ɐ<EFBFBD><C990><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E982A9><EFBFBD>ł<EFBFBD><C582>B
</para>
</sect1>
<sect1 id="example-parentchild-bidir">
<title><EFBFBD>o<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Α<EFBFBD>
</title>
<para>
<literal>Parent</literal> <20><><EFBFBD><EFBFBD> <literal>Child</literal> <20>ւ̒P<CC92><50><EFBFBD><EFBFBD> <literal>&lt;one-to-many&gt;</literal> <20>֘A<D698><41><EFBFBD><EFBFBD><EFBFBD>n<EFBFBD>߂<EFBFBD><DF82>Ƃ<EFBFBD><C682>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[<set name="children">
<key column="parent_id"/>
<one-to-many class="Child"/>
</set>]]></programlisting>
<para>
<20>ȉ<EFBFBD><C889>̃R<CC83>[<5B>h<EFBFBD><68><EFBFBD><EFBFBD><EFBFBD>s<EFBFBD><73><EFBFBD><EFBFBD><EFBFBD>ƁA
</para>
<programlisting><![CDATA[Parent p = .....;
Child c = new Child();
p.getChildren().add(c);
session.save(c);
session.flush();]]></programlisting>
<para>
Hibernate<74>͓<EFBFBD><CD93>‚<EFBFBD>SQL<51><4C><EFBFBD>𔭍s<F094AD8D><73><EFBFBD>܂<EFBFBD>:
</para>
<itemizedlist>
<listitem>
<para>
<literal>c</literal><EFBFBD>ɑ΂<EFBFBD><EFBFBD><EFBFBD>R<EFBFBD>[<5B>h<EFBFBD>𐶐<EFBFBD><F090B690><EFBFBD><EFBFBD><EFBFBD><literal>INSERT</literal>
</para>
</listitem>
<listitem>
<para>
<literal>p</literal><EFBFBD><EFBFBD><EFBFBD><EFBFBD><literal>c</literal><EFBFBD>ւ̃<EFBFBD><EFBFBD><EFBFBD><EFBFBD>N<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><literal>UPDATE</literal>
</para>
</listitem>
</itemizedlist>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD>͔<EFBFBD><CD94><EFBFBD><EFBFBD><EFBFBD><EFBFBD>I<EFBFBD>Ȃ<EFBFBD><C882><EFBFBD><EFBFBD>ł͂Ȃ<CD82><C882>A<literal>parent_id</literal> <20>J<EFBFBD><4A><EFBFBD><EFBFBD><EFBFBD>ɂ<EFBFBD><C982><EFBFBD><EFBFBD><EFBFBD> <literal>NOT NULL</literal> <20><><EFBFBD><EFBFBD><EFBFBD>Ɉᔽ<C988><E194BD><EFBFBD>܂<EFBFBD><DC82>B
<20>R<EFBFBD><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>̃}<7D>b<EFBFBD>s<EFBFBD><73><EFBFBD>O<EFBFBD><4F> <literal>not-null="true"</literal> <20>Ǝw<C68E><EFBFBD><EFBFBD>ƂŁAnull<6C><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E194BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>ł<EFBFBD><C582>܂<EFBFBD>:
</para>
<programlisting><![CDATA[<set name="children">
<key column="parent_id" not-null="true"/>
<one-to-many class="Child"/>
</set>]]></programlisting>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̉<EFBFBD><CC89><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͐<EFBFBD><CD90><EFBFBD><EFBFBD>ł<EFBFBD><C582>܂<EFBFBD><DC82><EFBFBD><EFBFBD>B
</para>
<para>
<20><><EFBFBD>̓<EFBFBD><CC93><EFBFBD><EFBFBD>̍<EFBFBD><CC8D>{<7B>I<EFBFBD>Ȍ<EFBFBD><C88C><EFBFBD><EFBFBD>́A<literal>p</literal> <20><><EFBFBD><EFBFBD> <literal>c</literal> <20>ւ̃<D682><CC83><EFBFBD><EFBFBD>N
<20>i<EFBFBD>O<EFBFBD><4F><EFBFBD>L<EFBFBD>[ <literal>parent_id</literal>)<29><> <literal>Child</literal> <20>I<EFBFBD>u<EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g<EFBFBD>̏<EFBFBD><CC8F>Ԃ̈ꕔ<CC88>Ƃ͍l<CD8D><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A
<20><><EFBFBD>̂<EFBFBD><CC82><EFBFBD> <literal>INSERT</literal> <20>ɂ<EFBFBD><C982><EFBFBD><EFBFBD>ă<EFBFBD><C483><EFBFBD><EFBFBD>N<EFBFBD><4E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȃ<EFBFBD><C882><EFBFBD><EFBFBD>Ƃł<C682><C582>B
<20>ł<EFBFBD><C582><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A<EFBFBD><41><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̓<EFBFBD><CD83><EFBFBD><EFBFBD>N<EFBFBD><4E>Child<6C>}<7D>b<EFBFBD>s<EFBFBD><73><EFBFBD>O<EFBFBD>̈ꕔ<CC88>ɂ<EFBFBD><C982><EFBFBD>Ƃł<C682><C582>B
</para>
<programlisting><![CDATA[<many-to-one name="parent" column="parent_id" not-null="true"/>]]></programlisting>
<para>
(<28>܂<EFBFBD> <literal>Child</literal> <20>N<EFBFBD><4E><EFBFBD>X<EFBFBD><58> <literal>parent</literal> <20>v<EFBFBD><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD><42><EFBFBD>lj<EFBFBD><C789><EFBFBD><EFBFBD><EFBFBD><EFBFBD>K<EFBFBD>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B)
</para>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD>ł<EFBFBD> <literal>Child</literal> <20>G<EFBFBD><47><EFBFBD>e<EFBFBD>B<EFBFBD>e<EFBFBD>B<EFBFBD><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>N<EFBFBD>̏<EFBFBD><CC8F>Ԃ𐧌䂷<F090A78C><E482B7><EFBFBD><EFBFBD>ɂȂ<C982><C882><EFBFBD><EFBFBD>̂ŁA
<20>R<EFBFBD><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>N<EFBFBD><4E><EFBFBD>X<EFBFBD>V<EFBFBD><56><EFBFBD>Ȃ<EFBFBD><C882><EFBFBD>ɂ<EFBFBD><C982>܂<EFBFBD><DC82><EFBFBD>B<EFBFBD><42><EFBFBD><EFBFBD><EFBFBD>ɂ<EFBFBD> <literal>inverse</literal> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>g<EFBFBD><67><EFBFBD>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[<set name="children" inverse="true">
<key column="parent_id"/>
<one-to-many class="Child"/>
</set>]]></programlisting>
<para>
<20>ȉ<EFBFBD><C889>̃R<CC83>[<5B>h<EFBFBD><68><EFBFBD>g<EFBFBD><67><EFBFBD>΁A<CE81>V<EFBFBD><56><EFBFBD><EFBFBD> <literal>Child</literal> <20><><EFBFBD>lj<EFBFBD><C789><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>ł<EFBFBD><C582>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[Parent p = (Parent) session.load(Parent.class, pid);
Child c = new Child();
c.setParent(p);
p.getChildren().add(c);
session.save(c);
session.flush();]]></programlisting>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD>ɂ<EFBFBD><C982><EFBFBD><EFBFBD>ASQL<51><4C> <literal>INSERT</literal> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>‚<EFBFBD><C282><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>s<EFBFBD><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɂȂ<C982><C882>܂<EFBFBD><DC82><EFBFBD><EFBFBD>I
</para>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɂ́A<literal>Parent</literal> <20><> <literal>addChild()</literal> <20><><EFBFBD>\<5C>b<EFBFBD>h<EFBFBD><68><EFBFBD><EFBFBD><EC90AC><EFBFBD>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[public void addChild(Child c) {
c.setParent(this);
children.add(c);
}]]></programlisting>
<para>
<literal>Child</literal> <20><><EFBFBD>lj<EFBFBD><C789><EFBFBD><EFBFBD><EFBFBD><EFBFBD>R<EFBFBD>[<5B>h<EFBFBD>͂<EFBFBD><CD82>̂悤<CC82>ɂȂ<C982><C882>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[Parent p = (Parent) session.load(Parent.class, pid);
Child c = new Child();
p.addChild(c);
session.save(c);
session.flush();]]></programlisting>
</sect1>
<sect1 id="example-parentchild-cascades">
<title><EFBFBD><EFBFBD><EFBFBD>C<EFBFBD>t<EFBFBD>T<EFBFBD>C<EFBFBD>N<EFBFBD><EFBFBD><EFBFBD>̃J<EFBFBD>X<EFBFBD>P<EFBFBD>[<5B>h</title>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD>I<EFBFBD><49> <literal>save()</literal> <20><><EFBFBD>R<EFBFBD>[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̂͂܂<CD82><DC82>ς킵<CF82><ED82B5><EFBFBD><EFBFBD><EFBFBD>̂ł<CC82><C582>B<EFBFBD><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>J<EFBFBD>X<EFBFBD>P<EFBFBD>[<5B>h<EFBFBD><68><EFBFBD>g<EFBFBD><67><EFBFBD>đΏ<C491><CE8F><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[<set name="children" inverse="true" cascade="all">
<key column="parent_id"/>
<one-to-many class="Child"/>
</set>]]></programlisting>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD>ɂ<EFBFBD><C982><EFBFBD><EFBFBD><EFBFBD><EFBFBD>قǂ̃R<CC83>[<5B>h<EFBFBD><68><EFBFBD><EFBFBD><EFBFBD>̂悤<CC82>ɒP<C992><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD>
</para>
<programlisting><![CDATA[Parent p = (Parent) session.load(Parent.class, pid);
Child c = new Child();
p.addChild(c);
session.flush();]]></programlisting>
<para>
<20><><EFBFBD>l<EFBFBD><6C> <literal>Parent</literal> <20><><EFBFBD>ۑ<EFBFBD><DB91>܂<EFBFBD><DC82>͍폜<CD8D><ED8F9C><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>ɁA<C981>q<EFBFBD><71><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˆ<EFBFBD><C288>Ž<EFBFBD><C28E><EFBFBD><EFBFBD>o<EFBFBD><6F><EFBFBD>Ĉ<EFBFBD><C488><EFBFBD><EFBFBD>K<EFBFBD>v<EFBFBD>͂<EFBFBD><CD82><EFBFBD><EFBFBD>܂<EFBFBD><DC82><EFBFBD><EFBFBD>B
<20>ȉ<EFBFBD><C889>̃R<CC83>[<5B>h<EFBFBD><68> <literal>p</literal> <20><><EFBFBD><EFBFBD><ED8F9C><EFBFBD>A<EFBFBD><41><EFBFBD><EFBFBD><EFBFBD>ăf<C483>[<5B>^<5E>x<EFBFBD>[<5B>X<EFBFBD><58><EFBFBD><EFBFBD>̎q<CC8E><71><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ׂč폜<C48D><ED8F9C><EFBFBD>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[Parent p = (Parent) session.load(Parent.class, pid);
session.delete(p);
session.flush();]]></programlisting>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̃R<CC83>[<5B>h<EFBFBD><68>
</para>
<programlisting><![CDATA[Parent p = (Parent) session.load(Parent.class, pid);
Child c = (Child) p.getChildren().iterator().next();
p.getChildren().remove(c);
c.setParent(null);
session.flush();]]></programlisting>
<para>
<20>f<EFBFBD>[<5B>^<5E>x<EFBFBD>[<5B>X<EFBFBD><58><EFBFBD><EFBFBD> <literal>c</literal> <20><><EFBFBD><EFBFBD><ED8F9C><EFBFBD>܂<EFBFBD><DC82><EFBFBD><EFBFBD>B<literal>p</literal> <20>ւ̃<D682><CC83><EFBFBD><EFBFBD>N<EFBFBD><4E><EFBFBD><EFBFBD><ED8F9C><EFBFBD><EFBFBD>
<20>i<EFBFBD><69><EFBFBD><EFBFBD><EFBFBD>Ă<EFBFBD><C482>̃P<CC83>[<5B>X<EFBFBD>ł<EFBFBD> <literal>NOT NULL</literal> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E194BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>N<EFBFBD><4E><EFBFBD><EFBFBD><EFBFBD>j<EFBFBD><6A><EFBFBD><EFBFBD><EFBFBD>ł<EFBFBD><C582>B
<literal>Child</literal> <20><> <literal>delete()</literal> <20>𖾎<EFBFBD><F096BE8E><EFBFBD><EFBFBD><EFBFBD><EFBFBD>K<EFBFBD>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[Parent p = (Parent) session.load(Parent.class, pid);
Child c = (Child) p.getChildren().iterator().next();
p.getChildren().remove(c);
session.delete(c);
session.flush();]]></programlisting>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD>̃P<CC83>[<5B>X<EFBFBD>ł͎<C582><CD8E>ۂ<EFBFBD> <literal>Child</literal> <20><><EFBFBD>e<EFBFBD>Ȃ<EFBFBD><C882>ł͑<C582><CD91>݂ł<DD82><C582>Ȃ<EFBFBD><C882><EFBFBD>ɂȂ<C982><C882>܂<EFBFBD><DC82><EFBFBD><EFBFBD>B
<20><><EFBFBD>̂<EFBFBD><CC82>߁A<DF81><41><EFBFBD><EFBFBD><EFBFBD>R<EFBFBD><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <literal>Child</literal> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E88F9C><EFBFBD><EFBFBD>A<EFBFBD><41><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><ED8F9C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ł<EFBFBD><C582>B
<20><><EFBFBD>̂<EFBFBD><CC82>߂ɂ<DF82> <literal>cascade="all-delete-orphan"</literal> <20><><EFBFBD>g<EFBFBD><67><EFBFBD>Ȃ<EFBFBD><C882><EFBFBD><EFBFBD>΂Ȃ<CE82><C882>܂<EFBFBD><DC82><EFBFBD><EFBFBD>B
</para>
<programlisting><![CDATA[<set name="children" inverse="true" cascade="all-delete-orphan">
<key column="parent_id"/>
<one-to-many class="Child"/>
</set>]]></programlisting>
<para>
<20><><EFBFBD>ӁF<D381>R<EFBFBD><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>̃}<7D>b<EFBFBD>s<EFBFBD><73><EFBFBD>O<EFBFBD><4F> <literal>inverse="true"</literal> <20>Ǝw<C68E><EFBFBD>Ă<EFBFBD><C482>A
<20>R<EFBFBD><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>̗v<CC97>f<EFBFBD>̃C<CC83>e<EFBFBD><65><EFBFBD>[<5B>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>ɂ<EFBFBD><C982><EFBFBD><EFBFBD>āA<C481>ˑR<CB91>J<EFBFBD>X<EFBFBD>P<EFBFBD>[<5B>h<EFBFBD><68><EFBFBD><EFBFBD><EFBFBD>s<EFBFBD><73><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
<20><><EFBFBD>̂<EFBFBD><CC82>߂<EFBFBD><DF82><EFBFBD><EFBFBD>J<EFBFBD>X<EFBFBD>P<EFBFBD>[<5B>h<EFBFBD>ŃI<C583>u<EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g<EFBFBD><67><EFBFBD>Z<EFBFBD>[<5B>u<EFBFBD>A<EFBFBD><EFBFBD>A<EFBFBD>X<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>K<EFBFBD>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȃ<EFBFBD><C882>A
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>R<EFBFBD><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>ɒlj<C992><C789><EFBFBD><EFBFBD>Ȃ<EFBFBD><C882><EFBFBD><EFBFBD>΂Ȃ<CE82><C882>܂<EFBFBD><DC82><EFBFBD><EFBFBD>B<EFBFBD>P<EFBFBD><50> <literal>setParent()</literal> <20><><EFBFBD>ĂԂ<C482><D482><EFBFBD><EFBFBD>ł͕s<CD95>\<5C><><EFBFBD>ł<EFBFBD><C582>B
</para>
</sect1>
<sect1 id="example-parentchild-update">
<title><EFBFBD>J<EFBFBD>X<EFBFBD>P<EFBFBD>[<5B>h<EFBFBD><68> <literal>unsaved-value</literal></title>
<para>
<literal>Parent</literal> <20><><EFBFBD>A<EFBFBD><41><EFBFBD><EFBFBD> <literal>Session</literal> <20>Ń<EFBFBD><C583>[<5B>h<EFBFBD><68><EFBFBD><EFBFBD><EFBFBD>AUI<55>̃A<CC83>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>ŕύX<CF8D><58><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A
<literal>update()</literal> <20><><EFBFBD>Ă<EFBFBD><C482>ł<EFBFBD><C582>̕ύX<CF8D><58><EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>Z<EFBFBD>b<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>ʼni<C589><69><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>܂<EFBFBD><DC82>B
<literal>Parent</literal> <20><><EFBFBD>q<EFBFBD><71><EFBFBD>̃R<CC83><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A<EFBFBD>J<EFBFBD>X<EFBFBD>P<EFBFBD>[<5B>h<EFBFBD>X<EFBFBD>V<EFBFBD><56><EFBFBD>L<EFBFBD><4C><EFBFBD>ɂȂ<C982><C882>Ă<EFBFBD><C482><EFBFBD>߁A
Hibernate<74>͂ǂ̎q<CC8E><71><EFBFBD><EFBFBD><EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><43><EFBFBD>X<EFBFBD>^<5E><><EFBFBD>X<EFBFBD><58><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EA82BD><EFBFBD>A<EFBFBD>ǂꂪ<C782>f<EFBFBD>[<5B>^<5E>x<EFBFBD>[<5B>X<EFBFBD>̊<EFBFBD><CC8A><EFBFBD><EFBFBD>̍s<CC8D>ɑ<EFBFBD><C991><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̂<EFBFBD><CC82><EFBFBD><EFBFBD>m<EFBFBD><6D><EFBFBD>K<EFBFBD>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
<literal>Parent</literal> <20><> <literal>Child</literal> <20>̗<EFBFBD><CC97><EFBFBD><EFBFBD><EFBFBD> <literal>java.lang.Long</literal>
<20>^<5E>̎<EFBFBD><CC8E>ʃv<CA83><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD>𐶐<EFBFBD><F090B690><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>܂<EFBFBD><DC82><EFBFBD>B
Hibernate<74>͂ǂ̎q<CC8E><71><EFBFBD><EFBFBD><EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̂<EFBFBD><CC82><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߂Ɏ<DF82><C98E>ʃv<CA83><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD>̒l<CC92><6C><EFBFBD>g<EFBFBD><67><EFBFBD>܂<EFBFBD>(version<6F><6E>timestamp<6D>v<EFBFBD><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD><42><EFBFBD>g<EFBFBD><67><EFBFBD>܂<EFBFBD><DC82>B
<xref linkend="manipulatingdata-updating-detached"/> <20>Q<EFBFBD><51>)<29>BHibernate3<65>ɂȂ<C982><C882>āA
<20><><EFBFBD><EFBFBD><EFBFBD>I<EFBFBD><49> <literal>unsaved-value</literal> <20><><EFBFBD>w<EFBFBD><EFBFBD><E882B7><EFBFBD>K<EFBFBD>v<EFBFBD>͂Ȃ<CD82><C882>Ȃ<EFBFBD><C882>܂<EFBFBD><DC82><EFBFBD><EFBFBD>B
</para>
<para>
<20>ȉ<EFBFBD><C889>̃R<CC83>[<5B>h<EFBFBD><68> <literal>parent</literal> <20><> <literal>child</literal> <20><><EFBFBD>X<EFBFBD>V<EFBFBD><56><EFBFBD>A<literal>newChild</literal> <20><><EFBFBD>}<7D><><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[//parent and child were both loaded in a previous session
//parent<6E><74>child<6C>͗<EFBFBD><CD97><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>A<EFBFBD>ȑO<C891><4F>Session<6F>Ń<EFBFBD><C583>[<5B>h<EFBFBD><68><EFBFBD><EFBFBD><EFBFBD>Ă<EFBFBD><C482>܂<EFBFBD>
parent.addChild(child);
Child newChild = new Child();
parent.addChild(newChild);
session.update(parent);
session.flush();]]></programlisting>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͐<EFBFBD><CD90><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EA82BD><EFBFBD>ʎq<CA8E>̏ꍇ<CC8F>ɂ͔<C982><CD94><EFBFBD><EFBFBD>ɗǂ<C997><C782>̂ł<CC82><C582><EFBFBD><EFBFBD>A<EFBFBD><41><EFBFBD><EFBFBD>Ă<EFBFBD><C482><EFBFBD><EA82BD><EFBFBD>ʎq<CA8E>ƕ<EFBFBD><C695><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʎq<CA8E>̏ꍇ<CC8F>͂ǂ<CD82><C782>ł<EFBFBD><C582><EFBFBD><E582A4><EFBFBD>H
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Hibernate<74><65><EFBFBD>A<EFBFBD>i<EFBFBD><69><EFBFBD>[<5B>U<EFBFBD>ɂ<EFBFBD><C982><EFBFBD><EFBFBD>Ă<EFBFBD><C482><EFBFBD><EA82BD><EFBFBD>ʎq<CA8E><71><EFBFBD><EFBFBD><EFBFBD>j<C281>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><43><EFBFBD>X<EFBFBD>^<5E><><EFBFBD>X<EFBFBD><58><EFBFBD><EFBFBD><EFBFBD><EFBFBD>I<EFBFBD>u<EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g<EFBFBD>ƁA
<20>ȑO<C891><4F>Session<6F>Ń<EFBFBD><C583>[<5B>h<EFBFBD><68><EFBFBD><EFBFBD>I<EFBFBD>u<EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>ʂł<CA82><C582>Ȃ<EFBFBD><C882><EFBFBD><EFBFBD>߁A<DF81><41><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EF82B5><EFBFBD>ł<EFBFBD><C582>B
<20><><EFBFBD>̏ꍇ<CC8F>AHibernate<74>̓^<5E>C<EFBFBD><43><EFBFBD>X<EFBFBD>^<5E><><EFBFBD>v<EFBFBD><76><EFBFBD>o<EFBFBD>[<5B>W<EFBFBD><57><EFBFBD><EFBFBD><EFBFBD>̃v<CC83><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD>̂ǂ<CC82><C782><EFBFBD><E782A9><EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>A<EFBFBD>񎟃L<F18E9F83><4C><EFBFBD>b<EFBFBD>V<EFBFBD><56><EFBFBD>ɖ₢<C996><E282A2><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
<20>ň<EFBFBD><C588>̏ꍇ<CC8F>A<EFBFBD>s<EFBFBD><73><EFBFBD><EFBFBD><EFBFBD>݂<EFBFBD><DD82><EFBFBD>ǂ<EFBFBD><C782><EFBFBD><EFBFBD>f<EFBFBD>[<5B>^<5E>x<EFBFBD>[<5B>X<EFBFBD><58><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
</para>
<!-- undocumenting
<para>
There is one further possibility. The <literal>Interceptor</literal> method named
<literal>isUnsaved()</literal> lets the application implement its own strategy for distinguishing
newly instantiated objects. For example, you could define a base class for your persistent classes.
</para>
<programlisting><![CDATA[public class Persistent {
private boolean _saved = false;
public void onSave() {
_saved=true;
}
public void onLoad() {
_saved=true;
}
......
public boolean isSaved() {
return _saved;
}
}]]></programlisting>
<para>
(The <literal>saved</literal> property is non-persistent.)
Now implement <literal>isUnsaved()</literal>, along with <literal>onLoad()</literal>
and <literal>onSave()</literal> as follows.
</para>
<programlisting><![CDATA[public Boolean isUnsaved(Object entity) {
if (entity instanceof Persistent) {
return new Boolean( !( (Persistent) entity ).isSaved() );
}
else {
return null;
}
}
public boolean onLoad(Object entity,
Serializable id,
Object[] state,
String[] propertyNames,
Type[] types) {
if (entity instanceof Persistent) ( (Persistent) entity ).onLoad();
return false;
}
public boolean onSave(Object entity,
Serializable id,
Object[] state,
String[] propertyNames,
Type[] types) {
if (entity instanceof Persistent) ( (Persistent) entity ).onSave();
return false;
}]]></programlisting>
<para>
Don't worry; in Hibernate3 you don't need to write any of this kind of code if you don't want to.
</para>
-->
</sect1>
<sect1 id="example-parentchild-conclusion">
<title><EFBFBD><EFBFBD><EFBFBD>_
</title>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD>ł͂<C582><CD82>Ȃ<EFBFBD><C882>̗ʂ<CC97><CA82>v<EFBFBD>񂵂<EFBFBD><F182B582>̂ŁA<C581>ŏ<EFBFBD><C58F>̍<EFBFBD><CC8D>͍<EFBFBD><CD8D><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ă<EFBFBD><C482><EFBFBD><EFBFBD><EFBFBD>Ɏv<C98E><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E982A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82><EFBFBD><EFBFBD>B
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ۂ́A<CD81><41><EFBFBD>ׂĔ<D782><C494><EFBFBD><EFBFBD>ɗǂ<C997><C782><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B<EFBFBD>قƂ<D982><C682>ǂ<EFBFBD>Hibernate<74>A<EFBFBD>v<EFBFBD><76><EFBFBD>P<EFBFBD>[<5B>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>ł́A<CD81><41><EFBFBD><EFBFBD><EFBFBD>̏<EFBFBD><CC8F>ʂŐe<C590>q<EFBFBD>p<EFBFBD>^<5E>[<5B><><EFBFBD><EFBFBD><EFBFBD>g<EFBFBD>p<EFBFBD><70><EFBFBD>܂<EFBFBD><DC82>B
</para>
<para>
<20>ŏ<EFBFBD><C58F>̒i<CC92><69><EFBFBD>ő<EFBFBD><C591>֕<EFBFBD><D695>@<40>ɂ‚<C982><C282>ĐG<C490><47><EFBFBD>܂<EFBFBD><DC82><EFBFBD><EFBFBD>B<EFBFBD><42><EFBFBD>L<EFBFBD>̂悤<CC82>Ȗ<EFBFBD><C896><EFBFBD><EFBFBD><EFBFBD> <literal>&lt;composite-element&gt;</literal> <20>}<7D>b<EFBFBD>s<EFBFBD><73><EFBFBD>O<EFBFBD>̏ꍇ<CC8F>͑<EFBFBD><CD91>݂<EFBFBD><DD82><EFBFBD><EFBFBD>A
<20>ɂ<EFBFBD><C982><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E782B8><EFBFBD><EFBFBD><EFBFBD>͊m<CD8A><6D><EFBFBD>ɐe<C990>q<EFBFBD>֌W<D68C>̃Z<CC83>}<7D><><EFBFBD>e<EFBFBD>B<EFBFBD>N<EFBFBD>X<EFBFBD><58><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>c<EFBFBD>O<EFBFBD>Ȃ<EFBFBD><C882><EFBFBD><EFBFBD>A<EFBFBD><41><EFBFBD><EFBFBD><EFBFBD>v<EFBFBD>f<EFBFBD>N<EFBFBD><4E><EFBFBD>X<EFBFBD>ɂ͓<C982><CD93>‚̑傫<CC91>Ȑ<EFBFBD><C890><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>F
1<>‚͕<C282><CD95><EFBFBD><EFBFBD>v<EFBFBD>f<EFBFBD>̓R<CD83><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>‚<EFBFBD><C282>Ƃ<EFBFBD><C682>ł<EFBFBD><C582>Ȃ<EFBFBD><C882><EFBFBD><EFBFBD>Ƃł<C682><C582>B<EFBFBD><42><EFBFBD><EFBFBD><EFBFBD>ЂƂ‚́A
<20><><EFBFBD>j<EFBFBD>[<5B>N<EFBFBD>Ȑe<C890>ł͂Ȃ<CD82><C882>G<EFBFBD><47><EFBFBD>e<EFBFBD>B<EFBFBD>e<EFBFBD>B<EFBFBD>̎q<CC8E><71><EFBFBD>ƂȂ<C682><C882>ׂ<EFBFBD><D782>ł͂Ȃ<CD82><C882>Ƃ<EFBFBD><C682><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƃł<C682>
</para>
</sect1>
</chapter>