📄 query_hql.po
字号:
"current_order\n""FROM customers cust,\n"" stores store,\n"" locations loc,\n"" store_customers sc,\n"" product prod\n""WHERE prod.name = 'widget'\n"" AND store.loc_id = loc.id\n"" AND loc.name IN ( 'Melbourne', 'Sydney' )\n"" AND sc.store_id = store.id\n"" AND sc.cust_id = cust.id\n"" AND prod.id = ALL(\n"" SELECT item.prod_id\n"" FROM line_items item, orders o\n"" WHERE item.order_id = o.id\n"" AND cust.current_order = o.id\n"" )]]>"msgstr ""#. Tag: title#: query_hql.xml:770#, no-c-formatmsgid "The order by clause"msgstr "A clausula order by"#. Tag: para#: query_hql.xml:772#, no-c-formatmsgid """The list returned by a query may be ordered by any property of a returned ""class or components:"msgstr """A lista retornada pela query pode ser ordenada por qualquer propriedade da ""classe ou componente retornado:"#. Tag: programlisting#: query_hql.xml:776#, no-c-formatmsgid """<![CDATA[from DomesticCat cat\n""order by cat.name asc, cat.weight desc, cat.birthdate]]>"msgstr ""#. Tag: para#: query_hql.xml:778#, no-c-formatmsgid """The optional <literal>asc</literal> or <literal>desc</literal> indicate ""ascending or descending order respectively."msgstr """As opções <literal>asc</literal> ou <literal>desc</literal> indicam ordem ""crescente ou decrescente, respectivamente."#. Tag: title#: query_hql.xml:785#, no-c-formatmsgid "The group by clause"msgstr "A clausula group by"#. Tag: para#: query_hql.xml:787#, no-c-formatmsgid """A query that returns aggregate values may be grouped by any property of a ""returned class or components:"msgstr """Uma query que retorne valores agregados, podem ser agrupados por qualquer ""propriedade de uma classe ou componente retornado:"#. Tag: programlisting#: query_hql.xml:791#, 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:793#, 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:795#, no-c-formatmsgid "A <literal>having</literal> clause is also allowed."msgstr "Uma clausula <literal>having</literal> também é permitida."#. Tag: programlisting#: query_hql.xml:799#, 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:801#, 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 """Funções SQL e funções agregadas são permitidas nas clausulas ""<literal>having</literal> e <literal>order by</literal>, se suportadas pelo ""banco de dados subjacente (ex: não no MySQL)."#. Tag: programlisting#: query_hql.xml:807#, 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:809#, 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 """Note que, nem a clausula <literal>group by</literal> ou <literal>order by</""literal>, podem conter expressões aritiméticas."#. Tag: title#: query_hql.xml:821#, no-c-formatmsgid "Subqueries"msgstr "Subqueries"#. Tag: para#: query_hql.xml:823#, 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 """Para bancos de dados que suportem subselects, o Hibernate suporta subqueries ""dentro de queries. Uma subquery precisa estar entre parênteses (normalmente ""uma chamada de função agregada SQL). Mesmo subqueries co-relacionadas ""(subqueries que fazem referência à alias de outras queries), são aceitas."#. Tag: programlisting#: query_hql.xml:829#, 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:831#, 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:833#, 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:835#, 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:837#, 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:839#, no-c-formatmsgid "Note that HQL subqueries may occur only in the select or where clauses."msgstr """Note que HQL subqueries podem aparecer apenas dentro de clausulas select ou ""where."#. Tag: para#: query_hql.xml:843#, 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:851#, no-c-formatmsgid "HQL examples"msgstr "Exemplos de HQL"#. Tag: para#: query_hql.xml:853#, 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 """As queries do Hibernate, podem ser muito poderosas e complexas. De fato, o ""poder da linguagem de querie é um dos pontos principais na distribuição do ""Hibernate. Aqui temos algumas queries de exemplo, muito similares a queries ""que usei em um projeto recente. Note que a maioria das queries que você irá ""escrever, são mais simples que estas."#. Tag: para#: query_hql.xml:859#, 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 """A query a seguir retorna o id de order, numero de itens e o valor total do ""order para todos os orders não pagos para um freguês particular e valor ""total mínimo dado, ordenando os resultados por valor total. Ao determinar os ""preços, é usado o catalogo corrente. A query SQL resultante, usando tabelas ""<literal>ORDER</literal>, <literal>ORDER_LINE</literal>, <literal>PRODUCT</""literal>, <literal>CATALOG</literal> e <literal>PRICE</literal>, tem quatro ""inner joins e um (não correlacionado) subselect."#. Tag: programlisting#: query_hql.xml:868#, 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:870#, 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 """Que monstro! Atualmente, na vida real, eu não sou muito afeiçoado a ""subqueries, então minha query seria mais parecida com isto:"#. Tag: programlisting#: query_hql.xml:875#, 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:877#, 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 """A próxima query conta o número de pagamentos em cada status, tirando todos ""os pagamentos com status <literal>AWAITING_APPROVAL</literal>, onde a mais ""recente mudança de status foi feita pelo usuário corrente. Traduz-se para ""uma query SQL <literal>com</literal> dois inner joins e um subselect ""correlacionado, nas tabelas <literal>PAYMENT</literal>, ""<literal>PAYMENT_STATUS</literal> e <literal>PAYMENT_STATUS_CHANGE</""literal> ."#. Tag: programlisting#: query_hql.xml:885#, 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:887#, 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 """Se eu tivesse mapeado a Collection <literal>statusChanges</literal> como um ""List, ao invés de um Set, a query teria sido muito mais simples de escrever."#. Tag: programlisting#: query_hql.xml:892#, 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:894#, 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 """A próxima query usa a função <literal>isNull()</literal> do MS SQL Server, ""para retornar todas as contas e pagamentos não pagos para a organização, ""para cada usuário corrente pertencente. Traduz-se para uma query SQL ""<literal>com</literal> três inner joins, um outer join e um subselect nas ""tabelas <literal>ACCOUNT</literal>, <literal>PAYMENT</literal>, ""<literal>PAYMENT_STATUS</literal>,<literal>ACCOUNT_TYPE</literal>, ""<literal>ORGANIZATION</literal> e <literal>ORG_USER</literal> ."#. Tag: programlisting#: query_hql.xml:903#, 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"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -