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

📄 query_hql.po

📁 hibernate-distribution-3.3.1.GA-dist.zip源码
💻 PO
📖 第 1 页 / 共 5 页
字号:
#: query_hql.xml:800#, no-c-formatmsgid """<![CDATA[from DomesticCat cat\n""order by cat.name asc, cat.weight desc, cat.birthdate]]>"msgstr ""#. Tag: para#: query_hql.xml:802#, no-c-formatmsgid """The optional <literal>asc</literal> or <literal>desc</literal> indicate ""ascending or descending order respectively."msgstr """可选的<literal>asc</literal>或<literal>desc</literal>关键字指明了按照升序或降""序进行排序."#. Tag: title#: query_hql.xml:809#, no-c-formatmsgid "The group by clause"msgstr "group by子句"#. Tag: para#: query_hql.xml:811#, no-c-formatmsgid """A query that returns aggregate values may be grouped by any property of a ""returned class or components:"msgstr """一个返回聚集值(aggregate values)的查询可以按照一个返回的类或组件(components)""中的任何属性(property)进行分组:"#. Tag: programlisting#: query_hql.xml:815#, no-c-formatmsgid """<![CDATA[select cat.color, sum(cat.weight), count(cat)\n""from Cat cat\n""group by cat.color]]>"msgstr ""#. Tag: programlisting#: query_hql.xml:817#, no-c-formatmsgid """<![CDATA[select foo.id, avg(name), max(name)\n""from Foo foo join foo.names name\n""group by foo.id]]>"msgstr ""#. Tag: para#: query_hql.xml:819#, no-c-formatmsgid "A <literal>having</literal> clause is also allowed."msgstr "<literal>having</literal>子句在这里也允许使用."#. Tag: programlisting#: query_hql.xml:823#, no-c-formatmsgid """<![CDATA[select cat.color, sum(cat.weight), count(cat)\n""from Cat cat\n""group by cat.color\n""having cat.color in (eg.Color.TABBY, eg.Color.BLACK)]]>"msgstr ""#. Tag: para#: query_hql.xml:825#, no-c-formatmsgid """SQL functions and aggregate functions are allowed in the <literal>having</""literal> and <literal>order by</literal> clauses, if supported by the ""underlying database (eg. not in MySQL)."msgstr """如果底层的数据库支持的话(例如不能在MySQL中使用),SQL的一般函数与聚集函数也可""以出现 在<literal>having</literal>与<literal>order by</literal> 子句中。"#. Tag: programlisting#: query_hql.xml:831#, no-c-formatmsgid """<![CDATA[select cat\n""from Cat cat\n""    join cat.kittens kitten\n""group by cat.id, cat.name, cat.other, cat.properties\n""having avg(kitten.weight) > 100\n""order by count(kitten) asc, sum(kitten.weight) desc]]>"msgstr ""#. Tag: para#: query_hql.xml:833#, no-c-formatmsgid """Note that neither the <literal>group by</literal> clause nor the ""<literal>order by</literal> clause may contain arithmetic expressions. Also ""note that Hibernate currently does not expand a grouped entity, so you can't ""write <literal>group by cat</literal> if all properties of <literal>cat</""literal> are non-aggregated. You have to list all non-aggregated properties ""explicitly."msgstr """注意<literal>group by</literal>子句与 <literal>order by</literal>子句中都不能""包含算术表达式(arithmetic expressions). 也要注意Hibernate目前不会扩展group""的实体,因此你不能写<literal>group by cat</literal>,除非<literal>cat</literal>""的所有属性都不是聚集的(non-aggregated)。你必须明确的列出所有的非聚集属性。"#. Tag: title#: query_hql.xml:845#, no-c-formatmsgid "Subqueries"msgstr "子查询"#. Tag: para#: query_hql.xml:847#, no-c-formatmsgid """For databases that support subselects, Hibernate supports subqueries within ""queries. A subquery must be surrounded by parentheses (often by an SQL ""aggregate function call). Even correlated subqueries (subqueries that refer ""to an alias in the outer query) are allowed."msgstr """对于支持子查询的数据库,Hibernate支持在查询中使用子查询。一个子查询必须被圆括""号包围起来(经常是SQL聚集函数的圆括号)。 甚至相互关联的子查询(引用到外部查""询中的别名的子查询)也是允许的。"#. Tag: programlisting#: query_hql.xml:853#, no-c-formatmsgid """<![CDATA[from Cat as fatcat\n""where fatcat.weight > (\n""    select avg(cat.weight) from DomesticCat cat\n"")]]>"msgstr ""#. Tag: programlisting#: query_hql.xml:855#, no-c-formatmsgid """<![CDATA[from DomesticCat as cat\n""where cat.name = some (\n""    select name.nickName from Name as name\n"")]]>"msgstr ""#. Tag: programlisting#: query_hql.xml:857#, no-c-formatmsgid """<![CDATA[from Cat as cat\n""where not exists (\n""    from Cat as mate where mate.mate = cat\n"")]]>"msgstr ""#. Tag: programlisting#: query_hql.xml:859#, no-c-formatmsgid """<![CDATA[from DomesticCat as cat\n""where cat.name not in (\n""    select name.nickName from Name as name\n"")]]>"msgstr ""#. Tag: programlisting#: query_hql.xml:861#, no-c-formatmsgid """<![CDATA[select cat.id, (select max(kit.weight) from cat.kitten kit)\n""from Cat as cat]]>"msgstr ""#. Tag: para#: query_hql.xml:863#, no-c-formatmsgid "Note that HQL subqueries may occur only in the select or where clauses."msgstr "注意,HQL自查询只可以在select或者where子句中出现。"#. Tag: para#: query_hql.xml:867#, no-c-formatmsgid """Note that subqueries can also utilize <literal>row value constructor</""literal> syntax. See <xref linkend=\"queryhql-tuple\"/> for more details."msgstr """Note that subqueries can also utilize <literal>row value constructor</""literal> syntax. See <xref linkend=\"queryhql-tuple\"/> for more details."#. Tag: title#: query_hql.xml:875#, no-c-formatmsgid "HQL examples"msgstr "HQL示例"#. Tag: para#: query_hql.xml:877#, no-c-formatmsgid """Hibernate queries can be quite powerful and complex. In fact, the power of ""the query language is one of Hibernate's main selling points. Here are some ""example queries very similar to queries that I used on a recent project. ""Note that most queries you will write are much simpler than these!"msgstr """Hibernate查询可以非常的强大与复杂。实际上,Hibernate的一个主要卖点就是查询语""句的威力。这里有一些例子,它们与我在最近的 一个项目中使用的查询非常相似。注意""你能用到的大多数查询比这些要简单的多!"#. Tag: para#: query_hql.xml:883#, no-c-formatmsgid """The following query returns the order id, number of items and total value of ""the order for all unpaid orders for a particular customer and given minimum ""total value, ordering the results by total value. In determining the prices, ""it uses the current catalog. The resulting SQL query, against the ""<literal>ORDER</literal>, <literal>ORDER_LINE</literal>, <literal>PRODUCT</""literal>, <literal>CATALOG</literal> and <literal>PRICE</literal> tables has ""four inner joins and an (uncorrelated) subselect."msgstr """下面的查询对于某个特定的客户的所有未支付的账单,在给定给最小总价值的情况下,""返回订单的id,条目的数量和总价值, 返回值按照总价值的结果进行排序。为了决定价""格,查询使用了当前目录。作为转换结果的SQL查询,使用了<literal>ORDER</""literal>, <literal>ORDER_LINE</literal>, <literal>PRODUCT</literal>, ""<literal>CATALOG</literal> 和<literal>PRICE</literal> 库表。"#. Tag: programlisting#: query_hql.xml:892#, no-c-formatmsgid """<![CDATA[select order.id, sum(price.amount), count(item)\n""from Order as order\n""    join order.lineItems as item\n""    join item.product as product,\n""    Catalog as catalog\n""    join catalog.prices as price\n""where order.paid = false\n""    and order.customer = :customer\n""    and price.product = product\n""    and catalog.effectiveDate < sysdate\n""    and catalog.effectiveDate >= all (\n""        select cat.effectiveDate\n""        from Catalog as cat\n""        where cat.effectiveDate < sysdate\n""    )\n""group by order\n""having sum(price.amount) > :minAmount\n""order by sum(price.amount) desc]]>"msgstr ""#. Tag: para#: query_hql.xml:894#, no-c-formatmsgid """What a monster! Actually, in real life, I'm not very keen on subqueries, so ""my query was really more like this:"msgstr """这简直是一个怪物!实际上,在现实生活中,我并不热衷于子查询,所以我的查询语句""看起来更像这个:"#. Tag: programlisting#: query_hql.xml:899#, no-c-formatmsgid """<![CDATA[select order.id, sum(price.amount), count(item)\n""from Order as order\n""    join order.lineItems as item\n""    join item.product as product,\n""    Catalog as catalog\n""    join catalog.prices as price\n""where order.paid = false\n""    and order.customer = :customer\n""    and price.product = product\n""    and catalog = :currentCatalog\n""group by order\n""having sum(price.amount) > :minAmount\n""order by sum(price.amount) desc]]>"msgstr ""#. Tag: para#: query_hql.xml:901#, no-c-formatmsgid """The next query counts the number of payments in each status, excluding all ""payments in the <literal>AWAITING_APPROVAL</literal> status where the most ""recent status change was made by the current user. It translates to an SQL ""query with two inner joins and a correlated subselect against the ""<literal>PAYMENT</literal>, <literal>PAYMENT_STATUS</literal> and ""<literal>PAYMENT_STATUS_CHANGE</literal> tables."msgstr """下面一个查询计算每一种状态下的支付的数目,除去所有处于""<literal>AWAITING_APPROVAL</literal>状态的支付,因为在该状态下 当前的用户作出""了状态的最新改变。该查询被转换成含有两个内连接以及一个相关联的子选择的SQL查""询,该查询使用了表 <literal>PAYMENT</literal>, <literal>PAYMENT_STATUS</""literal> 以及 <literal>PAYMENT_STATUS_CHANGE</literal>。"#. Tag: programlisting#: query_hql.xml:909#, no-c-formatmsgid """<![CDATA[select count(payment), status.name\n""from Payment as payment\n""    join payment.currentStatus as status\n""    join payment.statusChanges as statusChange\n""where payment.status.name <> PaymentStatus.AWAITING_APPROVAL\n""    or (\n""        statusChange.timeStamp = (\n""            select max(change.timeStamp)\n""            from PaymentStatusChange change\n""            where change.payment = payment\n""        )\n""        and statusChange.user <> :currentUser\n""    )\n""group by status.name, status.sortOrder\n""order by status.sortOrder]]>"msgstr ""#. Tag: para#: query_hql.xml:911#, no-c-formatmsgid """If I would have mapped the <literal>statusChanges</literal> collection as a ""list, instead of a set, the query would have been much simpler to write."msgstr """如果我把<literal>statusChanges</literal>实例集映射为一个列表(list)而不是一""个集合(set), 书写查询语句将更加简单."#. Tag: programlisting#: query_hql.xml:916#, no-c-formatmsgid """<![CDATA[select count(payment), status.name\n""from Payment as payment\n""    join payment.currentStatus as status\n""where payment.status.name <> PaymentStatus.AWAITING_APPROVAL\n""    or payment.statusChanges[ maxIndex(payment.statusChanges) ].user <> :""currentUser\n""group by status.name, status.sortOrder\n""order by status.sortOrder]]>"msgstr ""#. Tag: para#: query_hql.xml:918#, no-c-formatmsgid """The next query uses the MS SQL Server <literal>isNull()</literal> function ""to return all the accounts and unpaid payments for the organization to which ""the current user belongs. It translates to an SQL query with three inner ""joins, an outer join and a subselect against the <literal>ACCOUNT</literal>, ""<literal>PAYMENT</literal>, <literal>PAYMENT_STATUS</literal>, ""<literal>ACCOUNT_TYPE</literal>, <literal>ORGANIZATION</literal> and ""<literal>ORG_USER</literal> tables."msgstr """下面一个查询使用了MS SQL Server的 <literal>isNull()</literal>函数用以返回当前""用户所属组织的组织帐号及组织未支付的账。 它被转换成一个对表<literal>ACCOUNT</""literal>, <literal>PAYMENT</literal>, <literal>PAYMENT_STATUS</literal>, ""<literal>ACCOUNT_TYPE</literal>, <literal>ORGANIZATION</literal> 以及 ""<literal>ORG_USER</literal>进行的三个内连接, 一个外连接和一个子选择的SQL查""询。"#. Tag: programlisting#: query_hql.xml:927#, no-c-formatmsgid """<![CDATA[select account, payment\n""from Account as account\n""    left outer join account.payments as payment\n""where :currentUser in elements(account.holder.users)\n""    and PaymentStatus.UNPAID = isNull(payment.currentStatus.name, ""PaymentStatus.UNPAID)\n""order by account.type.sortOrder, account.accountNumber, payment.dueDate]]>"msgstr ""#. Tag: para#: query_hql.xml:929#, no-c-formatmsgid """For some databases, we would need to do away with the (correlated) subselect."msgstr "对于一些数据库,我们需要弃用(相关的)子选择。"#. Tag: programlisting#: query_hql.xml:933#, no-c-formatmsgid """<![CDATA[select account, payment\n""from Account as account\n""    join account.holder.users as user\n""    left outer join account.payments as payment\n""where :currentUser = user\n""    and PaymentStatus.UNPAID = isNull(payment.currentStatus.name, ""PaymentStatus.UNPAID)\n""order by account.type.sortOrder, account.accountNumber, payment.dueDate]]>"msgstr ""#. Tag: title#: query_hql.xml:938#, no-c-formatmsgid "Bulk update and delete"msgstr "批量的UPDATE和DELETE"#. Tag: para#: query_hql.xml:940#, no-c-formatmsgid """HQL now supports <literal>update</literal>, <literal>delete</literal> and ""<literal>insert ... select ...</literal> statements. See <xref linkend=""\"batch-direct\"/> fo

⌨️ 快捷键说明

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