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

📄 query_hql.pot

📁 hibernate-distribution-3.3.1.GA-dist.zip源码
💻 POT
📖 第 1 页 / 共 4 页
字号:
msgstr ""#. Tag: programlisting#: query_hql.xml:317#, no-c-formatmsgid ""      "<![CDATA[select max(bodyWeight) as max, min(bodyWeight) as min, count(*) as n\n"      "from Cat cat]]>"msgstr ""#. Tag: para#: query_hql.xml:319#, no-c-formatmsgid "This is most useful when used together with <literal>select new map</literal>:"msgstr ""#. Tag: programlisting#: query_hql.xml:323#, no-c-formatmsgid ""      "<![CDATA[select new map( max(bodyWeight) as max, min(bodyWeight) as min, count(*) as n )\n"      "from Cat cat]]>"msgstr ""#. Tag: para#: query_hql.xml:325#, no-c-formatmsgid "This query returns a <literal>Map</literal> from aliases to selected values."msgstr ""#. Tag: title#: query_hql.xml:332#, no-c-formatmsgid "Aggregate functions"msgstr ""#. Tag: para#: query_hql.xml:334#, no-c-formatmsgid "HQL queries may even return the results of aggregate functions on properties:"msgstr ""#. Tag: programlisting#: query_hql.xml:338#, no-c-formatmsgid ""      "<![CDATA[select avg(cat.weight), sum(cat.weight), max(cat.weight), count(cat)\n"      "from Cat cat]]>"msgstr ""#. Tag: para#: query_hql.xml:349#, no-c-formatmsgid "The supported aggregate functions are"msgstr ""#. Tag: literal#: query_hql.xml:356#, no-c-formatmsgid "avg(...), sum(...), min(...), max(...)"msgstr ""#. Tag: literal#: query_hql.xml:361#, no-c-formatmsgid "count(*)"msgstr ""#. Tag: literal#: query_hql.xml:366#, no-c-formatmsgid "count(...), count(distinct ...), count(all...)"msgstr ""#. Tag: para#: query_hql.xml:371#, no-c-formatmsgid "You may use arithmetic operators, concatenation, and recognized SQL functions in the select clause:"msgstr ""#. Tag: programlisting#: query_hql.xml:376#, no-c-formatmsgid ""      "<![CDATA[select cat.weight + sum(kitten.weight)\n"      "from Cat cat\n"      "    join cat.kittens kitten\n"      "group by cat.id, cat.weight]]>"msgstr ""#. Tag: programlisting#: query_hql.xml:378#, no-c-formatmsgid "<![CDATA[select firstName||' '||initial||' '||upper(lastName) from Person]]>"msgstr ""#. Tag: para#: query_hql.xml:380#, no-c-formatmsgid "The <literal>distinct</literal> and <literal>all</literal> keywords may be used and have the same semantics as in SQL."msgstr ""#. Tag: programlisting#: query_hql.xml:385#, no-c-formatmsgid ""      "<![CDATA[select distinct cat.name from Cat cat\n"      "\n"      "select count(distinct cat.name), count(cat) from Cat cat]]>"msgstr ""#. Tag: title#: query_hql.xml:390#, no-c-formatmsgid "Polymorphic queries"msgstr ""#. Tag: para#: query_hql.xml:392#, no-c-formatmsgid "A query like:"msgstr ""#. Tag: para#: query_hql.xml:398#, no-c-formatmsgid "returns instances not only of <literal>Cat</literal>, but also of subclasses like <literal>DomesticCat</literal>. Hibernate queries may name <emphasis>any</emphasis> Java class or interface in the <literal>from</literal> clause. The query will return instances of all persistent classes that extend that class or implement the interface. The following query would return all persistent objects:"msgstr ""#. Tag: programlisting#: query_hql.xml:406#, no-c-formatmsgid "<![CDATA[from java.lang.Object o]]>"msgstr ""#. Tag: para#: query_hql.xml:408#, no-c-formatmsgid "The interface <literal>Named</literal> might be implemented by various persistent classes:"msgstr ""#. Tag: programlisting#: query_hql.xml:413#, no-c-formatmsgid "<![CDATA[from Named n, Named m where n.name = m.name]]>"msgstr ""#. Tag: para#: query_hql.xml:415#, no-c-formatmsgid "Note that these last two queries will require more than one SQL <literal>SELECT</literal>. This means that the <literal>order by</literal> clause does not correctly order the whole result set. (It also means you can't call these queries using <literal>Query.scroll()</literal>.)"msgstr ""#. Tag: title#: query_hql.xml:424#, no-c-formatmsgid "The where clause"msgstr ""#. Tag: para#: query_hql.xml:426#, no-c-formatmsgid "The <literal>where</literal> clause allows you to narrow the list of instances returned. If no alias exists, you may refer to properties by name:"msgstr ""#. Tag: programlisting#: query_hql.xml:431#, no-c-formatmsgid "<![CDATA[from Cat where name='Fritz']]>"msgstr ""#. Tag: para#: query_hql.xml:433#, no-c-formatmsgid "If there is an alias, use a qualified property name:"msgstr ""#. Tag: programlisting#: query_hql.xml:437#, no-c-formatmsgid "<![CDATA[from Cat as cat where cat.name='Fritz']]>"msgstr ""#. Tag: para#: query_hql.xml:439#, no-c-formatmsgid "returns instances of <literal>Cat</literal> named 'Fritz'."msgstr ""#. Tag: programlisting#: query_hql.xml:443#, no-c-formatmsgid ""      "<![CDATA[select foo\n"      "from Foo foo, Bar bar\n"      "where foo.startDate = bar.date]]>"msgstr ""#. Tag: para#: query_hql.xml:445#, no-c-formatmsgid "will return all instances of <literal>Foo</literal> for which there exists an instance of <literal>bar</literal> with a <literal>date</literal> property equal to the <literal>startDate</literal> property of the <literal>Foo</literal>. Compound path expressions make the <literal>where</literal> clause extremely powerful. Consider:"msgstr ""#. Tag: programlisting#: query_hql.xml:454#, no-c-formatmsgid "<![CDATA[from Cat cat where cat.mate.name is not null]]>"msgstr ""#. Tag: para#: query_hql.xml:456#, no-c-formatmsgid "This query translates to an SQL query with a table (inner) join. If you were to write something like"msgstr ""#. Tag: programlisting#: query_hql.xml:461#, no-c-formatmsgid ""      "<![CDATA[from Foo foo\n"      "where foo.bar.baz.customer.address.city is not null]]>"msgstr ""#. Tag: para#: query_hql.xml:463#, no-c-formatmsgid "you would end up with a query that would require four table joins in SQL."msgstr ""#. Tag: para#: query_hql.xml:467#, no-c-formatmsgid "The <literal>=</literal> operator may be used to compare not only properties, but also instances:"msgstr ""#. Tag: programlisting#: query_hql.xml:472#, no-c-formatmsgid "<![CDATA[from Cat cat, Cat rival where cat.mate = rival.mate]]>"msgstr ""#. Tag: programlisting#: query_hql.xml:474#, no-c-formatmsgid ""      "<![CDATA[select cat, mate\n"      "from Cat cat, Cat mate\n"      "where cat.mate = mate]]>"msgstr ""#. Tag: para#: query_hql.xml:476#, no-c-formatmsgid "The special property (lowercase) <literal>id</literal> may be used to reference the unique identifier of an object. See <xref linkend=\"queryhql-identifier-property\"/> for more information."msgstr ""#. Tag: programlisting#: query_hql.xml:482#, no-c-formatmsgid ""      "<![CDATA[from Cat as cat where cat.id = 123\n"      "\n"      "from Cat as cat where cat.mate.id = 69]]>"msgstr ""#. Tag: para#: query_hql.xml:484#, no-c-formatmsgid "The second query is efficient. No table join is required!"msgstr ""#. Tag: para#: query_hql.xml:488#, no-c-formatmsgid "Properties of composite identifiers may also be used. Suppose <literal>Person</literal> has a composite identifier consisting of <literal>country</literal> and <literal>medicareNumber</literal>. Again, see <xref linkend=\"queryhql-identifier-property\"/> for more information regarding referencing identifier properties."msgstr ""#. Tag: programlisting#: query_hql.xml:495#, no-c-formatmsgid ""      "<![CDATA[from bank.Person person\n"      "where person.id.country = 'AU'\n"      "    and person.id.medicareNumber = 123456]]>"msgstr ""#. Tag: programlisting#: query_hql.xml:497#, no-c-formatmsgid ""      "<![CDATA[from bank.Account account\n"      "where account.owner.id.country = 'AU'\n"      "    and account.owner.id.medicareNumber = 123456]]>"msgstr ""#. Tag: para#: query_hql.xml:499#, no-c-formatmsgid "Once again, the second query requires no table join."msgstr ""#. Tag: para#: query_hql.xml:503#, no-c-formatmsgid "Likewise, the special property <literal>class</literal> accesses the discriminator value of an instance in the case of polymorphic persistence. A Java class name embedded in the where clause will be translated to its discriminator value."msgstr ""#. Tag: programlisting#: query_hql.xml:509#, no-c-formatmsgid "<![CDATA[from Cat cat where cat.class = DomesticCat]]>"msgstr ""#. Tag: para#: query_hql.xml:511#, no-c-formatmsgid "You may also use components or composite user types, or properties of said component types. See <xref linkend=\"queryhql-components\"/> for more details."msgstr ""#. Tag: para#: query_hql.xml:516#, no-c-formatmsgid "An \"any\" type has the special properties <literal>id</literal> and <literal>class</literal>, allowing us to express a join in the following way (where <literal>AuditLog.item</literal> is a property mapped with <literal>&lt;any&gt;</literal>)."msgstr ""#. Tag: programlisting#: query_hql.xml:522#, no-c-formatmsgid ""      "<![CDATA[from AuditLog log, Payment payment\n"      "where log.item.class = 'Payment' and log.item.id = payment.id]]>"msgstr ""#. Tag: para#: query_hql.xml:524#, no-c-formatmsgid "Notice that <literal>log.item.class</literal> and <literal>payment.class</literal> would refer to the values of completely different database columns in the above query."msgstr ""#. Tag: title#: query_hql.xml:532#, no-c-formatmsgid "Expressions"msgstr ""#. Tag: para#: query_hql.xml:534#, no-c-formatmsgid "Expressions allowed in the <literal>where</literal> clause include most of the kind of things you could write in SQL:"msgstr ""#. Tag: para#: query_hql.xml:541#, no-c-formatmsgid "mathematical operators <literal>+, -, *, /</literal>"msgstr ""#. Tag: para#: query_hql.xml:546#, no-c-formatmsgid "binary comparison operators <literal>=, &gt;=, &lt;=, &lt;&gt;, !=, like</literal>"msgstr ""#. Tag: para#: query_hql.xml:551#, no-c-formatmsgid "logical operations <literal>and, or, not</literal>"msgstr ""#. Tag: para#: query_hql.xml:556#, no-c-formatmsgid "Parentheses <literal>( )</literal>, indicating grouping"msgstr ""#. Tag: para#: query_hql.xml:561#, no-c-formatmsgid "<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>"msgstr ""#. Tag: para#: query_hql.xml:574#, no-c-formatmsgid "\"Simple\" case, <literal>case ... when ... then ... else ... end</literal>, and \"searched\" case, <literal>case when ... then ... else ... end</literal>"msgstr ""#. Tag: para#: query_hql.xml:580#, no-c-formatmsgid "string concatenation <literal>...||...</literal> or <literal>concat(...,...)</literal>"msgstr ""#. Tag: para#: query_hql.xml:585#, no-c-formatmsgid "<literal>current_date()</literal>, <literal>current_time()</literal>, <literal>current_timestamp()</literal>"msgstr ""#. Tag: para#: query_hql.xml:591#, no-c-formatmsgid "<literal>second(...)</literal>, <literal>minute(...)</literal>, <literal>hour(...)</literal>, <literal>day(...)</literal>, <literal>month(...)</literal>, <literal>year(...)</literal>,"msgstr ""#. Tag: para#: query_hql.xml:598#, no-c-formatmsgid "Any function or operator defined by EJB-QL 3.0: <literal>substring(), trim(), lower(), upper(), length(), locate(), abs(), sqrt(), bit_length(), mod()</literal>"msgstr ""#. Tag: para#: query_hql.xml:604#, no-c-formatmsgid "<literal>coalesce()</literal> and <literal>nullif()</literal>"msgstr ""#. Tag: para#: query_hql.xml:609#, no-c-formatmsgid "<literal>str()</literal> for converting numeric or temporal values to a readable string"msgstr ""#. Tag: para#: query_hql.xml:615#, no-c-formatmsgid "<literal>cast(... as ...)</literal>, where the second argument is the name of a Hibernate type, and <literal>extract(... from ...)</literal> if ANSI <literal>cast()</literal> and <literal>extract()</literal> is supported by the underlying database"msgstr ""#. Tag: para#: query_hql.xml:623#, no-c-formatmsgid "the HQL <literal>index()</literal> function, that applies to aliases of a joined indexed collection"msgstr ""#. Tag: para#: query_hql.xml:629#, no-c-formatmsgid "HQL functions that take collection-valued path expressions: <literal>size(), minelement(), maxelement(), minindex(), maxindex()</literal>, along with the special <literal>elements()</literal> and <literal>indices</literal> functions which may be quantified using <literal>some, all, exists, any, in</literal>."msgstr ""#. Tag: para#: query_hql.xml:637#, no-c-formatmsgid "Any database-supported SQL scalar function like <literal>sign()</literal>, <literal>trunc()</literal>, <literal>rtrim()</literal>, <literal>sin()</literal>"msgstr ""#. Tag: para

⌨️ 快捷键说明

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