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

1132 lines
45 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="Shift_JIS"?>
<chapter id="queryhql">
<title>HQL: The Hibernate Query Language</title>
<para>
Hibernate<74><65>SQL<51>ɔ<EFBFBD><C994><EFBFBD><EFBFBD>ɂ悭<C982><E682AD><EFBFBD><EFBFBD>(<28>Ӑ}<7D>I<EFBFBD>Ɏ<EFBFBD><C98E><EFBFBD><EFBFBD><EFBFBD>)<29><><EFBFBD>͂Ȗ₢<C896><E282A2><EFBFBD><EFBFBD><ED82B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ă<EFBFBD><C482>܂<EFBFBD><DC82>B
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SQL<51>Ɏ<EFBFBD><C98E><EFBFBD><EFBFBD>\<5C><><EFBFBD>ɘf<C998><EFBFBD><ED82B3><EFBFBD>Ȃ<EFBFBD><C882>ł<EFBFBD><C582><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>BHQL<51>͊<EFBFBD><CD8A>S<EFBFBD>ɃI<C983>u<EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g<EFBFBD>w<EFBFBD><77><EFBFBD>ł<EFBFBD><C582><EFBFBD><EFBFBD>A
<20>p<EFBFBD><70><EFBFBD>A<EFBFBD>|<7C><><EFBFBD><EFBFBD><EFBFBD>[<5B>t<EFBFBD>B<EFBFBD>Y<EFBFBD><59><EFBFBD>A<EFBFBD>֘A<D698>Ƃ<EFBFBD><C682><EFBFBD><EFBFBD><EFBFBD><EFBFBD>T<EFBFBD>O<EFBFBD>𗝉<EFBFBD><F0979D89><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
</para>
<sect1 id="queryhql-casesensitivity">
<title><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ə<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̋<EFBFBD><EFBFBD><EFBFBD></title>
<para>
<20>N<EFBFBD>G<EFBFBD><47><EFBFBD><EFBFBD>Java<76>̃N<CC83><4E><EFBFBD>X<EFBFBD><58><EFBFBD>ƃv<C683><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>đ啶<C491><E595B6><EFBFBD>A<EFBFBD><41><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʂ<EFBFBD><CA82>܂<EFBFBD><DC82><EFBFBD><EFBFBD>B
<20>]<5D><><EFBFBD><EFBFBD> <literal>SeLeCT</literal> <20><>
<literal>sELEct</literal> <20>Ɠ<EFBFBD><C693><EFBFBD><EFBFBD>ŁA<C581><41><EFBFBD><EFBFBD>
<literal>SELECT</literal> <20>Ƃ<EFBFBD><C682><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ł<EFBFBD><C582><EFBFBD>
<literal>net.sf.hibernate.eg.FOO</literal> <20><>
<literal>net.sf.hibernate.eg.Foo</literal> <20>Ƃ͈Ⴂ<CD88>A<EFBFBD><41><EFBFBD><EFBFBD>
<literal>foo.barSet</literal> <20><>
<literal>foo.BARSET</literal> <20>Ƃ<EFBFBD><C682><EFBFBD>܂<EFBFBD><DC82>B
</para>
<para>
<20><><EFBFBD>̃}<7D>j<EFBFBD><6A><EFBFBD>A<EFBFBD><41><EFBFBD>ł͏<C582><CD8F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>HQL<51>L<EFBFBD>[<5B><><EFBFBD>[<5B>h<EFBFBD><68><EFBFBD>g<EFBFBD>p<EFBFBD><70><EFBFBD>܂<EFBFBD><DC82>B
<20><EFBFBD><E595B6><EFBFBD>̃L<CC83>[<5B><><EFBFBD>[<5B>h<EFBFBD>̃N<CC83>G<EFBFBD><47><EFBFBD>̕<EFBFBD><CC95><EFBFBD><EFBFBD>ǂ݂₷<DD82><E282B7><EFBFBD>Ɗ<EFBFBD><C68A><EFBFBD><EFBFBD><EFBFBD>[<5B>U<EFBFBD>[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǝv<C68E><76><EFBFBD>܂<EFBFBD><DC82>B
<20>ł<EFBFBD><C582><EFBFBD><EFBFBD>AJava<76>R<EFBFBD>[<5B>h<EFBFBD><68><EFBFBD>ɖ<EFBFBD><C996>ߍ<EFBFBD><DF8D>܂<DC82>Ƃ<EFBFBD><C682>ɂ͌<C982><CD8C>Â炢<C382>Ǝv<C68E><76><EFBFBD>܂<EFBFBD><DC82>B
</para>
</sect1>
<sect1 id="queryhql-from">
<title>from<EFBFBD><EFBFBD></title>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>P<EFBFBD><50><EFBFBD><EFBFBD>Hibernate<74>N<EFBFBD>G<EFBFBD><47><EFBFBD>͎<EFBFBD><CD8E>̌`<60><><EFBFBD>ł<EFBFBD><C582>B
</para>
<programlisting><![CDATA[from eg.Cat]]></programlisting>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD>͒P<CD92><50><EFBFBD>Ɂ@<literal>eg.Cat</literal><EFBFBD>@<40>N<EFBFBD><4E><EFBFBD>X<EFBFBD>̃C<CC83><43><EFBFBD>X<EFBFBD>^<5E><><EFBFBD>X<EFBFBD><58><EFBFBD><EFBFBD><EFBFBD>ׂĕԂ<C495><D482>܂<EFBFBD><DC82>B
<20>K<EFBFBD><4B><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>N<EFBFBD><4E><EFBFBD>X<EFBFBD><58><EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>i<EFBFBD>N<EFBFBD><4E><EFBFBD>X<EFBFBD>Ƀp<C983>b<EFBFBD>P<EFBFBD>[<5B>W<EFBFBD><57><EFBFBD><EFBFBD><EFBFBD>t<EFBFBD><74><EFBFBD><EFBFBD><EFBFBD>j<EFBFBD>K<EFBFBD>v<EFBFBD>͂<EFBFBD><CD82><EFBFBD><EFBFBD>܂<EFBFBD><DC82><EFBFBD><EFBFBD>B
<20>Ƃ<EFBFBD><C682><EFBFBD><EFBFBD>̂<EFBFBD><CC82>A<literal>auto-import</literal> <20><><EFBFBD>f<EFBFBD>t<EFBFBD>H<EFBFBD><48><EFBFBD>g<EFBFBD>ɂȂ<C982><C882>Ă<EFBFBD><C482><EFBFBD><E982A9><EFBFBD>ł<EFBFBD><C582>B
<20><><EFBFBD>̂<EFBFBD><CC82>߂قƂ<D982><C682>ǂ̏ꍇ<CC8F>A<EFBFBD><41><EFBFBD>̂悤<CC82>ɏ<EFBFBD><C98F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŏ\<5C><><EFBFBD>ł<EFBFBD><C582>B
</para>
<programlisting><![CDATA[from Cat]]></programlisting>
<para>
<20>قƂ<D982><C682>ǂ̏ꍇ<CC8F>N<EFBFBD>G<EFBFBD><47><EFBFBD>̂ق<CC82><D982>̕<EFBFBD><CC95><EFBFBD><EFBFBD>Ł@<literal>Cat</literal><EFBFBD>@<40><><EFBFBD>Q<EFBFBD>Ƃ<EFBFBD><C682><EFBFBD><EFBFBD>̂ŁA<C581>ʖ<EFBFBD><CA96><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ă<EFBFBD><C482>K<EFBFBD>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ł<EFBFBD><C582><EFBFBD>B
</para>
<programlisting><![CDATA[from Cat as cat]]></programlisting>
<para>
<20><><EFBFBD>̃N<CC83>G<EFBFBD><47><EFBFBD>ł<EFBFBD> <literal>Cat</literal> <20>C<EFBFBD><43><EFBFBD>X<EFBFBD>^<5E><><EFBFBD>X<EFBFBD><58> <literal>cat</literal>
<20>Ƃ<EFBFBD><C682><EFBFBD><EFBFBD>ʖ<EFBFBD><CA96><EFBFBD><EFBFBD>t<EFBFBD><74><EFBFBD>Ă<EFBFBD><C482>܂<EFBFBD><DC82>B
<20><><EFBFBD>̂<EFBFBD><CC82>߁A<DF81><41><EFBFBD>ł<EFBFBD><C582>̃N<CC83>G<EFBFBD><47><EFBFBD><EFBFBD><EFBFBD>ŁA<C581><41><EFBFBD>̕ʖ<CC95><CA96><EFBFBD><EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>ł<EFBFBD><C582>܂<EFBFBD><DC82>B
<literal>as</literal> <20>L<EFBFBD>[<5B><><EFBFBD>[<5B>h<EFBFBD>̓I<CD83>v<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>ł<EFBFBD><C582>B<EFBFBD>‚܂<DC82>̂悤<CC82>ɏ<EFBFBD><C98F><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>ł<EFBFBD><C582>܂<EFBFBD><DC82>F
</para>
<programlisting><![CDATA[from Cat cat]]></programlisting>
<para>
<20><><EFBFBD>ρA<CF81><41><EFBFBD><EFBFBD>̓N<CD83><4E><EFBFBD>X<EFBFBD><58><EFBFBD><EFBFBD><EFBFBD>ɂ<EFBFBD><C982><EFBFBD><EFBFBD>đ<EFBFBD><C491><EFBFBD><EFBFBD>̃N<CC83><4E><EFBFBD>X<EFBFBD><58><EFBFBD>o<EFBFBD><6F><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[from Formula, Parameter]]></programlisting>
<programlisting><![CDATA[from Formula as form, Parameter as param]]></programlisting>
<para>
<20><><EFBFBD>[<5B>J<EFBFBD><4A><EFBFBD>ϐ<EFBFBD><CF90><EFBFBD>Java<76>̃l<CC83>[<5B>~<7E><><EFBFBD>O<EFBFBD><EFBFBD>ƈ<EFBFBD><C688>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD>A
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɏ<EFBFBD><C98F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>N<EFBFBD>G<EFBFBD><47><EFBFBD>̕ʖ<CC95><CA96><EFBFBD><EFBFBD>t<EFBFBD><74><EFBFBD><EFBFBD>Ƃ͂<C682><CD82><EFBFBD><EFBFBD>K<EFBFBD><4B><EFBFBD>ł<EFBFBD>(<28><EFBFBD><E182A6> <literal>domesticCat</literal> )<29>B
</para>
</sect1>
<sect1 id="queryhql-joins" revision="2">
<title><EFBFBD>֘A<EFBFBD>ƌ<EFBFBD><EFBFBD><EFBFBD></title>
<para>
<20>֘A<D698><41><EFBFBD><EFBFBD><EFBFBD>G<EFBFBD><47><EFBFBD>e<EFBFBD>B<EFBFBD>e<EFBFBD>B<EFBFBD><42><EFBFBD><EFBFBD>͒l<CD92>R<EFBFBD><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>̗v<CC97>f<EFBFBD>ɂ<EFBFBD><C982>A<literal><EFBFBD><EFBFBD><EFBFBD><EFBFBD></literal> <20><><EFBFBD>g<EFBFBD><67><EFBFBD>ĕʖ<C495><CA96><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ă邱<C482>Ƃ<EFBFBD><C682>o<EFBFBD><6F><EFBFBD>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[from Cat as cat
inner join cat.mate as mate
left outer join cat.kittens as kitten]]></programlisting>
<programlisting><![CDATA[from Cat as cat left join cat.mate.kittens as kittens]]></programlisting>
<programlisting><![CDATA[from Formula form full join form.parameter param]]></programlisting>
<para>
<20>T<EFBFBD>|<7C>[<5B>g<EFBFBD><67><EFBFBD>Ă<EFBFBD><C482><EFBFBD><E98C8B><EFBFBD>̃^<5E>C<EFBFBD>v<EFBFBD><76>ANSI SQL<51>Ɠ<EFBFBD><C693><EFBFBD><EFBFBD>ł<EFBFBD><C582>B
</para>
<itemizedlist spacing="compact">
<listitem>
<para>
<literal>inner join</literal>
</para>
</listitem>
<listitem>
<para>
<literal>left outer join</literal>
</para>
</listitem>
<listitem>
<para>
<literal>right outer join</literal>
</para>
</listitem>
<listitem>
<para>
<literal>full join</literal> (<28><><EFBFBD><EFBFBD><EFBFBD>Ă<EFBFBD><C482>̏ꍇ<CC8F>g<EFBFBD><67><EFBFBD>Â炢)
</para>
</listitem>
</itemizedlist>
<para>
<literal>inner join</literal><EFBFBD>A<literal>left outer join</literal><EFBFBD>A<literal>right outer join</literal><EFBFBD>ɂ͏ȗ<EFBFBD><EFBFBD>`<60><><EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>ł<EFBFBD><C582>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[from Cat as cat
join cat.mate as mate
left join cat.kittens as kitten]]></programlisting>
<para>
HQL<51><4C> <literal>with</literal> <20>L<EFBFBD>[<5B><><EFBFBD>[<5B>h<EFBFBD><68><EFBFBD>g<EFBFBD><67><EFBFBD>ƁA<C681><41><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>t<EFBFBD><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>ł<EFBFBD><C582>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[from Cat as cat
left join cat.kittens as kitten
with kitten.bodyWeight > 10.0]]></programlisting>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD>āA<C481>u<EFBFBD>t<EFBFBD>F<EFBFBD>b<EFBFBD>`<60>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD>͊֘A<D698><41><EFBFBD>l<EFBFBD>̃R<CC83><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>e<EFBFBD>I<EFBFBD>u<EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g<EFBFBD>ƈꏏ<C688><EA8F8F>1<EFBFBD>x<EFBFBD><78>select<63><74><EFBFBD>ŏ<EFBFBD><C58F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
<20><><EFBFBD><EFBFBD><EFBFBD>͓<EFBFBD><CD93>ɃR<C983><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>̏ꍇ<CC8F>ɗL<C997>p<EFBFBD>ł<EFBFBD><C582>B<EFBFBD><42><EFBFBD><EFBFBD><EFBFBD>͎<EFBFBD><CD8E><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A<EFBFBD>֘A<D698>ƃR<C683><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>ɑ΂<C991><CE82><EFBFBD><EFBFBD>}<7D>b<EFBFBD>s<EFBFBD><73><EFBFBD>O<EFBFBD><4F><EFBFBD>`<60>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD>̊O<CC8A><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lazy<7A><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̒<EFBFBD><CC92>`<60><><EFBFBD><EFBFBD><E38F91><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƂɂȂ<C982><C882>܂<EFBFBD><DC82>B
<xref linkend="performance-fetching"/> <20>ɂ<EFBFBD><C982><EFBFBD><E891BD><EFBFBD>̏<EFBFBD><CC8F>񂪂<EFBFBD><F182AA82><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[from Cat as cat
inner join fetch cat.mate
left join fetch cat.kittens]]></programlisting>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD>ɂ<EFBFBD><C982><EFBFBD><EFBFBD>t<EFBFBD>F<EFBFBD>b<EFBFBD>`<60>͊֘A<D698><41><EFBFBD><EFBFBD><EFBFBD>I<EFBFBD>u<EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g<EFBFBD><67> <literal>where</literal> <20><>(<28>܂<EFBFBD><DC82>͑<EFBFBD><CD91>̂ǂ<CC82><C782>Ȑ߂ł<DF82>)
<20>Ŏg<C58E><67><EFBFBD><EFBFBD><EFBFBD>Ă͂Ȃ<CD82><C882>Ȃ<EFBFBD><C882>̂ŁA<C581>ʏ<EFBFBD><CA8F>ʖ<EFBFBD><CA96><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ă<EFBFBD><C482>K<EFBFBD>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82><EFBFBD><EFBFBD>B<EFBFBD>܂<EFBFBD><DC82>֘A<D698>I<EFBFBD>u<EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g<EFBFBD>͖₢<CD96><E282A2><EFBFBD><EFBFBD><ED82B9><EFBFBD>ʂƂ<CA82><C682><EFBFBD>
<20><><EFBFBD>ڕԂ<DA95><D482><EFBFBD><EFBFBD>܂<EFBFBD><DC82><EFBFBD><EFBFBD>B<EFBFBD><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɐe<C990>I<EFBFBD>u<EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g<EFBFBD><67><EFBFBD>ʂ<EFBFBD><CA82>ăA<C483>N<EFBFBD>Z<EFBFBD>X<EFBFBD>ł<EFBFBD><C582>܂<EFBFBD><DC82>B
<20>R<EFBFBD><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ċA<C48B>I<EFBFBD>Ɍ<EFBFBD><C98C><EFBFBD><EFBFBD>t<EFBFBD>F<EFBFBD>b<EFBFBD>`<60><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̂݁A<DD81>ʖ<EFBFBD><CA96><EFBFBD><EFBFBD>K<EFBFBD>v<EFBFBD>ɂȂ<C982><C882>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[from Cat as cat
inner join fetch cat.mate
left join fetch cat.kittens child
left join fetch child.kittens]]></programlisting>
<para>
<literal>fetch</literal> <20>\<5C><><EFBFBD><EFBFBD> <literal>iterate()</literal>
<20><><EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>N<EFBFBD>G<EFBFBD><47><EFBFBD>Ăяo<D18F><6F><EFBFBD>Ŏg<C58E>p<EFBFBD>ł<EFBFBD><C582>Ȃ<EFBFBD><C882><EFBFBD><EFBFBD>Ƃɒ<C682><C992>ӂ<EFBFBD><D382>Ă<EFBFBD><C482><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<20>i<EFBFBD><69><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <literal>scroll()</literal> <20>͎g<CD8E>p<EFBFBD>ł<EFBFBD><C582>܂<EFBFBD><DC82>j<EFBFBD>B
<20>܂<EFBFBD><DC82>A<EFBFBD><41><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̑<EFBFBD><CC91><EFBFBD><EFBFBD>͌<EFBFBD><CD8C>ʂ̍s<CC8D>Ɋ<EFBFBD><C98A>Â<EFBFBD><C382>Ă<EFBFBD><C482><EFBFBD>߁A
<literal>fetch</literal> <20><> <literal>setMaxResults()</literal> <20><> <literal>setFirstResult()</literal>
<20>ƈꏏ<C688>Ɏg<C98E>p<EFBFBD><70><EFBFBD>ׂ<EFBFBD><D782>ł͂<C582><CD82><EFBFBD><EFBFBD>܂<EFBFBD><DC82><EFBFBD><EFBFBD>B
<20>ʏ<EFBFBD>eager<65>ȃR<C883><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>t<EFBFBD>F<EFBFBD>b<EFBFBD>`<60><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Əd<C68F><64><EFBFBD><EFBFBD><EFBFBD>o<EFBFBD>Ă<EFBFBD><C482>܂<EFBFBD><DC82><EFBFBD><EFBFBD>߁A<DF81><41><EFBFBD>Ȃ<EFBFBD><C882><EFBFBD><EFBFBD><EFBFBD><EFBFBD>҂<EFBFBD><D282><EFBFBD><EFBFBD><EFBFBD>ȍs<C88D><73><EFBFBD>ɂ͂Ȃ<CD82><C882>Ȃ<EFBFBD><C882>̂ł<CC82><C582>B
<20><><EFBFBD><EFBFBD><EFBFBD>Ă܂<C482> <literal>fetch</literal> <20>́A<CD81>A<EFBFBD>h<EFBFBD>z<EFBFBD>b<EFBFBD>N<EFBFBD><4E> <literal>with</literal> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<20><EFBFBD>Ɏg<C98E><67><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>ł<EFBFBD><C582>܂<EFBFBD><DC82><EFBFBD><EFBFBD>B
<20><><EFBFBD>‚̃N<CC83>G<EFBFBD><47><EFBFBD>ŕ<EFBFBD><C595><EFBFBD><EFBFBD>̃R<CC83><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>t<EFBFBD>F<EFBFBD>b<EFBFBD>`<60><><EFBFBD><EFBFBD>Ƃɂ<C682><C982><EFBFBD>ς<EFBFBD><CF82><EFBFBD>ł<EFBFBD><C582><EFBFBD><EFBFBD>̂ŁA<C581><41><EFBFBD>̏ꍇ<CC8F><EA8D87><EFBFBD>ӂ<EFBFBD><D382>Ă<EFBFBD><C482><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
<20>܂<EFBFBD><DC82>A<EFBFBD><41><EFBFBD><EFBFBD><EFBFBD>̃R<CC83><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>ɑ΂<C991><CE82><EFBFBD><E98C8B><EFBFBD>t<EFBFBD>F<EFBFBD>b<EFBFBD>`<60><>bag<61>}<7D>b<EFBFBD>s<EFBFBD><73><EFBFBD>O<EFBFBD>ɑ΂<C991><CE82>ė\<5C><><EFBFBD><EFBFBD><EFBFBD>ʌ<EFBFBD><CA8C>ʂ<EFBFBD><CA82><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E782B7><EFBFBD>Ƃ<EFBFBD><C682><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̂ŁA
<20><><EFBFBD>̏ꍇ<CC8F>̃N<CC83>G<EFBFBD><47><EFBFBD>̍쐬<CC8D>ɂ͒<C982><CD92>ӂ<EFBFBD><D382>Ă<EFBFBD><C482><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
<20>Ō<EFBFBD><C58C><EFBFBD> <literal><EFBFBD>S<EFBFBD>O<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɂ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>t<EFBFBD>F<EFBFBD>b<EFBFBD>`</literal> <20><>
<literal><EFBFBD>E<EFBFBD>O<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɂ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>t<EFBFBD>F<EFBFBD>b<EFBFBD>`</literal> <20>͗L<CD97>p<EFBFBD>ł͂Ȃ<CD82><C882><EFBFBD><EFBFBD>Ƃɒ<C682><C992>ӂ<EFBFBD><D382>Ă<EFBFBD><C482><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
</para>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD>v<EFBFBD><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD><42><EFBFBD>x<EFBFBD><78><EFBFBD>̒x<CC92><78><EFBFBD>t<EFBFBD>F<EFBFBD>b<EFBFBD>`<60><><EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD>i<EFBFBD><69><EFBFBD><EFBFBD><EFBFBD>I<EFBFBD>Ƀo<C983>C<EFBFBD>g<EFBFBD>R<EFBFBD>[<5B>h<EFBFBD><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>j<EFBFBD>A
<literal>fetch all properties</literal> <20><><EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD>
Hibernate<74>ɒx<C992><78><EFBFBD>v<EFBFBD><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD>𑬂₩<F091AC82>Ɂi<C981>ŏ<EFBFBD><C58F>̃N<CC83>G<EFBFBD><47><EFBFBD>Łj<C581>t<EFBFBD>F<EFBFBD>b<EFBFBD>`<60><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>ł<EFBFBD><C582>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[from Document fetch all properties order by name]]></programlisting>
<programlisting><![CDATA[from Document doc fetch all properties where lower(doc.name) like '%cats%']]></programlisting>
</sect1>
<sect1 id="queryhql-joins-forms">
<title><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\<5C><><EFBFBD>̌`<60><></title>
<para>
HQL<51>͂Q<CD82>‚̊֘A<D698><41><EFBFBD><EFBFBD><EFBFBD>`<60><><EFBFBD><EFBFBD><EFBFBD>T<EFBFBD>|<7C>[<5B>g<EFBFBD><67><EFBFBD>܂<EFBFBD><DC82>F<literal><EFBFBD>ÖٓI</literal> <20><> <literal><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>I</literal><EFBFBD>B
</para>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD>܂ł̃Z<CC83>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>ł<EFBFBD><C582><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>͂<EFBFBD><CD82>ׂ<EFBFBD> <literal><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>I<EFBFBD><EFBFBD></literal> <20>`<60><><EFBFBD>ŁA
from<6F>߂Ŗ<DF82><C596><EFBFBD><EFBFBD>I<EFBFBD><49>join<69>L<EFBFBD>[<5B><><EFBFBD>[<5B>h<EFBFBD><68><EFBFBD>g<EFBFBD><67><EFBFBD>Ă<EFBFBD><C482>܂<EFBFBD><DC82>B
<20><><EFBFBD>̌`<60><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߂<EFBFBD><DF82>܂<EFBFBD><DC82>B
</para>
<para>
<literal><EFBFBD>ÖٓI</literal> <20>t<EFBFBD>H<EFBFBD>[<5B><><EFBFBD>́Ajoin<69>L<EFBFBD>[<5B><><EFBFBD>[<5B>h<EFBFBD><68><EFBFBD>g<EFBFBD><67><EFBFBD>܂<EFBFBD><DC82><EFBFBD><EFBFBD>B<EFBFBD><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɁA<C981>Q<EFBFBD>Ƃ<EFBFBD><C682><EFBFBD><EFBFBD>֘A<D698><41>
<20>h<EFBFBD>b<EFBFBD>g<EFBFBD>\<5C>L<EFBFBD><4C><EFBFBD>g<EFBFBD><67><EFBFBD>܂<EFBFBD><DC82>B<literal><EFBFBD>ÖٓI</literal> <20><><EFBFBD><EFBFBD><EFBFBD>́A<CD81><41><EFBFBD>܂<EFBFBD><DC82>܂<EFBFBD>HQL<51>ɏo<C98F>Ă<EFBFBD><C482>܂<EFBFBD><DC82>B
<literal><EFBFBD>ÖٓI</literal> <20><><EFBFBD><EFBFBD><EFBFBD>̌<EFBFBD><CC8C>ʂ́ASQL<51>X<EFBFBD>e<EFBFBD>[<5B>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>g<EFBFBD>̓<EFBFBD><CC93><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʂł<CA82><C582>B
</para>
<programlisting><![CDATA[from Cat as cat where cat.mate.name like '%s%']]></programlisting>
</sect1>
<sect1 id="queryhql-select">
<title>Select<EFBFBD><EFBFBD></title>
<para>
<literal>select</literal> <20>߂͈ȉ<CD88><C889>̂悤<CC82>ɂǂ̃I<CC83>u<EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g<EFBFBD>Ƒ<EFBFBD><C691><EFBFBD><EFBFBD><EFBFBD><EFBFBD>N<EFBFBD>G<EFBFBD><47><EFBFBD><EFBFBD><EFBFBD>U<EFBFBD><55><EFBFBD>g<EFBFBD>Z<EFBFBD>b<EFBFBD>g<EFBFBD>ɕԂ<C995><D482><EFBFBD><EFBFBD><EFBFBD><EFBFBD>I<EFBFBD><49><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B:
</para>
<programlisting><![CDATA[select mate
from Cat as cat
inner join cat.mate as mate]]></programlisting>
<para>
<20><><EFBFBD>L<EFBFBD>̃N<CC83>G<EFBFBD><47><EFBFBD>͑<EFBFBD><CD91><EFBFBD> <literal>Cat</literal> <20><> <literal>mate</literal> <20><><EFBFBD>I<EFBFBD><49><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
<20><><EFBFBD>ۂɂ͎<C982><CD8E>̂悤<CC82>ɁA<C981><41><EFBFBD><EFBFBD><EFBFBD>Ȍ<EFBFBD><C88C>ɕ\<5C><><EFBFBD>ł<EFBFBD><C582>܂<EFBFBD><DC82>B:
</para>
<programlisting><![CDATA[select cat.mate from Cat cat]]></programlisting>
<para>
<20>N<EFBFBD>G<EFBFBD><47><EFBFBD>̓R<CD83><52><EFBFBD>|<7C>[<5B>l<EFBFBD><6C><EFBFBD>g<EFBFBD>^<5E>̃v<CC83><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD><42><EFBFBD>܂ށA<DE81><41><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>l<EFBFBD>^<5E>̃v<CC83><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD><42><EFBFBD>Ԃ<EFBFBD><D482>܂<EFBFBD><DC82>B:
</para>
<programlisting><![CDATA[select cat.name from DomesticCat cat
where cat.name like 'fri%']]></programlisting>
<programlisting><![CDATA[select cust.name.firstName from Customer as cust]]></programlisting>
<para>
<20>N<EFBFBD>G<EFBFBD><47><EFBFBD>͕<EFBFBD><CD95><EFBFBD><EFBFBD>̃I<CC83>u<EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g<EFBFBD><67>(<28>܂<EFBFBD><DC82><EFBFBD>)<29>v<EFBFBD><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD><42> <literal>Object[]</literal> <20>^<5E>̔z<CC94><7A><EFBFBD>Ƃ<EFBFBD><C682>ĕԂ<C495><D482>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[select mother, offspr, mate.name
from DomesticCat as mother
inner join mother.mate as mate
left outer join mother.kittens as offspr]]></programlisting>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <literal>List</literal> <20>Ƃ<EFBFBD><C682>āA
</para>
<programlisting><![CDATA[select new list(mother, offspr, mate.name)
from DomesticCat as mother
inner join mother.mate as mate
left outer join mother.kittens as offspr]]></programlisting>
<para>
<20>܂<EFBFBD><DC82>́A<CD81>^<5E>C<EFBFBD>v<EFBFBD>Z<EFBFBD>[<5B>t<EFBFBD><74>Java<76>I<EFBFBD>u<EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g<EFBFBD><67><EFBFBD>Ԃ<EFBFBD><D482>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[select new Family(mother, mate, offspr)
from DomesticCat as mother
join mother.mate as mate
left join mother.kittens as offspr]]></programlisting>
<para>
<20><><EFBFBD><EFBFBD><E982A2> <literal>Family</literal> <20>N<EFBFBD><4E><EFBFBD>X<EFBFBD><58><EFBFBD>K<EFBFBD>؂ȃR<C883><52><EFBFBD>X<EFBFBD>g<EFBFBD><67><EFBFBD>N<EFBFBD>^<5E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ă<EFBFBD><C482><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682><EFBFBD><EFBFBD>Ȃ<EFBFBD><C882>΁A
</para>
<para>
select<63>߂<EFBFBD> <literal>as</literal> <20><><EFBFBD>g<EFBFBD><67><EFBFBD>ĕʖ<C495><CA96><EFBFBD><EFBFBD>‚<EFBFBD><C282><EFBFBD>Ƃ<EFBFBD><C682>ł<EFBFBD><C582>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[select max(bodyWeight) as max, min(bodyWeight) as min, count(*) as n
from Cat cat]]></programlisting>
<para>
<literal>select new map</literal> <20>ƈꏏ<C688>Ɏg<C98E><67><EFBFBD>Ƃ<EFBFBD><C682>ɍł<C98D><C582>𗧂<EFBFBD><F097A782>܂<EFBFBD><DC82>F
</para>
<programlisting><![CDATA[select new map( max(bodyWeight) as max, min(bodyWeight) as min, count(*) as n )
from Cat cat]]></programlisting>
<para>
<20><><EFBFBD>̃N<CC83>G<EFBFBD><47><EFBFBD>͕ʖ<CD95><CA96><EFBFBD><EFBFBD><EFBFBD>select<63><74><EFBFBD><EFBFBD><EFBFBD>l<EFBFBD><6C> <literal>Map</literal> <20><><EFBFBD>Ԃ<EFBFBD><D482>܂<EFBFBD><DC82>B
</para>
</sect1>
<sect1 id="queryhql-aggregation">
<title><EFBFBD>W<EFBFBD><EFBFBD><EFBFBD>֐<EFBFBD></title>
<para>
HQL<51>̃N<CC83>G<EFBFBD><47><EFBFBD>̓v<CD83><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD>̏W<CC8F><57><EFBFBD>֐<EFBFBD><D690>̌<EFBFBD><CC8C>ʂ<EFBFBD><CA82>Ԃ<EFBFBD><D482>܂<EFBFBD><DC82>F
</para>
<programlisting><![CDATA[select avg(cat.weight), sum(cat.weight), max(cat.weight), count(cat)
from Cat cat]]></programlisting>
<!-- NO LONGER SUPPORTED
<para>
Collections may also appear inside aggregate functions in the <literal>select</literal>
clause.
</para>
<programlisting><![CDATA[select cat, count( elements(cat.kittens) )
from Cat cat group by cat]]></programlisting>
-->
<para>
<20>T<EFBFBD>|<7C>[<5B>g<EFBFBD><67><EFBFBD>Ă<EFBFBD><C482><EFBFBD><EFBFBD>W<EFBFBD><57><EFBFBD>֐<EFBFBD><D690>͈ȉ<CD88><C889>̂<EFBFBD><CC82>̂ł<CC82><C582>B
</para>
<itemizedlist spacing="compact">
<listitem>
<para>
<literal>avg(...), sum(...), min(...), max(...)</literal>
</para>
</listitem>
<listitem>
<para>
<literal>count(*)</literal>
</para>
</listitem>
<listitem>
<para>
<literal>count(...), count(distinct ...), count(all...)</literal>
</para>
</listitem>
</itemizedlist>
<para>
select<63>߂ɂ<DF82><C982><EFBFBD><EFBFBD>ĎZ<C48E>p<EFBFBD><70><EFBFBD><EFBFBD><EFBFBD>A<EFBFBD>A<EFBFBD><41><EFBFBD>Ə<EFBFBD><C68F>F<EFBFBD><46><EFBFBD>ꂽSQL<51>֐<EFBFBD><D690><EFBFBD><EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>ł<EFBFBD><C582>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[select cat.weight + sum(kitten.weight)
from Cat cat
join cat.kittens kitten
group by cat.id, cat.weight]]></programlisting>
<programlisting><![CDATA[select firstName||' '||initial||' '||upper(lastName) from Person]]></programlisting>
<para>
SQL<51>Ɠ<EFBFBD><C693><EFBFBD><EFBFBD>Ӗ<EFBFBD><D396><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <literal>distinct</literal> <20><> <literal>all</literal> <20>L<EFBFBD>[<5B><><EFBFBD>[<5B>h<EFBFBD><68><EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>ł<EFBFBD><C582>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[select distinct cat.name from Cat cat
select count(distinct cat.name), count(cat) from Cat cat]]></programlisting>
</sect1>
<sect1 id="queryhql-polymorphism">
<title><EFBFBD>|<7C><><EFBFBD><EFBFBD><EFBFBD>[<5B>t<EFBFBD>B<EFBFBD>b<EFBFBD>N<EFBFBD>ȃN<C883>G<EFBFBD><47></title>
<para>
<20><><EFBFBD>̂悤<CC82>ȃN<C883>G<EFBFBD><47><EFBFBD>F
</para>
<programlisting><![CDATA[from Cat as cat]]></programlisting>
<para>
<literal>Cat</literal> <20>C<EFBFBD><43><EFBFBD>X<EFBFBD>^<5E><><EFBFBD>X<EFBFBD><58><EFBFBD><EFBFBD><EFBFBD>ł͂Ȃ<CD82><C882>A<literal>DomesticCat</literal>
<20>̂悤<CC82>ȃT<C883>u<EFBFBD>N<EFBFBD><4E><EFBFBD>X<EFBFBD><58><EFBFBD>Ԃ<EFBFBD><D482><EFBFBD><EFBFBD>܂<EFBFBD><DC82>BHibernate<74>N<EFBFBD>G<EFBFBD><47><EFBFBD><EFBFBD> <emphasis><EFBFBD>ǂ<EFBFBD><EFBFBD><EFBFBD></emphasis>
Java<76>N<EFBFBD><4E><EFBFBD>X<EFBFBD><58><EFBFBD>C<EFBFBD><43><EFBFBD>^<5E>[<5B>t<EFBFBD>F<EFBFBD>C<EFBFBD>X<EFBFBD><58> <literal>from</literal> <20>߂ɓ<DF82><C993><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>ł<EFBFBD><C582>܂<EFBFBD><DC82>B
<20>N<EFBFBD>G<EFBFBD><47><EFBFBD>͂<EFBFBD><CD82>̃N<CC83><4E><EFBFBD>X<EFBFBD><58><EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A<EFBFBD><41><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̓C<CD83><43><EFBFBD>^<5E>[<5B>t<EFBFBD>F<EFBFBD>C<EFBFBD>X<EFBFBD><58><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>S<EFBFBD>Ẳi<CC89><69><EFBFBD>N<EFBFBD><4E><EFBFBD>X<EFBFBD><58><EFBFBD>Ԃ<EFBFBD><D482>܂<EFBFBD><DC82>B
<20><><EFBFBD>̃N<CC83>G<EFBFBD><47><EFBFBD>͉i<CD89><69><EFBFBD>I<EFBFBD>u<EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>ׂĕԂ<C495><D482>܂<EFBFBD>:
</para>
<programlisting><![CDATA[from java.lang.Object o]]></programlisting>
<para>
<literal>Named</literal> <20>C<EFBFBD><43><EFBFBD>^<5E>[<5B>t<EFBFBD>F<EFBFBD>C<EFBFBD>X<EFBFBD>͗l<CD97>X<EFBFBD>ȉi<C889><69><EFBFBD>N<EFBFBD><4E><EFBFBD>X<EFBFBD>ɂ<EFBFBD><C982><EFBFBD><EFBFBD>Ď<EFBFBD><C48E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B:
</para>
<programlisting><![CDATA[from Named n, Named m where n.name = m.name]]></programlisting>
<para>
<20>Ō<EFBFBD><C58C>̓<EFBFBD><CC93>‚̃N<CC83>G<EFBFBD><47><EFBFBD>́A<CD81><41><EFBFBD>ˆȏ<C288><C88F><EFBFBD>SQL <literal>SELECT</literal> <20><><EFBFBD>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD>Ă<EFBFBD><C482><EFBFBD>Ƃɒ<C682><C992>ӂ<EFBFBD><D382>Ă<EFBFBD><C482><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
<20><><EFBFBD>̂<EFBFBD><CC82>Ƃ<EFBFBD> <literal>order by</literal> <20>߂<EFBFBD><DF82><EFBFBD><EFBFBD>U<EFBFBD><55><EFBFBD>g<EFBFBD>Z<EFBFBD>b<EFBFBD>g<EFBFBD>S<EFBFBD>̂𐳊m<F090B38A>ɂ͐<C982><CD90>񂵂Ȃ<F182B582><C882><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>Ӗ<EFBFBD><D396><EFBFBD><EFBFBD>܂<EFBFBD>
(<28><><EFBFBD><EFBFBD><EFBFBD>ɂ<EFBFBD><C982><EFBFBD><EFBFBD>́A<literal>Query.scroll()</literal> <20><><EFBFBD>g<EFBFBD>p<EFBFBD><70><EFBFBD>Ă<EFBFBD><C482><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̃N<CC83>G<EFBFBD><47><EFBFBD><EFBFBD><EFBFBD>ĂԂ<C482><D482>Ƃ<EFBFBD><C682>ł<EFBFBD><C582>Ȃ<EFBFBD><C882><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>Ӗ<EFBFBD><D396><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B)<29>B
</para>
</sect1>
<sect1 id="queryhql-where">
<title>where<EFBFBD><EFBFBD></title>
<para>
<literal>where</literal> <20>߂͕Ԃ<CD95><D482><EFBFBD><EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><43><EFBFBD>X<EFBFBD>^<5E><><EFBFBD>X<EFBFBD>̃<EFBFBD><CC83>X<EFBFBD>g<EFBFBD><67><EFBFBD>i<EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>ł<EFBFBD><C582>܂<EFBFBD><DC82>B
<20><><EFBFBD><EFBFBD><EFBFBD>ʖ<EFBFBD><CA96><EFBFBD><EFBFBD>Ȃ<EFBFBD><C882><EFBFBD>A<EFBFBD><41><EFBFBD>O<EFBFBD>Ńv<C583><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD><42><EFBFBD>Q<EFBFBD>Ƃ<EFBFBD><C682>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[from Cat where name='Fritz']]></programlisting>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD>ʖ<EFBFBD><CA96><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A<EFBFBD>C<EFBFBD><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>g<EFBFBD><67><EFBFBD>Ă<EFBFBD><C482><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
</para>
<programlisting><![CDATA[from Cat as cat where cat.name='Fritz']]></programlisting>
<para>
<20><><EFBFBD>O<EFBFBD><4F>'Fritz'<27>Ƃ<EFBFBD><C682><EFBFBD> <literal>Cat</literal> <20>̃C<CC83><43><EFBFBD>X<EFBFBD>^<5E><><EFBFBD>X<EFBFBD><58><EFBFBD>Ԃ<EFBFBD><D482>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[select foo
from Foo foo, Bar bar
where foo.startDate = bar.date]]></programlisting>
<para>
<20><><EFBFBD><EFBFBD>HQL<51>́A<literal>Foo</literal> <20><> <literal>startDate</literal> <20>v<EFBFBD><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD>Ɠ<EFBFBD><C693><EFBFBD><EFBFBD><EFBFBD>
<literal>date</literal> <20>v<EFBFBD><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <literal>bar</literal> <20>C<EFBFBD><43><EFBFBD>X<EFBFBD>^<5E><><EFBFBD>X<EFBFBD><58><EFBFBD><EFBFBD><EFBFBD>݂<EFBFBD><DD82><EFBFBD><EFBFBD>A
<20><><EFBFBD>ׂĂ<D782> <literal>Foo</literal> <20>C<EFBFBD><43><EFBFBD>X<EFBFBD>^<5E><><EFBFBD>X<EFBFBD><58><EFBFBD>Ԃ<EFBFBD><D482>܂<EFBFBD><DC82>B
<20>R<EFBFBD><52><EFBFBD>p<EFBFBD>E<EFBFBD><45><EFBFBD>h<EFBFBD>p<EFBFBD>X<EFBFBD><58><EFBFBD>i<EFBFBD><EFBFBD>΁ucat.mate.name<6D>v<EFBFBD>j<EFBFBD><6A> <literal>where</literal> <20>߂<EFBFBD><DF82><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɋ<EFBFBD><C98B>͂ɂ<CD82><C982>܂<EFBFBD><DC82>B<EFBFBD><42><EFBFBD>ځF
</para>
<programlisting><![CDATA[from Cat cat where cat.mate.name is not null]]></programlisting>
<para>
<20><><EFBFBD>̃N<CC83>G<EFBFBD><47><EFBFBD>̓e<CD83>[<5B>u<EFBFBD><75><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>i<EFBFBD><69><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>j<EFBFBD><6A><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SQL<51>N<EFBFBD>G<EFBFBD><47><EFBFBD>ɕϊ<C995><CF8A><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
<20><><EFBFBD>̑<EFBFBD><CC91><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ɉȉ<C988><C889>̂悤<CC82>ɏ<EFBFBD><C98F><EFBFBD><EFBFBD>ƁA
</para>
<programlisting><![CDATA[from Foo foo
where foo.bar.baz.customer.address.city is not null]]></programlisting>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̃N<CC83>G<EFBFBD><47><EFBFBD><EFBFBD><EFBFBD>L<EFBFBD>q<EFBFBD><71><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>N<EFBFBD>G<EFBFBD><47><EFBFBD><EFBFBD><EFBFBD><EFBFBD>4<EFBFBD>‚̃e<CC83>[<5B>u<EFBFBD><75><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>K<EFBFBD>v<EFBFBD>Ƃ<EFBFBD><C682><EFBFBD>SQL<51>N<EFBFBD>G<EFBFBD><47><EFBFBD>ɕϊ<C995><CF8A><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
</para>
<para>
<literal>=</literal> <20><><EFBFBD>Z<EFBFBD>q<EFBFBD>͈ȉ<CD88><C889>̂悤<CC82>ɁA<C981>v<EFBFBD><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD><42><EFBFBD><EFBFBD><EFBFBD>łȂ<C582><C882>C<EFBFBD><43><EFBFBD>X<EFBFBD>^<5E><><EFBFBD>X<EFBFBD><58><EFBFBD><EFBFBD><EFBFBD>r<EFBFBD><72><EFBFBD><EFBFBD>߂ɂ<DF82><C982>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B<EFBFBD>F
</para>
<programlisting><![CDATA[from Cat cat, Cat rival where cat.mate = rival.mate]]></programlisting>
<programlisting><![CDATA[select cat, mate
from Cat cat, Cat mate
where cat.mate = mate]]></programlisting>
<para>
<literal>id</literal> (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<29>͓<EFBFBD><CD93>ʂȃv<C883><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD>ł<EFBFBD><C582><EFBFBD><EFBFBD>A
<20>I<EFBFBD>u<EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g<EFBFBD>̃<EFBFBD><CC83>j<EFBFBD>[<5B>N<EFBFBD>Ȏ<EFBFBD><C88E>ʎq<CA8E><71><EFBFBD>Q<EFBFBD>Ƃ<EFBFBD><C682><EFBFBD>߂Ɏg<C98E>p<EFBFBD>ł<EFBFBD><C582>܂<EFBFBD><DC82>B(<28><><EFBFBD><EFBFBD><EFBFBD>ɁA<C981><41><EFBFBD>̃v<CC83><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD><42><EFBFBD><EFBFBD><EFBFBD>g<EFBFBD>p<EFBFBD>ł<EFBFBD><C582>܂<EFBFBD><DC82>B)
</para>
<programlisting><![CDATA[from Cat as cat where cat.id = 123
from Cat as cat where cat.mate.id = 69]]></programlisting>
<para>
2<>Ԗڂ̃N<CC83>G<EFBFBD><47><EFBFBD>͌<EFBFBD><CD8C><EFBFBD><EFBFBD>I<EFBFBD>ł<EFBFBD><C582>B<EFBFBD>e<EFBFBD>[<5B>u<EFBFBD><75><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>K<EFBFBD>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82><EFBFBD><EFBFBD>I
</para>
<para>
<20>܂<EFBFBD><DC82><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʎq<CA8E>̃v<CC83><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD><42><EFBFBD>g<EFBFBD>p<EFBFBD>ł<EFBFBD><C582>܂<EFBFBD><DC82>B<EFBFBD><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <literal>Person</literal> <20><>
<literal>country</literal> <20><> <literal>medicareNumber</literal> <20><><EFBFBD><EFBFBD><EFBFBD>Ȃ镡<C882><E995A1><EFBFBD><EFBFBD><EFBFBD>ʎq<CA8E><71><EFBFBD><EFBFBD><EFBFBD>‚Ɖ<C282><C689><EFBFBD>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[from bank.Person person
where person.id.country = 'AU'
and person.id.medicareNumber = 123456]]></programlisting>
<programlisting><![CDATA[from bank.Account account
where account.owner.id.country = 'AU'
and account.owner.id.medicareNumber = 123456]]></programlisting>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>x<EFBFBD><78><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82><EFBFBD><EFBFBD>A2<41>Ԗڂ̃N<CC83>G<EFBFBD><47><EFBFBD>ɂ̓e<CD83>[<5B>u<EFBFBD><75><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>K<EFBFBD>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82><EFBFBD><EFBFBD>B
</para>
<para>
<20><><EFBFBD>l<EFBFBD><6C> <literal>class</literal> <20>͓<EFBFBD><CD93>ʂȃv<C883><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD>ł<EFBFBD><C582><EFBFBD><EFBFBD>A
<20>|<7C><><EFBFBD><EFBFBD><EFBFBD>[<5B>t<EFBFBD>B<EFBFBD>b<EFBFBD>N<EFBFBD>ȉi<C889><69><EFBFBD><EFBFBD><EFBFBD>ɂ<EFBFBD><C982><EFBFBD><EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><43><EFBFBD>X<EFBFBD>^<5E><><EFBFBD>X<EFBFBD><58>discriminator<6F>l<EFBFBD>ɃA<C983>N<EFBFBD>Z<EFBFBD>X<EFBFBD><58><EFBFBD>܂<EFBFBD><DC82>B
where<72>߂ɖ<DF82><C996>ߍ<EFBFBD><DF8D>܂ꂽJava<76>̃N<CC83><4E><EFBFBD>X<EFBFBD><58><EFBFBD>͂<EFBFBD><CD82><EFBFBD>discriminator<6F>l<EFBFBD>ɕϊ<C995><CF8A><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[from Cat cat where cat.class = DomesticCat]]></programlisting>
<para>
<20>܂<EFBFBD><DC82>R<EFBFBD><52><EFBFBD>|<7C>[<5B>l<EFBFBD><6C><EFBFBD>g<EFBFBD><EFBFBD><E295A1><EFBFBD><EFBFBD><EFBFBD>[<5B>U<EFBFBD>^(<28>܂<EFBFBD><DC82><EFBFBD><EFBFBD>̃R<CC83><52><EFBFBD>|<7C>[<5B>l<EFBFBD><6C><EFBFBD>g<EFBFBD>̃R<CC83><52><EFBFBD>|<7C>[<5B>l<EFBFBD><6C><EFBFBD>g<EFBFBD>Ȃ<EFBFBD>)<29>̃v<CC83><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD><42><EFBFBD>w<EFBFBD><77><EFBFBD>ł<EFBFBD><C582>܂<EFBFBD><DC82>B
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>āi<C481>R<EFBFBD><52><EFBFBD>|<7C>[<5B>l<EFBFBD><6C><EFBFBD>g<EFBFBD>̃v<CC83><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD>ł͂Ȃ<CD82><C882>j<EFBFBD>R<EFBFBD><52><EFBFBD>|<7C>[<5B>l<EFBFBD><6C><EFBFBD>g<EFBFBD>^<5E>̃v<CC83><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD>ŏI<C58F><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>p<EFBFBD>X<EFBFBD><58><EFBFBD><EFBFBD><EFBFBD>g<EFBFBD><67><EFBFBD>Ȃ<EFBFBD><C882>ł<EFBFBD><C582><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
<20><EFBFBD>΂<EFBFBD><CE82><EFBFBD> <literal>store.owner</literal> <20><> <literal>address</literal>
<20>R<EFBFBD><52><EFBFBD>|<7C>[<5B>l<EFBFBD><6C><EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>ƒG<C283><47><EFBFBD>e<EFBFBD>B<EFBFBD>e<EFBFBD>B<EFBFBD>Ȃ<EFBFBD><C882>Έȉ<CE88><C889>̂悤<CC82>Ȍ<EFBFBD><C88C>ʂƂȂ<C682><C882>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[store.owner.address.city // okay
store.owner.address // error!]]></programlisting>
<para>
"any"<22>^<5E>͓<EFBFBD><CD93>ʂȃv<C883><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD>ł<EFBFBD><C582><EFBFBD> <literal>id</literal> <20><> <literal>class</literal> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A
<20>ȉ<EFBFBD><C889>̕<EFBFBD><CC95>@<40>Ō<EFBFBD><C58C><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>”\<5C>ɂ<EFBFBD><C982>܂<EFBFBD>(<literal>AuditLog.item</literal> <20><>
<literal>&lt;any&gt;</literal> <20>Ń}<7D>b<EFBFBD>s<EFBFBD><73><EFBFBD>O<EFBFBD><4F><EFBFBD><EFBFBD>v<EFBFBD><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD>ł<EFBFBD>)<29>B
</para>
<programlisting><![CDATA[from AuditLog log, Payment payment
where log.item.class = 'Payment' and log.item.id = payment.id]]></programlisting>
<para>
<literal>log.item.class</literal> <20><> <literal>payment.class</literal> <20><>
<20><><EFBFBD>L<EFBFBD>̃N<CC83>G<EFBFBD><47><EFBFBD><EFBFBD><EFBFBD>őS<C591><53><EFBFBD>قȂ<D982><C882>f<EFBFBD>[<5B>^<5E>x<EFBFBD>[<5B>X<EFBFBD>J<EFBFBD><4A><EFBFBD><EFBFBD><EFBFBD>̒l<CC92><6C><EFBFBD>Q<EFBFBD>Ƃ<EFBFBD><C682><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƃɒ<C682><C992>ӂ<EFBFBD><D382>Ă<EFBFBD><C482><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
</para>
</sect1>
<sect1 id="queryhql-expressions">
<title>Expressions <20><></title>
<para>
SQL<51><4C> <literal>where</literal> <20>߂ŋL<C58B>q<EFBFBD><71><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>o<EFBFBD><6F><EFBFBD><EFBFBD>̂قƂ<D982><C682>ǂ<EFBFBD>HQL<51>ł<EFBFBD><C582>L<EFBFBD>q<EFBFBD>ł<EFBFBD><C582>܂<EFBFBD><DC82>B:
</para>
<itemizedlist spacing="compact">
<listitem>
<para>
<20>Z<EFBFBD>p<EFBFBD><70><EFBFBD>Z<EFBFBD>q<EFBFBD>F<literal>+, -, *, /</literal>
</para>
</listitem>
<listitem>
<para>
2<><32><EFBFBD><EFBFBD><EFBFBD>r<EFBFBD><72><EFBFBD>Z<EFBFBD>q<EFBFBD>F<literal>=, &gt;=, &lt;=, &lt;&gt;, !=, like</literal>
</para>
</listitem>
<listitem>
<para>
<20>_<EFBFBD><5F><EFBFBD><EFBFBD><EFBFBD>Z<EFBFBD>q<EFBFBD>F<literal>and, or, not</literal>
</para>
</listitem>
<listitem>
<para>
<20>O<EFBFBD><4F><EFBFBD>[<5B>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\<5C><><EFBFBD><EFBFBD><EFBFBD>ʁF<literal>( )</literal>
</para>
</listitem>
<listitem>
<para>
<literal>in</literal>,
<literal>not in</literal>,
<literal>between</literal>,
<literal>is null</literal>,
<literal>is not null</literal>,
<literal>is empty</literal>,
<literal>is not empty</literal>,
<literal>member of</literal> and
<literal>not member of</literal>
</para>
</listitem>
<listitem>
<para>
"<22>V<EFBFBD><56><EFBFBD>v<EFBFBD><76>"<22><>case <literal>case ... when ... then ... else ... end</literal><EFBFBD>A
"<22>T<EFBFBD><54><EFBFBD>I"<22><>case <literal>case when ... then ... else ... end</literal>
</para>
</listitem>
<listitem>
<para>
<20>X<EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>O<EFBFBD>̘A<CC98><41> <literal>...||...</literal> <20>܂<EFBFBD><DC82><EFBFBD> <literal>concat(...,...)</literal>
</para>
</listitem>
<listitem>
<para>
<literal>current_date()</literal>, <literal>current_time()</literal>,
<literal>current_timestamp()</literal>
</para>
</listitem>
<listitem>
<para>
<literal>second(...)</literal>, <literal>minute(...)</literal>,
<literal>hour(...)</literal>, <literal>day(...)</literal>,
<literal>month(...)</literal>, <literal>year(...)</literal>,
</para>
</listitem>
<listitem>
<para>
EJB-QL 3.0<EFBFBD>Œ<EFBFBD><EFBFBD>`<60><><EFBFBD><EFBFBD><EFBFBD>Ă<EFBFBD><C482><EFBFBD><EFBFBD>֐<EFBFBD><D690><EFBFBD>Z<EFBFBD>q: <literal>substring(), trim(),
lower(), upper(), length(), locate(), abs(), sqrt(), bit_length()</literal>
</para>
</listitem>
<listitem>
<para>
<literal>coalesce()</literal> <20><> <literal>nullif()</literal>
</para>
</listitem>
<listitem>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԃ̒l<CC92><6C>String<6E>ɃR<C983><52><EFBFBD>o<EFBFBD>[<5B>g<EFBFBD><67><EFBFBD><EFBFBD> <literal>str()</literal><EFBFBD>j
</para>
</listitem>
<listitem>
<para>
2<>Ԗڂ̈<DA82><CC88><EFBFBD><EFBFBD><EFBFBD>Hibernate<74>^<5E>̖<EFBFBD><CC96>O<EFBFBD>ł<EFBFBD><C582><EFBFBD> <literal>cast(... as ...)</literal> <20><>
<literal>extract(... from ...)</literal><EFBFBD>B
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>g<EFBFBD>p<EFBFBD><70><EFBFBD><EFBFBD><EFBFBD>f<EFBFBD>[<5B>^<5E>x<EFBFBD>[<5B>X<EFBFBD><58>ANSI <literal>cast()</literal> <20><> <literal>extract()</literal>
<20><><EFBFBD>T<EFBFBD>|<7C>[<5B>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ɍ<EFBFBD><C98C><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
</para>
</listitem>
<listitem>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><43><EFBFBD>f<EFBFBD>b<EFBFBD>N<EFBFBD>X<EFBFBD>t<EFBFBD><74><EFBFBD>̃R<CC83><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>̕ʖ<CC95><CA96>ɓK<C993>p<EFBFBD><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD>HQL<51><4C>
<literal>index()</literal> <20>֐<EFBFBD><D690>B
</para>
</listitem>
<listitem>
<para>
<20>R<EFBFBD><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>l<EFBFBD>̃p<CC83>X<EFBFBD><58><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>HQL<51>֐<EFBFBD><D690>F <literal>size(), minelement(), maxelement(),
minindex(), maxindex()</literal> <20>B
<literal>some, all, exists, any, in</literal> <20><><EFBFBD>g<EFBFBD><67><EFBFBD>ďC<C48F><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>ł<EFBFBD><C582><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʂ<EFBFBD>
<literal>elements()</literal> <20><> <literal>indices</literal> <20>֐<EFBFBD><D690>ƈꏏ<C688>Ɏg<C98E><67><EFBFBD>܂<EFBFBD><DC82>B
</para>
</listitem>
<listitem>
<para>
<literal>sign()</literal>, <literal>trunc()</literal>, <literal>rtrim()</literal>, <literal>sin()</literal>
<20>̂悤<CC82>ȃf<C883>[<5B>^<5E>x<EFBFBD>[<5B>X<EFBFBD><58><EFBFBD>T<EFBFBD>|<7C>[<5B>g<EFBFBD><67><EFBFBD><EFBFBD>SQL<51>X<EFBFBD>J<EFBFBD><4A><EFBFBD>֐<EFBFBD><D690>B
</para>
</listitem>
<listitem>
<para>
JDBC<42>X<EFBFBD>^<5E>C<EFBFBD><43><EFBFBD>̈ʒu<CA92>p<EFBFBD><70><EFBFBD><EFBFBD><EFBFBD>[<5B>^ <literal>?</literal>
</para>
</listitem>
<listitem>
<para>
<20><><EFBFBD>O<EFBFBD>t<EFBFBD><74><EFBFBD>p<EFBFBD><70><EFBFBD><EFBFBD><EFBFBD>[<5B>^: <literal>:name</literal>, <literal>:start_date</literal>, <literal>:x1</literal>
</para>
</listitem>
<listitem>
<para>
SQL<51><4C><EFBFBD>e<EFBFBD><65><EFBFBD><EFBFBD><EFBFBD>F<literal>'foo'</literal>, <literal>69</literal>, <literal>6.66E+2</literal>,
<literal>'1970-01-01 10:00:01.0'</literal>
</para>
</listitem>
<listitem>
<para>
Java<76><61> <literal>public static final</literal> <20><EFBFBD>F<literal>eg.Color.TABBY</literal>
</para>
</listitem>
</itemizedlist>
<para>
<literal>in</literal> <20><> <literal>between</literal> <20>͈ȉ<CD88><C889>̂悤<CC82>Ɏg<C98E>p<EFBFBD>ł<EFBFBD><C582>܂<EFBFBD><DC82>B:
</para>
<programlisting><![CDATA[from DomesticCat cat where cat.name between 'A' and 'B']]></programlisting>
<programlisting><![CDATA[from DomesticCat cat where cat.name in ( 'Foo', 'Bar', 'Baz' )]]></programlisting>
<para>
<20>܂<EFBFBD><DC82>A<EFBFBD>ے<EFBFBD><DB92>`<60>ŋL<C58B>q<EFBFBD><71><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>ł<EFBFBD><C582>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[from DomesticCat cat where cat.name not between 'A' and 'B']]></programlisting>
<programlisting><![CDATA[from DomesticCat cat where cat.name not in ( 'Foo', 'Bar', 'Baz' )]]></programlisting>
<para>
<20><><EFBFBD>l<EFBFBD><6C> <literal>is null</literal> <20><> <literal>is not null</literal> <20><>null<6C>l<EFBFBD><6C><EFBFBD>e<EFBFBD>X<EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD>߂Ɏg<C98E>p<EFBFBD>ł<EFBFBD><C582>܂<EFBFBD><DC82>B
</para>
<para>
Hibernate<74>ݒ<EFBFBD><DD92>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD><EFBFBD>HQL query substitutions<6E><73><EFBFBD><EFBFBD><EFBFBD>`<60><><EFBFBD><EFBFBD><EFBFBD>΁Aboolean<61>l<EFBFBD><6C><EFBFBD><EFBFBD><EFBFBD>̒<EFBFBD><CC92>ŊȒP<C892>Ɏg<C98E>p<EFBFBD>ł<EFBFBD><C582>܁B<DC81>F
</para>
<programlisting><![CDATA[<property name="hibernate.query.substitutions">true 1, false 0</property>]]></programlisting>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƃʼn<C682><C589>L<EFBFBD><4C>HQL<51><4C>SQL<51>ɕϊ<C995><CF8A><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682><EFBFBD> <literal>true</literal> ,
<literal>false</literal> <20>L<EFBFBD>[<5B><><EFBFBD>[<5B>h<EFBFBD><68> <literal>1</literal> , <literal>0</literal> <20>ɒu<C992><75><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B:
</para>
<programlisting><![CDATA[from Cat cat where cat.alive = true]]></programlisting>
<para>
<20><><EFBFBD>ʂȃv<C883><76><EFBFBD>p<EFBFBD>e<EFBFBD>B <literal>size</literal><EFBFBD>A<EFBFBD>܂<EFBFBD><EFBFBD>͓<EFBFBD><EFBFBD>ʂȊ֐<EFBFBD> <literal>size()</literal>
<20><><EFBFBD>g<EFBFBD><67><EFBFBD>ăR<C483><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>̃T<CC83>C<EFBFBD>Y<EFBFBD><59><EFBFBD>e<EFBFBD>X<EFBFBD>g<EFBFBD>ł<EFBFBD><C582>܂<EFBFBD><DC82>B:
</para>
<programlisting><![CDATA[from Cat cat where cat.kittens.size > 0]]></programlisting>
<programlisting><![CDATA[from Cat cat where size(cat.kittens) > 0]]></programlisting>
<para>
<20>C<EFBFBD><43><EFBFBD>f<EFBFBD>b<EFBFBD>N<EFBFBD>X<EFBFBD>t<EFBFBD><74><EFBFBD>̃R<CC83><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>ł́A<literal>minindex</literal> <20><> <literal>maxindex</literal>
<20>֐<EFBFBD><D690><EFBFBD><EFBFBD>g<EFBFBD><67><EFBFBD>āA<C481>C<EFBFBD><43><EFBFBD>f<EFBFBD>b<EFBFBD>N<EFBFBD>X<EFBFBD>̍ŏ<CC8D><C58F>l<EFBFBD>ƍő<C68D><C591>l<EFBFBD><6C><EFBFBD>Q<EFBFBD>Ƃł<C682><C582>܂<EFBFBD><DC82>B
<20><><EFBFBD>l<EFBFBD>ɁA<literal>minelement</literal> <20><> <literal>maxelement</literal> <20><><EFBFBD>g<EFBFBD><67><EFBFBD>āA
<20><><EFBFBD>{<7B>^<5E>̃R<CC83><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>v<EFBFBD>f<EFBFBD>̍ŏ<CC8D><C58F>l<EFBFBD>ƍő<C68D><C591>l<EFBFBD><6C><EFBFBD>Q<EFBFBD>Ƃł<C682><C582>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[from Calendar cal where maxelement(cal.holidays) > current_date]]></programlisting>
<programlisting><![CDATA[from Order order where maxindex(order.items) > 100]]></programlisting>
<programlisting><![CDATA[from Order order where minelement(order.items) > 10000]]></programlisting>
<para>
<20>R<EFBFBD><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>̗v<CC97>f<EFBFBD><66><EFBFBD>C<EFBFBD><43><EFBFBD>f<EFBFBD>b<EFBFBD>N<EFBFBD>X<EFBFBD>̃Z<CC83>b<EFBFBD>g<EFBFBD>i<literal>elements</literal> <20><> <literal>indices</literal>
<20>֐<EFBFBD><D690>j<EFBFBD>A<EFBFBD>܂<EFBFBD><DC82>͕<EFBFBD><CD95><EFBFBD><E282A2><EFBFBD><EFBFBD>i<EFBFBD><69><EFBFBD>q<EFBFBD>j<EFBFBD>̌<EFBFBD><CC8C>ʂ<EFBFBD><CA82>󂯎<EFBFBD><F382AF8E><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>́A
SQL<51>֐<EFBFBD> <literal>any, some, all, exists, in</literal> <20><><EFBFBD>T<EFBFBD>|<7C>[<5B>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[select mother from Cat as mother, Cat as kit
where kit in elements(foo.kittens)]]></programlisting>
<programlisting><![CDATA[select p from NameList list, Person p
where p.name = some elements(list.names)]]></programlisting>
<programlisting><![CDATA[from Cat cat where exists elements(cat.kittens)]]></programlisting>
<programlisting><![CDATA[from Player p where 3 > all elements(p.scores)]]></programlisting>
<programlisting><![CDATA[from Show show where 'fizard' in indices(show.acts)]]></programlisting>
<para>
<literal>size</literal>, <literal>elements</literal>, <literal>indices</literal>,
<literal>minindex</literal>, <literal>maxindex</literal>, <literal>minelement</literal>,
<literal>maxelement</literal> <20><>Hibernate3<65><33>where<72>߂<EFBFBD><DF82><EFBFBD><EFBFBD>ŗ<EFBFBD><C597>p<EFBFBD>”\<5C>ł<EFBFBD><C582><EFBFBD>Ƃɒ<C682><C992>ӂ<EFBFBD><D382>Ă<EFBFBD><C482><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
</para>
<para>
<20>C<EFBFBD><43><EFBFBD>f<EFBFBD>b<EFBFBD>N<EFBFBD>X<EFBFBD>t<EFBFBD><74><EFBFBD>̃R<CC83><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>iarrays, lists, maps<70>j<EFBFBD>̗v<CC97>f<EFBFBD>́A
<20>C<EFBFBD><43><EFBFBD>f<EFBFBD>b<EFBFBD>N<EFBFBD>X<EFBFBD>ŎQ<C58E>Ƃł<C682><C582>܂<EFBFBD><DC82>iwhere<72>ߓ<EFBFBD><DF93>ł̂݁j<DD81>B
</para>
<programlisting><![CDATA[from Order order where order.items[0].id = 1234]]></programlisting>
<programlisting><![CDATA[select person from Person person, Calendar calendar
where calendar.holidays['national day'] = person.birthDay
and person.nationality.calendar = calendar]]></programlisting>
<programlisting><![CDATA[select item from Item item, Order order
where order.items[ order.deliveredItemIndices[0] ] = item and order.id = 11]]></programlisting>
<programlisting><![CDATA[select item from Item item, Order order
where order.items[ maxindex(order.items) ] = item and order.id = 11]]></programlisting>
<para>
<literal>[]</literal> <20><><EFBFBD><EFBFBD><EFBFBD>̎<EFBFBD><CC8E>́A<CD81>Z<EFBFBD>p<EFBFBD><70><EFBFBD>ł<EFBFBD><C582>\<5C><><EFBFBD>܂<EFBFBD><DC82><EFBFBD><EFBFBD>B
</para>
<programlisting><![CDATA[select item from Item item, Order order
where order.items[ size(order.items) - 1 ] = item]]></programlisting>
<para>
<20><><EFBFBD>Α<EFBFBD><CE91>֘A<D698><41><EFBFBD>l<EFBFBD>̃R<CC83><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>̗v<CC97>f<EFBFBD>ɑ΂<C991><CE82>ẮAHQL<51>͑g<CD91>ݍ<EFBFBD><DD8D>݂<EFBFBD> <literal>index()</literal> <20>֐<EFBFBD><D690><EFBFBD><EFBFBD>p<EFBFBD>ӂ<EFBFBD><D382>Ă<EFBFBD><C482>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[select item, index(item) from Order order
join order.items item
where index(item) < 5]]></programlisting>
<para>
<20>x<EFBFBD>[<5B>X<EFBFBD>ƂȂ<C682><C882>f<EFBFBD>[<5B>^<5E>x<EFBFBD>[<5B>X<EFBFBD><58><EFBFBD>T<EFBFBD>|<7C>[<5B>g<EFBFBD><67><EFBFBD>Ă<EFBFBD><C482><EFBFBD><EFBFBD>X<EFBFBD>J<EFBFBD><4A><EFBFBD>[SQL<51>֐<EFBFBD><D690><EFBFBD><EFBFBD>g<EFBFBD>p<EFBFBD>ł<EFBFBD><C582>܂<EFBFBD>
</para>
<programlisting><![CDATA[from DomesticCat cat where upper(cat.name) like 'FRI%']]></programlisting>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>S<EFBFBD>Ă𗝉<C482><F0979D89><EFBFBD><EFBFBD>Ă<EFBFBD><C482>Ȃ<EFBFBD><C882>Ȃ<EFBFBD><C882>A<EFBFBD><41><EFBFBD>̃N<CC83>G<EFBFBD><47><EFBFBD><EFBFBD>SQL<51>łǂꂾ<C782><EA82BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A<EFBFBD>ǂ݂Â炭<C382>o<EFBFBD><6F><EFBFBD><EFBFBD>l<EFBFBD><6C><EFBFBD>Ă<EFBFBD><C482><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B:
</para>
<programlisting><![CDATA[select cust
from Product prod,
Store store
inner join store.customers cust
where prod.name = 'widget'
and store.location.name in ( 'Melbourne', 'Sydney' )
and prod = all elements(cust.currentOrder.lineItems)]]></programlisting>
<para>
<emphasis><EFBFBD>q<EFBFBD><EFBFBD><EFBFBD>g:</emphasis> <20><EFBFBD>΂<EFBFBD><CE82>̂悤<CC82>ɏo<C98F><6F><EFBFBD>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[SELECT cust.name, cust.address, cust.phone, cust.id, cust.current_order
FROM customers cust,
stores store,
locations loc,
store_customers sc,
product prod
WHERE prod.name = 'widget'
AND store.loc_id = loc.id
AND loc.name IN ( 'Melbourne', 'Sydney' )
AND sc.store_id = store.id
AND sc.cust_id = cust.id
AND prod.id = ALL(
SELECT item.prod_id
FROM line_items item, orders o
WHERE item.order_id = o.id
AND cust.current_order = o.id
)]]></programlisting>
</sect1>
<sect1 id="queryhql-ordering">
<title>order by<62><79></title>
<para>
<20>N<EFBFBD>G<EFBFBD><47><EFBFBD><EFBFBD><EFBFBD>Ԃ<EFBFBD>list<73>́A<CD81>Ԃ<EFBFBD><D482><EFBFBD><EFBFBD><EFBFBD><EFBFBD>N<EFBFBD><4E><EFBFBD>X<EFBFBD><58><EFBFBD>R<EFBFBD><52><EFBFBD>|<7C>[<5B>l<EFBFBD><6C><EFBFBD>g<EFBFBD>̔C<CC94>ӂ̑<D382><CC91><EFBFBD><EFBFBD>ɂ<EFBFBD><C982><EFBFBD><EFBFBD>ĕ<EFBFBD><C495>בւ<D791><D682><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B<EFBFBD>F
</para>
<programlisting><![CDATA[from DomesticCat cat
order by cat.name asc, cat.weight desc, cat.birthdate]]></programlisting>
<para>
<20>I<EFBFBD>v<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <literal>asc</literal> <20><> <literal>desc</literal> <20>͂<EFBFBD><CD82><EFBFBD><EFBFBD><EA8FB8><EFBFBD><EFBFBD><EFBFBD>~<7E><><EFBFBD>̐<EFBFBD><CC90><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
</para>
</sect1>
<sect1 id="queryhql-grouping">
<title>group by<62><79></title>
<para>
<20>W<EFBFBD><57><EFBFBD>l<EFBFBD><6C><EFBFBD>Ԃ<EFBFBD><D482>N<EFBFBD>G<EFBFBD><47><EFBFBD>́A<CD81>Ԃ<EFBFBD><D482><EFBFBD><EFBFBD><EFBFBD><EFBFBD>N<EFBFBD><4E><EFBFBD>X<EFBFBD><58><EFBFBD>R<EFBFBD><52><EFBFBD>|<7C>[<5B>l<EFBFBD><6C><EFBFBD>g<EFBFBD>̔C<CC94>ӂ̃v<CC83><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD>ɂ<EFBFBD><C982><EFBFBD><EFBFBD>ăO<C483><4F><EFBFBD>[<5B>v<EFBFBD><76><EFBFBD>ł<EFBFBD><C582>܂<EFBFBD><DC82>B:
</para>
<programlisting><![CDATA[select cat.color, sum(cat.weight), count(cat)
from Cat cat
group by cat.color]]></programlisting>
<programlisting><![CDATA[select foo.id, avg(name), max(name)
from Foo foo join foo.names name
group by foo.id]]></programlisting>
<para>
<literal>having</literal> <20>߂<EFBFBD><DF82>g<EFBFBD><67><EFBFBD>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[select cat.color, sum(cat.weight), count(cat)
from Cat cat
group by cat.color
having cat.color in (eg.Color.TABBY, eg.Color.BLACK)]]></programlisting>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD>g<EFBFBD>p<EFBFBD><70><EFBFBD><EFBFBD><EFBFBD>f<EFBFBD>[<5B>^<5E>x<EFBFBD>[<5B>X<EFBFBD><58><EFBFBD>T<EFBFBD>|<7C>[<5B>g<EFBFBD><67><EFBFBD>Ă<EFBFBD><C482><EFBFBD><EFBFBD>Ȃ<EFBFBD><C882>A
<literal>having</literal> <20><> <literal>order by</literal> <20>߂<EFBFBD>SQL<51>֐<EFBFBD><D690>ƏW<C68F><57><EFBFBD>֐<EFBFBD><D690><EFBFBD><EFBFBD>g<EFBFBD><67><EFBFBD>܂<EFBFBD>
<20>i<EFBFBD><EFBFBD><E182A6>MySQL<51>ɂ͂<C982><CD82><EFBFBD><EFBFBD>܂<EFBFBD><DC82><EFBFBD><EFBFBD>j<EFBFBD>B
</para>
<programlisting><![CDATA[select cat
from Cat cat
join cat.kittens kitten
group by cat
having avg(kitten.weight) > 100
order by count(kitten) asc, sum(kitten.weight) desc]]></programlisting>
<para>
<literal>group by</literal> <20>߂<EFBFBD> <literal>order by</literal> <20>߂<EFBFBD>
<20>Z<EFBFBD>p<EFBFBD><70><EFBFBD><EFBFBD><EFBFBD>܂ނ<DC82><DE82>Ƃ<EFBFBD><C682>ł<EFBFBD><C582>Ȃ<EFBFBD><C882><EFBFBD><EFBFBD>Ƃɒ<C682><C992>ӂ<EFBFBD><D382>Ă<EFBFBD><C482><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
</para>
</sect1>
<sect1 id="queryhql-subqueries" revision="2">
<title><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></title>
<para>
<20>T<EFBFBD>u<EFBFBD>Z<EFBFBD><5A><EFBFBD>N<EFBFBD>g<EFBFBD><67><EFBFBD>T<EFBFBD>|<7C>[<5B>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>f<EFBFBD>[<5B>^<5E>x<EFBFBD>[<5B>X<EFBFBD>̂<EFBFBD><CC82>߁AHibernate<74>͕<EFBFBD><CD95><EFBFBD><E282A2><EFBFBD><EFBFBD><ED82B9><EFBFBD>T<EFBFBD>|<7C>[<5B>g<EFBFBD><67><EFBFBD>Ă<EFBFBD><C482>܂<EFBFBD><DC82>B
<20><><EFBFBD><EFBFBD><E282A2><EFBFBD><EFBFBD>͊<EFBFBD><CD8A>ʂň͂܂Ȃ<DC82><C882><EFBFBD><EFBFBD>΂Ȃ<CE82><C882>܂<EFBFBD><DC82><EFBFBD><EFBFBD>iSQL<51>̏W<CC8F><57><EFBFBD>֐<EFBFBD><D690>Ăяo<D18F><6F><EFBFBD>ɂ<EFBFBD><C982><EFBFBD><E98E96><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ł<EFBFBD><C582>j<EFBFBD>B
<20>֘A<D698><41><EFBFBD><EFBFBD><E282A2><EFBFBD>킹(<28>O<EFBFBD><4F><EFBFBD>N<EFBFBD>G<EFBFBD><47><EFBFBD><EFBFBD><EFBFBD>̕ʖ<CC95><CA96><EFBFBD><EFBFBD>Q<EFBFBD>Ƃ<EFBFBD><C682><EFBFBD><EFBFBD><E282A2><EFBFBD><EFBFBD>̂<EFBFBD><CC82><EFBFBD>)<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>‚<EFBFBD><C282><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[from Cat as fatcat
where fatcat.weight > (
select avg(cat.weight) from DomesticCat cat
)]]></programlisting>
<programlisting><![CDATA[from DomesticCat as cat
where cat.name = some (
select name.nickName from Name as name
)]]></programlisting>
<programlisting><![CDATA[from Cat as cat
where not exists (
from Cat as mate where mate.mate = cat
)]]></programlisting>
<programlisting><![CDATA[from DomesticCat as cat
where cat.name not in (
select name.nickName from Name as name
)]]></programlisting>
<programlisting><![CDATA[select cat.id, (select max(kit.weight) from cat.kitten kit)
from Cat as cat]]></programlisting>
<para>
HQL<51><4C><EFBFBD><EFBFBD><E282A2><EFBFBD><EFBFBD>́Aselect<63>܂<EFBFBD><DC82><EFBFBD>where<72>߂<EFBFBD><DF82><EFBFBD><EFBFBD>Ŏg<C58E><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƃɒ<C682><C992>ӂ<EFBFBD><D382>Ă<EFBFBD><C482><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
</para>
<para>
select<63><74><EFBFBD>X<EFBFBD>g<EFBFBD>ɕ<EFBFBD><C995><EFBFBD><EFBFBD>̎<EFBFBD><CC8E><EFBFBD><EFBFBD><EFBFBD><EFBFBD>•<EFBFBD><C295><EFBFBD><E282A2><EFBFBD><EFBFBD>ɂ́A<CD81>^<5E>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>ł<EFBFBD><C582>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[from Cat as cat
where not ( cat.name, cat.color ) in (
select cat.name, cat.color from DomesticCat cat
)]]></programlisting>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD>‚<EFBFBD><C282>̃f<CC83>[<5B>^<5E>x<EFBFBD>[<5B>X<EFBFBD>iOracle<6C><65>HSQL<51>ɂ͂<C982><CD82><EFBFBD><EFBFBD>܂<EFBFBD><DC82><EFBFBD><EFBFBD>j<EFBFBD>ł́A
<20><><EFBFBD>̃R<CC83><52><EFBFBD>e<EFBFBD>L<EFBFBD>X<EFBFBD>g<EFBFBD>ł<EFBFBD><C582>^<5E>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD>g<EFBFBD><67><EFBFBD>܂<EFBFBD><DC82>B
<20><EFBFBD>΁A<CE81>N<EFBFBD>G<EFBFBD><47><EFBFBD>R<EFBFBD><52><EFBFBD>|<7C>[<5B>l<EFBFBD><6C><EFBFBD>g<EFBFBD><EFBFBD><E295A1><EFBFBD><EFBFBD><EFBFBD>[<5B>U<EFBFBD>^<5E>ɂ<EFBFBD><C982><EFBFBD><EFBFBD>Ăł<C482><C582>B
</para>
<programlisting><![CDATA[from Person where name = ('Gavin', 'A', 'King')]]></programlisting>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD>ł<EFBFBD><C582><EFBFBD><EFBFBD>A<EFBFBD><41><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȃN<C883>G<EFBFBD><47><EFBFBD>ł<EFBFBD><C582>F
</para>
<programlisting><![CDATA[from Person where name.first = 'Gavin' and name.initial = 'A' and name.last = 'King')]]></programlisting>
<para>
<20><><EFBFBD>̂悤<CC82>Ȃ<EFBFBD><C882>Ƃ<EFBFBD><C682><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȃ<EFBFBD><C882>̂ɂ<CC82>2<EFBFBD>‚̗<C282><CC97>R<EFBFBD><52><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>F
1<>–ڂ́A<CD81>f<EFBFBD>[<5B>^<5E>x<EFBFBD>[<5B>X<EFBFBD>v<EFBFBD><76><EFBFBD>b<EFBFBD>g<EFBFBD>t<EFBFBD>H<EFBFBD>[<5B><><EFBFBD>ԂŊ<D482><C58A>S<EFBFBD>Ȍ݊<C88C><DD8A><EFBFBD><EFBFBD>͂Ȃ<CD82><C882><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ł<EFBFBD><C582>B
2<>–ڂ́A<CD81>N<EFBFBD>G<EFBFBD><47><EFBFBD><EFBFBD><EFBFBD>}<7D>b<EFBFBD>s<EFBFBD><73><EFBFBD>O<EFBFBD>h<EFBFBD>L<EFBFBD><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>g<EFBFBD>̃v<CC83><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD>̏<EFBFBD><CC8F><EFBFBD><EFBFBD>Ɉˑ<C988><CB91><EFBFBD><EFBFBD><EFBFBD><E982A9><EFBFBD>ł<EFBFBD><C582>B
</para>
</sect1>
<sect1 id="queryhql-examples">
<title>HQL<EFBFBD>̗<EFBFBD></title>
<para>
Hibernate<74>N<EFBFBD>G<EFBFBD><47><EFBFBD>͔<EFBFBD><CD94><EFBFBD><EFBFBD>ɋ<EFBFBD><C98B>͂ŕ<CD82><C595>G<EFBFBD>ɂł<C982><C582>܂<EFBFBD><DC82>B<EFBFBD><42><EFBFBD>ہA<DB81>N<EFBFBD>G<EFBFBD><47><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̈З͂<D097>Hibernate<74>̎<EFBFBD><CC8E>v<EFBFBD>ȃZ<C883>[<5B><><EFBFBD>X<EFBFBD>|<7C>C<EFBFBD><43><EFBFBD>g<EFBFBD>̈<EFBFBD><CC88>‚ł<C282><C582>B
<20><><EFBFBD><EFBFBD><EFBFBD>ɍŋ߂̃v<CC83><76><EFBFBD>W<EFBFBD>F<EFBFBD>N<EFBFBD>g<EFBFBD>Ŏg<C58E>p<EFBFBD><70><EFBFBD><EFBFBD><EFBFBD>N<EFBFBD>G<EFBFBD><47><EFBFBD>Ɣ<EFBFBD><C694><EFBFBD><EFBFBD>ɂ悭<C982><E682AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E182AA><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
<20>قƂ<D982><C682>ǂ̃N<CC83>G<EFBFBD><47><EFBFBD>͂<EFBFBD><CD82><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̗<EFBFBD><CC97><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȒP<C892>ɋL<C98B>q<EFBFBD>ł<EFBFBD><C582><EFBFBD>Ƃɒ<C682><C992>ӂ<EFBFBD><D382>Ă<EFBFBD><C482><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!
</para>
<para>
<20>ȉ<EFBFBD><C889>̃N<CC83>G<EFBFBD><47><EFBFBD>͓<EFBFBD><CD93><EFBFBD><EFBFBD>̌ڋq<DA8B>Ɨ^<5E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŏ<EFBFBD><C58F>̍<EFBFBD><CC8D>v<EFBFBD>l<EFBFBD>ɑ΂<C991><CE82><EFBFBD><E996A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̒<EFBFBD><CC92><EFBFBD>ID<49>A
<20><><EFBFBD>i<EFBFBD>̐<EFBFBD><CC90>A<EFBFBD><41><EFBFBD><EFBFBD><EFBFBD>̍<EFBFBD><CC8D>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD>v<EFBFBD>l<EFBFBD>Ő<EFBFBD><C590>񂵂ĕԂ<C495><D482>܂<EFBFBD><DC82>B
<20><><EFBFBD>i<EFBFBD><69><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E882B7><EFBFBD>ہA<DB81><41><EFBFBD>݂̃J<CC83>^<5E><><EFBFBD>O<EFBFBD><4F><EFBFBD>g<EFBFBD><67><EFBFBD>܂<EFBFBD><DC82>B<EFBFBD><42><EFBFBD>ʂƂ<CA82><C682>ĕԂ<C495><D482><EFBFBD><EFBFBD><EFBFBD>SQL<51>N<EFBFBD>G<EFBFBD><47><EFBFBD><EFBFBD>
<literal>ORDER</literal>, <literal>ORDER_LINE</literal>, <literal>PRODUCT</literal>,
<literal>CATALOG</literal> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <literal>PRICE</literal> <20>e<EFBFBD>[<5B>u<EFBFBD><75><EFBFBD>ɑ΂<C991>4<EFBFBD>‚̓<C282><CC93><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
(<28>֘A<D698><41><EFBFBD>Ȃ<EFBFBD>)<29><><EFBFBD><EFBFBD><E282A2><EFBFBD><EFBFBD><ED82B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[select order.id, sum(price.amount), count(item)
from Order as order
join order.lineItems as item
join item.product as product,
Catalog as catalog
join catalog.prices as price
where order.paid = false
and order.customer = :customer
and price.product = product
and catalog.effectiveDate < sysdate
and catalog.effectiveDate >= all (
select cat.effectiveDate
from Catalog as cat
where cat.effectiveDate < sysdate
)
group by order
having sum(price.amount) > :minAmount
order by sum(price.amount) desc]]></programlisting>
<para>
<20><><EFBFBD>ċ<EFBFBD><C48B><EFBFBD><EFBFBD>ȃN<C883>G<EFBFBD><47><EFBFBD>Ȃ̂ł<CC82><C582>傤! <20><><EFBFBD>i<EFBFBD><69><EFBFBD>͕<EFBFBD><CD95><EFBFBD><E282A2><EFBFBD><EFBFBD><ED82B9><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>g<EFBFBD><67><EFBFBD>܂<EFBFBD><DC82><EFBFBD><EFBFBD>B<EFBFBD><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ď<EFBFBD><C48E>̃N<CC83>G<EFBFBD><47><EFBFBD>͎<EFBFBD><CD8E>ۂɂ͈ȉ<CD88><C889>̂悤<CC82>ɂȂ<C982><C882>܂<EFBFBD><DC82>B:
</para>
<programlisting><![CDATA[select order.id, sum(price.amount), count(item)
from Order as order
join order.lineItems as item
join item.product as product,
Catalog as catalog
join catalog.prices as price
where order.paid = false
and order.customer = :customer
and price.product = product
and catalog = :currentCatalog
group by order
having sum(price.amount) > :minAmount
order by sum(price.amount) desc]]></programlisting>
<para>
<20><><EFBFBD>̃N<CC83>G<EFBFBD><47><EFBFBD>͊e<CD8A>X<EFBFBD>e<EFBFBD>[<5B>^<5E>X<EFBFBD>̎x<CC8E><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>𐔂<EFBFBD><F0909482>܂<EFBFBD><DC82>B<EFBFBD><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ׂĂ̎x<CC8E><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>݂̗<DD82><CC97>p<EFBFBD>҂ɂ<D282><C982><EFBFBD>
<20>ŐV<C590>̃X<CC83>e<EFBFBD>[<5B>^<5E>X<EFBFBD>ύX<CF8D>ł<EFBFBD><C582><EFBFBD> <literal>AWAITING_APPROVAL</literal> <20>ł<EFBFBD><C582><EFBFBD><EFBFBD><EFBFBD><EA8D87><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
<20><><EFBFBD>̃N<CC83>G<EFBFBD><47><EFBFBD><EFBFBD>2<EFBFBD>‚̓<C282><CC93><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <literal>PAYMENT</literal>, <literal>PAYMENT_STATUS</literal> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<literal>PAYMENT_STATUS_CHANGE</literal> <20>e<EFBFBD>[<5B>u<EFBFBD><75><EFBFBD>ɑ΂<C991><CE82><EFBFBD><EFBFBD>֘A<D698><41><EFBFBD><EFBFBD><E282A2><EFBFBD><EFBFBD><ED82B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SQL<51>N<EFBFBD>G<EFBFBD><47><EFBFBD>ɕϊ<C995><CF8A><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[select count(payment), status.name
from Payment as payment
join payment.currentStatus as status
join payment.statusChanges as statusChange
where payment.status.name <> PaymentStatus.AWAITING_APPROVAL
or (
statusChange.timeStamp = (
select max(change.timeStamp)
from PaymentStatusChange change
where change.payment = payment
)
and statusChange.user <> :currentUser
)
group by status.name, status.sortOrder
order by status.sortOrder]]></programlisting>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>set<65>̑<EFBFBD><CC91><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>list<73>Ƃ<EFBFBD><C682><EFBFBD> <literal>statusChanges</literal> <20>R<EFBFBD><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<20>}<7D>b<EFBFBD>s<EFBFBD><73><EFBFBD>O<EFBFBD><4F><EFBFBD><EFBFBD><EFBFBD>Ȃ<EFBFBD><C882>΁A<CE81>͂邩<CD82>ɊȒP<C892>ɃN<C983>G<EFBFBD><47><EFBFBD><EFBFBD><EFBFBD>L<EFBFBD>q<EFBFBD>ł<EFBFBD><C582><EFBFBD><EFBFBD>ł<EFBFBD><C582><EFBFBD>B
</para>
<programlisting><![CDATA[select count(payment), status.name
from Payment as payment
join payment.currentStatus as status
where payment.status.name <> PaymentStatus.AWAITING_APPROVAL
or payment.statusChanges[ maxIndex(payment.statusChanges) ].user <> :currentUser
group by status.name, status.sortOrder
order by status.sortOrder]]></programlisting>
<para>
<20><><EFBFBD>̃N<CC83>G<EFBFBD><47><EFBFBD>͌<EFBFBD><CD8C>݂̃<DD82><CC83>[<5B>U<EFBFBD><55><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>g<EFBFBD>D<EFBFBD>ɑ΂<C991><CE82><EFBFBD><EFBFBD>A<EFBFBD>J<EFBFBD>E<EFBFBD><45><EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>і<EFBFBD><D196><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̎x<CC8E><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<20><><EFBFBD>ׂĕԂ<C495>MS SQL Server
<20><> <literal>isNull()</literal> <20>֐<EFBFBD><D690><EFBFBD><EFBFBD>g<EFBFBD>p<EFBFBD><70><EFBFBD>Ă<EFBFBD><C482>܂<EFBFBD><DC82>B
<20><><EFBFBD>̃N<CC83>G<EFBFBD><47><EFBFBD><EFBFBD>3<EFBFBD>‚̓<C282><CC93><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD>‚̊O<CC8A><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>A
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <literal>ACCOUNT</literal>, <literal>PAYMENT</literal>, <literal>PAYMENT_STATUS</literal>,
<literal>ACCOUNT_TYPE</literal>, <literal>ORGANIZATION</literal> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<literal>ORG_USER</literal> <20>e<EFBFBD>[<5B>u<EFBFBD><75><EFBFBD>ɑ΂<C991><CE82><EFBFBD><EFBFBD><E282A2><EFBFBD><EFBFBD><ED82B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SQL<51>ɕϊ<C995><CF8A><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[select account, payment
from Account as account
left outer join account.payments as payment
where :currentUser in elements(account.holder.users)
and PaymentStatus.UNPAID = isNull(payment.currentStatus.name, PaymentStatus.UNPAID)
order by account.type.sortOrder, account.accountNumber, payment.dueDate]]></programlisting>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD>‚<EFBFBD><C282>̃f<CC83>[<5B>^<5E>x<EFBFBD>[<5B>X<EFBFBD>ɂ‚<C982><C282>ẮA(<28>֘A<D698><41><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ꂽ)<29><><EFBFBD><EFBFBD><E282A2><EFBFBD><EFBFBD>̎g<CC8E>p<EFBFBD><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>K<EFBFBD>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ł<EFBFBD><C582><EFBFBD>B
</para>
<programlisting><![CDATA[select account, payment
from Account as account
join account.holder.users as user
left outer join account.payments as payment
where :currentUser = user
and PaymentStatus.UNPAID = isNull(payment.currentStatus.name, PaymentStatus.UNPAID)
order by account.type.sortOrder, account.accountNumber, payment.dueDate]]></programlisting>
</sect1>
<sect1 id="queryhql-bulk" revision="2">
<title><EFBFBD><EFBFBD><EFBFBD>ʂ<EFBFBD>UPDATE<EFBFBD><EFBFBD>DELETE</title>
<para>
HQL<51>͍<EFBFBD><CD8D><EFBFBD> <literal>update</literal> <20><> <literal>delete</literal><EFBFBD>A<literal>insert ... select ...</literal>
<20>X<EFBFBD>e<EFBFBD>[<5B>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>g<EFBFBD><67>HQL<51>ɓ<EFBFBD><C993><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>T<EFBFBD>|<7C>[<5B>g<EFBFBD><67><EFBFBD>Ă<EFBFBD><C482>܂<EFBFBD><DC82>B
<xref linkend="batch-direct"/> <20>ɏڍׂ<DA8D><D782><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
</para>
</sect1>
<sect1 id="queryhql-tipstricks">
<title>Tips &amp; Tricks</title>
<para>
<20><><EFBFBD>ۂɌ<DB82><C98C>ʂ<EFBFBD><CA82>Ԃ<EFBFBD><D482>Ȃ<EFBFBD><C882>Ă<EFBFBD><C482>N<EFBFBD>G<EFBFBD><47><EFBFBD>̌<EFBFBD><CC8C>ʐ<EFBFBD><CA90>𐔂<EFBFBD><F0909482><EFBFBD>Ƃ<EFBFBD><C682>ł<EFBFBD><C582>܂<EFBFBD><DC82>B:
</para>
<programlisting><![CDATA[( (Integer) session.iterate("select count(*) from ....").next() ).intValue()]]></programlisting>
<para>
<20>R<EFBFBD><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>̃T<CC83>C<EFBFBD>Y<EFBFBD>ɂ<EFBFBD><C982><EFBFBD>ʂ<EFBFBD><CA82><EFBFBD><EFBFBD>בւ<D791><D682><EFBFBD>߂ɂ͈ȉ<CD88><C889>̃N<CC83>G<EFBFBD><47><EFBFBD><EFBFBD><EFBFBD>g<EFBFBD>p<EFBFBD><70><EFBFBD>܂<EFBFBD><DC82>B:
</para>
<programlisting><![CDATA[select usr.id, usr.name
from User as usr
left join usr.messages as msg
group by usr.id, usr.name
order by count(msg)]]></programlisting>
<para>
<20>g<EFBFBD>p<EFBFBD><70><EFBFBD>Ă<EFBFBD><C482><EFBFBD><EFBFBD>f<EFBFBD>[<5B>^<5E>x<EFBFBD>[<5B>X<EFBFBD><58><EFBFBD>T<EFBFBD>u<EFBFBD>Z<EFBFBD><5A><EFBFBD>N<EFBFBD>g<EFBFBD><67><EFBFBD>T<EFBFBD>|<7C>[<5B>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A<EFBFBD>N<EFBFBD>G<EFBFBD><47><EFBFBD><EFBFBD>where<72>߂ŃT<C583>C<EFBFBD>Y<EFBFBD>ɂ<EFBFBD><C982><EFBFBD><EFBFBD>I<EFBFBD><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݒ<EFBFBD><DD92>ł<EFBFBD><C582>܂<EFBFBD>:
</para>
<programlisting><![CDATA[from User usr where size(usr.messages) >= 1]]></programlisting>
<para>
<20>g<EFBFBD>p<EFBFBD><70><EFBFBD>Ă<EFBFBD><C482><EFBFBD><EFBFBD>f<EFBFBD>[<5B>^<5E>x<EFBFBD>[<5B>X<EFBFBD><58><EFBFBD>T<EFBFBD>u<EFBFBD>Z<EFBFBD><5A><EFBFBD>N<EFBFBD>g<EFBFBD><67><EFBFBD>T<EFBFBD>|<7C>[<5B>g<EFBFBD><67><EFBFBD>Ȃ<EFBFBD><C882><EFBFBD>́A<CD81><41><EFBFBD>̃N<CC83>G<EFBFBD><47><EFBFBD><EFBFBD><EFBFBD>g<EFBFBD>p<EFBFBD><70><EFBFBD>Ă<EFBFBD><C482><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
</para>
<programlisting><![CDATA[select usr.id, usr.name
from User usr.name
join usr.messages msg
group by usr.id, usr.name
having count(msg) >= 1]]></programlisting>
<para>
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ă<EFBFBD><C482><EFBFBD><E982B9><EFBFBD>ŏ<EFBFBD><C58F>̉<EFBFBD><CC89><EFBFBD><EFBFBD>@<40><>message<67>̌<EFBFBD><CC8C><EFBFBD><EFBFBD><EFBFBD>
<20>[<5B><><EFBFBD><EFBFBD> <literal>User</literal> <20><><EFBFBD>Ԃ<EFBFBD><D482><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682>ł<EFBFBD><C582>Ȃ<EFBFBD><C882>Ȃ<EFBFBD><C882>΁A<CE81>ȉ<EFBFBD><C889>̌`<60><><EFBFBD><EFBFBD><EFBFBD>g<EFBFBD><67><EFBFBD>܂<EFBFBD><DC82>B
</para>
<programlisting><![CDATA[select usr.id, usr.name
from User as usr
left join usr.messages as msg
group by usr.id, usr.name
having count(msg) = 0]]></programlisting>
<para>
JavaBean<61>̃v<CC83><76><EFBFBD>p<EFBFBD>e<EFBFBD>B<EFBFBD>́A<CD81><41><EFBFBD>O<EFBFBD>t<EFBFBD><74><EFBFBD>̃N<CC83>G<EFBFBD><47><EFBFBD>p<EFBFBD><70><EFBFBD><EFBFBD><EFBFBD>[<5B>^<5E>Ɍ<EFBFBD><C98C>т‚<D182><C282><EFBFBD>Ƃ<EFBFBD><C682>o<EFBFBD><6F><EFBFBD>܂<EFBFBD><DC82>B<EFBFBD>F
</para>
<programlisting><![CDATA[Query q = s.createQuery("from foo Foo as foo where foo.name=:name and foo.size=:size");
q.setProperties(fooBean); // fooBean has getName() and getSize()
List foos = q.list();]]></programlisting>
<para>
<20>R<EFBFBD><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>̓t<CD83>B<EFBFBD><42><EFBFBD>^<5E>t<EFBFBD><74> <literal>Query</literal> <20>C<EFBFBD><43><EFBFBD>^<5E>[<5B>t<EFBFBD>F<EFBFBD>C<EFBFBD>X<EFBFBD><58><EFBFBD>g<EFBFBD>p<EFBFBD><70><EFBFBD><EFBFBD>ƂŃy<C583>[<5B>W<EFBFBD><57><EFBFBD>‚<EFBFBD><C282><EFBFBD>Ƃ<EFBFBD><C682>ł<EFBFBD><C582>܂<EFBFBD><DC82>B:
</para>
<programlisting><![CDATA[Query q = s.createFilter( collection, "" ); // the trivial filter
q.setMaxResults(PAGE_SIZE);
q.setFirstResult(PAGE_SIZE * pageNumber);
List page = q.list();]]></programlisting>
<para>
<20>R<EFBFBD><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>̗v<CC97>f<EFBFBD>̓N<CD83>G<EFBFBD><47><EFBFBD>t<EFBFBD>B<EFBFBD><42><EFBFBD>^<5E><><EFBFBD>g<EFBFBD><67><EFBFBD>āA<C481><41><EFBFBD>בւ<D791><D682><EFBFBD><EFBFBD>O<EFBFBD><4F><EFBFBD>[<5B>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>o<EFBFBD><6F><EFBFBD>܂<EFBFBD><DC82>B:
</para>
<programlisting><![CDATA[Collection orderedCollection = s.filter( collection, "order by this.amount" );
Collection counts = s.filter( collection, "select this.type, count(this) group by this.type" );]]></programlisting>
<para>
<20>R<EFBFBD><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɃR<C983><52><EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>̃T<CC83>C<EFBFBD>Y<EFBFBD>𓾂邱<F093BE82>Ƃ<EFBFBD><C682>ł<EFBFBD><C582>܂<EFBFBD><DC82>B:
</para>
<programlisting><![CDATA[( (Integer) session.iterate("select count(*) from ....").next() ).intValue();]]></programlisting>
</sect1>
</chapter>