⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 queryhql.html

📁 图象处理
💻 HTML
📖 第 1 页 / 共 4 页
字号:
from eg.Player p where 3 &gt; all elements(p.scores)from eg.Show show where 'fizard' in indices(show.acts)</pre><p>            &#35831;&#27880;&#24847;&#36825;&#20123;&#35774;&#26045;&#65306;<tt class="literal">size</tt>,<tt class="literal">elements</tt>,<tt class="literal">indices</tt>,<tt class="literal">minIndex</tt>,<tt class="literal">maxIndex</tt>,<tt class="literal">minElement</tt>,<tt class="literal">maxElement</tt> &#37117;&#26377;&#19968;&#20123;&#20351;&#29992;&#38480;&#21046;&#65306;        </p><div class="itemizedlist"><ul type="disc" compact><li><p>                    &#22312;<tt class="literal">where</tt>&#23376;&#21477;&#20013;: &#21482;&#23545;&#25903;&#25345;&#23376;&#26597;&#35810;&#30340;&#25968;&#25454;&#24211;&#26377;&#25928;                </p></li><li><p>                    &#22312;<tt class="literal">select</tt>&#23376;&#21477;&#20013;&#65306;&#21482;&#26377;<tt class="literal">elements</tt>&#21644;<tt class="literal">indices</tt>&#26377;&#25928;                </p></li></ul></div><p>            &#26377;&#24207;&#30340;&#38598;&#21512;(&#25968;&#32452;&#12289;list&#12289;map)&#30340;&#20803;&#32032;&#21487;&#20197;&#29992;&#32034;&#24341;&#26469;&#36827;&#34892;&#24341;&#29992;&#65288;&#21482;&#38480;&#20110;&#22312;where&#23376;&#21477;&#20013;&#65289;        </p><pre class="programlisting">from Order order where order.items[0].id = 1234select person from Person person, Calendar calendarwhere calendar.holidays['national day'] = person.birthDay    and person.nationality.calendar = calendarselect item from Item item, Order orderwhere order.items[ order.deliveredItemIndices[0] ] = item and order.id = 11select item from Item item, Order orderwhere order.items[ maxindex(order.items) ] = item and order.id = 11</pre><p>            <tt class="literal">[]</tt>&#20013;&#30340;&#34920;&#36798;&#24335;&#20801;&#35768;&#26159;&#21478;&#19968;&#20010;&#25968;&#23398;&#34920;&#36798;&#24335;&#12290;        </p><pre class="programlisting">select item from Item item, Order orderwhere order.items[ size(order.items) - 1 ] = item</pre><p>            HQL&#20063;&#23545;&#19968;&#23545;&#22810;&#20851;&#32852;&#25110;&#32773;&#20540;&#38598;&#21512;&#25552;&#20379;&#20869;&#32622;&#30340;<tt class="literal">index()</tt>&#20989;&#25968;&#12290;        </p><pre class="programlisting">select item, index(item) from Order order     join order.items itemwhere index(item) &lt; 5</pre><p>            &#24213;&#23618;&#25968;&#25454;&#24211;&#25903;&#25345;&#30340;&#26631;&#37327;SQL&#20989;&#25968;&#20063;&#21487;&#20197;&#20351;&#29992;        </p><pre class="programlisting">from eg.DomesticCat cat where upper(cat.name) like 'FRI%'</pre><p>            &#20551;&#22914;&#20197;&#19978;&#30340;&#36825;&#20123;&#36824;&#27809;&#26377;&#35753;&#20320;&#20449;&#26381;&#30340;&#35805;&#65292;&#35831;&#24819;&#35937;&#19968;&#19979;&#19979;&#38754;&#30340;&#26597;&#35810;&#20551;&#33509;&#29992;SQL&#26469;&#20889;&#65292;&#20250;&#21464;&#24471;&#22810;&#20040;&#38271;&#65292;&#22810;&#20040;&#19981;&#21487;&#35835;&#65306;        </p><pre class="programlisting">select custfrom Product prod,    Store store    inner join store.customers custwhere prod.name = 'widget'    and store.location.name in ( 'Melbourne', 'Sydney' )    and prod = all elements(cust.currentOrder.lineItems)</pre><p>            <span class="emphasis"><em>&#25552;&#31034;&#65306;</em></span>&#23545;&#24212;&#30340;SQL&#35821;&#21477;&#21487;&#33021;&#26159;&#36825;&#26679;&#30340;        </p><pre class="programlisting">SELECT cust.name, cust.address, cust.phone, cust.id, cust.current_orderFROM customers cust,    stores store,    locations loc,    store_customers sc,    product prodWHERE 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    )</pre></div><div class="sect1" lang="zh-cn"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="queryhql-ordering"></a>11.9.&nbsp;order by &#23376;&#21477;</h2></div></div><div></div></div><p>            &#26597;&#35810;&#36820;&#22238;&#30340;&#21015;&#34920;&#21487;&#20197;&#25353;&#29031;&#20219;&#20309;&#36820;&#22238;&#30340;&#31867;&#25110;&#32773;&#32452;&#20214;&#30340;&#23646;&#24615;&#25490;&#24207;&#65306;        </p><pre class="programlisting">from eg.DomesticCat catorder by cat.name asc, cat.weight desc, cat.birthdate</pre><p>            <tt class="literal">asc</tt>&#21644;<tt class="literal">desc</tt>&#26159;&#21487;&#36873;&#30340;&#65292;&#20998;&#21035;&#20195;&#34920;&#21319;&#24207;&#25110;&#32773;&#38477;&#24207;&#12290;        </p></div><div class="sect1" lang="zh-cn"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="queryhql-grouping"></a>11.10.&nbsp;group by &#23376;&#21477;</h2></div></div><div></div></div><p>            &#36820;&#22238;&#32479;&#35745;&#20540;&#30340;&#26597;&#35810;&#21487;&#20197;&#25353;&#29031;&#36820;&#22238;&#30340;&#31867;&#25110;&#32773;&#32452;&#20214;&#30340;&#20219;&#20309;&#23646;&#24615;&#25490;&#24207;&#65306;        </p><pre class="programlisting">select cat.color, sum(cat.weight), count(cat) from eg.Cat catgroup by cat.colorselect foo.id, avg( elements(foo.names) ), max( indices(foo.names) ) from eg.Foo foogroup by foo.id</pre><p>	        &#35831;&#27880;&#24847;&#65306;&#20320;&#21487;&#20197;&#22312;select&#23376;&#21477;&#20013;&#20351;&#29992;<tt class="literal">elements</tt>&#21644;<tt class="literal">indices</tt>&#25351;&#20196;&#65292;&#21363;&#20351;&#20320;&#30340;&#25968;&#25454;&#24211;&#19981;&#25903;&#25345;&#23376;&#26597;&#35810;&#20063;&#21487;&#20197;&#12290;	    </p><p>	        <tt class="literal">having</tt>&#23376;&#21477;&#20063;&#26159;&#20801;&#35768;&#30340;&#12290;	    </p><pre class="programlisting">select cat.color, sum(cat.weight), count(cat) from eg.Cat catgroup by cat.color having cat.color in (eg.Color.TABBY, eg.Color.BLACK)</pre><p>	        &#22312;<tt class="literal">having</tt>&#23376;&#21477;&#20013;&#20801;&#35768;&#20986;&#29616;SQL&#20989;&#25968;&#21644;&#32479;&#35745;&#20989;&#25968;&#65292;&#24403;&#28982;&#36825;&#38656;&#35201;&#24213;&#23618;&#25968;&#25454;&#24211;&#25903;&#25345;&#25165;&#34892;&#12290;&#65288;&#27604;&#22914;&#35828;,MySQL&#23601;&#19981;&#25903;&#25345;&#65289;	    </p><pre class="programlisting">select catfrom eg.Cat cat    join cat.kittens kittengroup by cathaving avg(kitten.weight) &gt; 100order by count(kitten) asc, sum(kitten.weight) desc</pre><p>	        &#27880;&#24847;&#65292;<tt class="literal">group by</tt>&#23376;&#21477;&#21644;<tt class="literal">order by</tt>&#23376;&#21477;&#37117;&#19981;&#25903;&#25345;&#25968;&#23398;&#34920;&#36798;&#24335;&#12290;	    </p></div><div class="sect1" lang="zh-cn"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="queryhql-subqueries"></a>11.11.&nbsp;&#23376;&#26597;&#35810;</h2></div></div><div></div></div><p>            &#23545;&#20110;&#25903;&#25345;&#23376;&#26597;&#35810;&#30340;&#25968;&#25454;&#24211;&#26469;&#35828;&#65292;Hibernate&#25903;&#25345;&#22312;&#26597;&#35810;&#20013;&#23884;&#22871;&#23376;&#26597;&#35810;&#12290;&#23376;&#26597;&#35810;&#24517;&#39035;&#30001;&#22278;&#25324;&#21495;&#21253;&#22260;&#65288;&#24120;&#24120;&#26159;&#22312;&#19968;&#20010;SQL&#32479;&#35745;&#20989;&#25968;&#20013;&#65289;&#12290;&#20063;&#20801;&#35768;&#20851;&#32852;&#23376;&#26597;&#35810;&#65288;&#22312;&#22806;&#37096;&#26597;&#35810;&#20013;&#20316;&#20026;&#19968;&#20010;&#21035;&#21517;&#20986;&#29616;&#30340;&#23376;&#26597;&#35810;&#65289;&#12290;        </p><pre class="programlisting">from eg.Cat as fatcat where fatcat.weight &gt; (     select avg(cat.weight) from eg.DomesticCat cat )from eg.DomesticCat as cat where cat.name = some (     select name.nickName from eg.Name as name )    from eg.Cat as cat where not exists (     from eg.Cat as mate where mate.mate = cat )from eg.DomesticCat as cat where cat.name not in (     select name.nickName from eg.Name as name )</pre></div><div class="sect1" lang="zh-cn"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="queryhql-examples"></a>11.12.&nbsp;HQL&#31034;&#20363;</h2></div></div><div></div></div><p>            Hibernate&#26597;&#35810;&#21487;&#20197;&#38750;&#24120;&#24378;&#22823;&#22797;&#26434;&#12290;&#23454;&#38469;&#19978;&#65292;&#24378;&#26377;&#21147;&#30340;&#26597;&#35810;&#35821;&#35328;&#26159;Hibernate&#30340;&#20027;&#35201;&#21334;&#28857;&#20043;&#19968;&#12290;&#19979;&#38754;&#32473;&#20986;&#30340;&#31034;&#20363;&#19982;&#25105;&#22312;&#36817;&#26399;&#23454;&#38469;&#39033;&#30446;&#20013;&#20351;&#29992;&#30340;&#19968;&#20123;&#26597;&#35810;&#24456;&#31867;&#20284;&#12290;&#35831;&#27880;&#24847;&#20320;&#32534;&#20889;&#30340;&#26597;&#35810;&#22823;&#37096;&#20998;&#31561;&#37117;&#19981;&#20250;&#36825;&#20040;&#22797;&#26434;&#65281;        </p><p>            &#19979;&#38754;&#30340;&#26597;&#35810;&#23545;&#29305;&#23450;&#30340;&#23458;&#25143;&#65292;&#26681;&#25454;&#32473;&#23450;&#30340;&#26368;&#23567;&#24635;&#35745;&#20540;&#65288;minAmount)&#65292;&#26597;&#35810;&#20986;&#25152;&#26377;&#26410;&#20184;&#35746;&#21333;&#65292;&#36820;&#22238;&#20854;&#35746;&#21333;&#21495;&#12289;&#36135;&#21697;&#24635;&#25968;&#12289;&#35746;&#21333;&#24635;&#37329;&#39069;&#65292;&#32467;&#26524;&#25353;&#29031;&#24635;&#37329;&#39069;&#25490;&#24207;&#12290;&#22312;&#20915;&#23450;&#20215;&#26684;&#30340;&#26102;&#20505;&#65292;&#21442;&#32771;&#24403;&#21069;&#30446;&#24405;&#12290;&#20135;&#29983;&#30340;SQL&#26597;&#35810;&#65292;&#22312;<tt class="literal">ORDER</tt>,<tt class="literal">ORDER_LINE</tt>,<tt class="literal">PRODUCT</tt>,<tt class="literal">CATALOG</tt>&#21644;<tt class="literal">PRICE</tt>&#34920;&#20043;&#38388;&#26377;&#22235;&#20010;&#20869;&#37096;&#36830;&#25509;&#21644;&#19968;&#20010;&#27809;&#26377;&#20135;&#29983;&#20851;&#32852;&#30340;&#23383;&#26597;&#35810;&#12290;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -