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

📄 query_hql.pot

📁 hibernate 开源框架的代码 jar包希望大家能喜欢
💻 POT
📖 第 1 页 / 共 2 页
字号:
msgid ""msgstr """Project-Id-Version: PACKAGE VERSION\n""POT-Creation-Date: 2007-10-19 10:34-0500\n""PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n""Last-Translator: FULL NAME <EMAIL@ADDRESS>\n""Language-Team: LANGUAGE <LL@li.org>\n""MIME-Version: 1.0\n""Content-Type: text/plain; charset=UTF-8\n""Content-Transfer-Encoding: 8bit\n"#: query_hql.xml:5(title) msgid "HQL: The Hibernate Query Language"msgstr ""#: query_hql.xml:7(para) msgid "Hibernate is equipped with an extremely powerful query language that (quite intentionally) looks very much like SQL. But don't be fooled by the syntax; HQL is fully object-oriented, understanding notions like inheritence, polymorphism and association."msgstr ""#: query_hql.xml:14(title) msgid "Case Sensitivity"msgstr ""#: query_hql.xml:16(para) msgid "Queries are case-insensitive, except for names of Java classes and properties. So <literal>SeLeCT</literal> is the same as <literal>sELEct</literal> is the same as <literal>SELECT</literal> but <literal>org.hibernate.eg.FOO</literal> is not <literal>org.hibernate.eg.Foo</literal> and <literal>foo.barSet</literal> is not <literal>foo.BARSET</literal>."msgstr ""#: query_hql.xml:27(para) msgid "This manual uses lowercase HQL keywords. Some users find queries with uppercase keywords more readable, but we find this convention ugly when embedded in Java code."msgstr ""#: query_hql.xml:35(title) msgid "The from clause"msgstr ""#: query_hql.xml:37(para) msgid "The simplest possible Hibernate query is of the form:"msgstr ""#: query_hql.xml:43(para) msgid "which simply returns all instances of the class <literal>eg.Cat</literal>. We don't usually need to qualify the class name, since <literal>auto-import</literal> is the default. So we almost always just write:"msgstr ""#: query_hql.xml:51(para) msgid "Most of the time, you will need to assign an <emphasis>alias</emphasis>, since you will want to refer to the <literal>Cat</literal> in other parts of the query."msgstr ""#: query_hql.xml:59(para) msgid "This query assigns the alias <literal>cat</literal> to <literal>Cat</literal> instances, so we could use that alias later in the query. The <literal>as</literal> keyword is optional; we could also write:"msgstr ""#: query_hql.xml:67(para) msgid "Multiple classes may appear, resulting in a cartesian product or \"cross\" join."msgstr ""#: query_hql.xml:74(para) msgid "It is considered good practice to name query aliases using an initial lowercase, consistent with Java naming standards for local variables (eg. <literal>domesticCat</literal>)."msgstr ""#: query_hql.xml:83(title) msgid "Associations and joins"msgstr ""#: query_hql.xml:85(para) msgid "We may also assign aliases to associated entities, or even to elements of a collection of values, using a <literal>join</literal>."msgstr ""#: query_hql.xml:98(para) msgid "The supported join types are borrowed from ANSI SQL"msgstr ""#: query_hql.xml:105(literal) msgid "inner join"msgstr ""#: query_hql.xml:110(literal) msgid "left outer join"msgstr ""#: query_hql.xml:115(literal) msgid "right outer join"msgstr ""#: query_hql.xml:119(para) msgid "<literal>full join</literal> (not usually useful)"msgstr ""#: query_hql.xml:125(para) msgid "The <literal>inner join</literal>, <literal>left outer join</literal> and <literal>right outer join</literal> constructs may be abbreviated."msgstr ""#: query_hql.xml:134(para) msgid "You may supply extra join conditions using the HQL <literal>with</literal> keyword."msgstr ""#: query_hql.xml:143(para) msgid "In addition, a \"fetch\" join allows associations or collections of values to be initialized along with their parent objects, using a single select. This is particularly useful in the case of a collection. It effectively overrides the outer join and lazy declarations of the mapping file for associations and collections. See <xref linkend=\"performance-fetching\"/> for more information."msgstr ""#: query_hql.xml:155(para) msgid "A fetch join does not usually need to assign an alias, because the associated objects should not be used in the <literal>where</literal> clause (or any other clause). Also, the associated objects are not returned directly in the query results. Instead, they may be accessed via the parent object. The only reason we might need an alias is if we are recursively join fetching a further collection:"msgstr ""#: query_hql.xml:168(para) msgid "Note that the <literal>fetch</literal> construct may not be used in queries called using <literal>iterate()</literal> (though <literal>scroll()</literal> can be used). Nor should <literal>fetch</literal> be used together with <literal>setMaxResults()</literal> or <literal>setFirstResult()</literal> as these operations are based on the result rows, which usually contain duplicates for eager collection fetching, hence, the number of rows is not what you'd expect. Nor may <literal>fetch</literal> be used together with an ad hoc <literal>with</literal> condition. It is possible to create a cartesian product by join fetching more than one collection in a query, so take care in this case. Join fetching multiple collection roles also sometimes gives unexpected results for bag mappings, so be careful about how you formulate your queries in this case. Finally, note that <literal>full join fetch</literal> and <literal>right join fetch</literal> are not meaningful."msgstr ""#: query_hql.xml:183(para) msgid "If you are using property-level lazy fetching (with bytecode instrumentation), it is possible to force Hibernate to fetch the lazy properties immediately (in the first query) using <literal>fetch all properties</literal>."msgstr ""#: query_hql.xml:195(title) msgid "Forms of join syntax"msgstr ""#: query_hql.xml:197(para) msgid "HQL supports two forms of association joining: <literal>implicit</literal> and <literal>explicit</literal>."msgstr ""#: query_hql.xml:201(para) msgid "The queries shown in the previous section all use the <literal>explicit</literal> form where the join keyword is explicitly used in the from clause. This is the recommended form."msgstr ""#: query_hql.xml:206(para) msgid "The <literal>implicit</literal> form does not use the join keyword. Instead, the associations are \"dereferenced\" using dot-notation. <literal>implicit</literal> joins can appear in any of the HQL clauses. <literal>implicit</literal> join result in inner joins in the resulting SQL statement."msgstr ""#: query_hql.xml:217(title) msgid "Refering to identifier property"msgstr ""#: query_hql.xml:219(para) msgid "There are, generally speaking, 2 ways to refer to an entity's identifier property:"msgstr ""#: query_hql.xml:224(para) msgid "The special property (lowercase) <literal>id</literal> may be used to reference the identifier property of an entity <emphasis>provided that entity does not define a non-identifier property named id</emphasis>."msgstr ""#: query_hql.xml:231(para) msgid "If the entity defines a named identifier property, you may use that property name."msgstr ""#: query_hql.xml:237(para) msgid "References to composite identifier properties follow the same naming rules. If the entity has a non-identifier property named id, the composite identifier property can only be referenced by its defined named; otherwise, the special <literal>id</literal> property can be used to rerference the identifier property."msgstr ""#: query_hql.xml:244(para) msgid "Note: this has changed significantly starting in version 3.2.2. In previous versions, <literal>id</literal><emphasis>always</emphasis> referred to the identifier property no matter what its actual name. A ramification of that decision was that non-identifier properties named <literal>id</literal> could never be referenced in Hibernate queries."msgstr ""#: query_hql.xml:253(title) msgid "The select clause"msgstr ""#: query_hql.xml:255(para) msgid "The <literal>select</literal> clause picks which objects and properties to return in the query result set. Consider:"msgstr ""#: query_hql.xml:264(para) msgid "The query will select <literal>mate</literal>s of other <literal>Cat</literal>s. Actually, you may express this query more compactly as:"msgstr ""#: query_hql.xml:271(para) msgid "Queries may return properties of any value type including properties of component type:"msgstr ""#: query_hql.xml:280(para) msgid "Queries may return multiple objects and/or properties as an array of type <literal>Object[]</literal>,"msgstr ""#: query_hql.xml:290(para) msgid "or as a <literal>List</literal>,"msgstr ""#: query_hql.xml:299(para) msgid "or as an actual typesafe Java object,"msgstr ""#: query_hql.xml:308(para) msgid "assuming that the class <literal>Family</literal> has an appropriate constructor."msgstr ""#: query_hql.xml:312(para) msgid "You may assign aliases to selected expressions using <literal>as</literal>:"msgstr ""#: query_hql.xml:319(para) msgid "This is most useful when used together with <literal>select new map</literal>:"msgstr ""#: query_hql.xml:326(para) msgid "This query returns a <literal>Map</literal> from aliases to selected values."msgstr ""#: query_hql.xml:333(title) msgid "Aggregate functions"msgstr ""#: query_hql.xml:335(para) msgid "HQL queries may even return the results of aggregate functions on properties:"msgstr ""#. 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>#: query_hql.xml:352(para) msgid "The supported aggregate functions are"msgstr ""#: query_hql.xml:359(literal) msgid "avg(...), sum(...), min(...), max(...)"msgstr ""#: query_hql.xml:364(literal) msgid "count(*)"msgstr ""#: query_hql.xml:369(literal) msgid "count(...), count(distinct ...), count(all...)"msgstr ""#: query_hql.xml:374(para) msgid "You may use arithmetic operators, concatenation, and recognized SQL functions in the select clause:"msgstr ""#: query_hql.xml:386(para) msgid "The <literal>distinct</literal> and <literal>all</literal> keywords may be used and have the same semantics as in SQL."msgstr ""#: query_hql.xml:398(title) msgid "Polymorphic queries"msgstr ""#: query_hql.xml:400(para) msgid "A query like:"msgstr ""#: query_hql.xml:406(para) msgid "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 ""#: query_hql.xml:416(para) msgid "The interface <literal>Named</literal> might be implemented by various persistent classes:"msgstr ""#: query_hql.xml:423(para) msgid "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 ""#: query_hql.xml:432(title) msgid "The where clause"msgstr ""#: query_hql.xml:434(para) msgid "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 ""#: query_hql.xml:441(para) msgid "If there is an alias, use a qualified property name:"msgstr ""#: query_hql.xml:447(para) msgid "returns instances of <literal>Cat</literal> named 'Fritz'."msgstr ""#: query_hql.xml:455(para) msgid "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 ""#: query_hql.xml:466(para) msgid "This query translates to an SQL query with a table (inner) join. If you were to write something like"msgstr ""#: query_hql.xml:474(para) msgid "you would end up with a query that would require four table joins in SQL."msgstr ""#: query_hql.xml:478(para) msgid "The <literal>=</literal> operator may be used to compare not only properties, but also instances:"msgstr ""#: query_hql.xml:489(para) msgid "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 ""#: query_hql.xml:499(para) msgid "The second query is efficient. No table join is required!"msgstr ""#: query_hql.xml:503(para) msgid "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 ""#: query_hql.xml:518(para) msgid "Once again, the second query requires no table join."msgstr ""#: query_hql.xml:522(para) msgid "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 ""#: query_hql.xml:530(para) msgid "You may also use components or composite user types, or properties of said component types. See <xref linkend=\"queryhql-coomponents\"/> for more details."msgstr ""#: query_hql.xml:535(para) msgid "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 ""#: query_hql.xml:544(para) msgid "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 ""#: query_hql.xml:552(title) msgid "Expressions"msgstr ""

⌨️ 快捷键说明

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