📄 performance.po
字号:
msgid """Certain operations do <emphasis>not</emphasis> require proxy initialization"msgstr """Algumas operações <emphasis>não</emphasis> requerem inicialização por proxy:"#. Tag: para#: performance.xml:334#, no-c-formatmsgid """<literal>equals()</literal>, if the persistent class does not override ""<literal>equals()</literal>"msgstr """<literal>equals()</literal>, se a classe persistente não sobrescrever ""<literal>equals()</literal>"#. Tag: para#: performance.xml:340#, no-c-formatmsgid """<literal>hashCode()</literal>, if the persistent class does not override ""<literal>hashCode()</literal>"msgstr """<literal>hashCode()</literal>, se a classe persistente não sobrescrever ""<literal>hashCode()</literal>"#. Tag: para#: performance.xml:346#, no-c-formatmsgid "The identifier getter method"msgstr "O método getter do identificador"#. Tag: para#: performance.xml:352#, no-c-formatmsgid """Hibernate will detect persistent classes that override <literal>equals()</""literal> or <literal>hashCode()</literal>."msgstr """O Hibernate irá detectar classes persistentes que sobrescrevem ""<literal>equals()</literal> ou <literal>hashCode()</literal>."#. Tag: para#: performance.xml:357#, no-c-formatmsgid """By choosing <literal>lazy=\"no-proxy\"</literal> instead of the default ""<literal>lazy=\"proxy\"</literal>, we can avoid the problems associated with ""typecasting. However, we will require buildtime bytecode instrumentation, ""and all operations will result in immediate proxy initialization."msgstr """Escolhendo <literal>lazy=\"no-proxy\"</literal> ao invés do padrão ""<literal>lazy=\"proxy\"</literal>, podemos evitar problemas associados com ""typecasting. Porém, iremos precisar de instrumentação de bytecode em tempo ""de compilação e todas as operações irão resultar em iniciazações de proxy ""imediatas."#. Tag: title#: performance.xml:367#, no-c-formatmsgid "Initializing collections and proxies"msgstr "Inicializando coleções e proxies"#. Tag: para#: performance.xml:369#, no-c-formatmsgid """A <literal>LazyInitializationException</literal> will be thrown by Hibernate ""if an uninitialized collection or proxy is accessed outside of the scope of ""the <literal>Session</literal>, ie. when the entity owning the collection or ""having the reference to the proxy is in the detached state."msgstr """Será lançada uma <literal>LazyInitializationException</literal> se uma ""coleção não inicializada ou proxy é acessado fora do escopo da ""<literal>Session</literal>, isto é, quando a entidade que contém a coleção ""ou tem a referência ao proxy estiver no estado destachado."#. Tag: para#: performance.xml:375#, no-c-formatmsgid """Sometimes we need to ensure that a proxy or collection is initialized before ""closing the <literal>Session</literal>. Of course, we can alway force ""initialization by calling <literal>cat.getSex()</literal> or <literal>cat.""getKittens().size()</literal>, for example. But that is confusing to readers ""of the code and is not convenient for generic code."msgstr """Algumas vezes precisamos garantir qie o proxy ou coleção é inicializado ""antes de se fechar a <literal>Session</literal>. Claro que sempre podemos ""forçar a inicialização chamando <literal>cat.getSex()</literal> ou ""<literal>cat.getKittens().size()</literal>, por exemplo. Mas isto parece ""confuso para quem lê o código e não é conveniente para códigos genéricos."#. Tag: para#: performance.xml:382#, no-c-formatmsgid """The static methods <literal>Hibernate.initialize()</literal> and ""<literal>Hibernate.isInitialized()</literal> provide the application with a ""convenient way of working with lazily initialized collections or proxies. ""<literal>Hibernate.initialize(cat)</literal> will force the initialization ""of a proxy, <literal>cat</literal>, as long as its <literal>Session</""literal> is still open. <literal>Hibernate.initialize( cat.getKittens() )</""literal> has a similar effect for the collection of kittens."msgstr """Os métodos estáticos <literal>Hibernate.initialize()</literal> e ""<literal>Hibernate.isInitialized()</literal> possibilitam a aplicação uma ""maneira conveniente de trabalhar com coleções inicializadas preguiçosamente ""e proxies. <literal>Hibernate.initialize(cat)</literal> irá forçar a ""inicialização de um proxy, <literal>cat</literal>, contanto que a ""<literal>Session</literal> esteja ainda aberta. <literal>Hibernate.initialize""( cat.getKittens() )</literal> tem um efeito similar para a coleção de ""kittens."#. Tag: para#: performance.xml:391#, no-c-formatmsgid """Another option is to keep the <literal>Session</literal> open until all ""needed collections and proxies have been loaded. In some application ""architectures, particularly where the code that accesses data using ""Hibernate, and the code that uses it are in different application layers or ""different physical processes, it can be a problem to ensure that the ""<literal>Session</literal> is open when a collection is initialized. There ""are two basic ways to deal with this issue:"msgstr """Outra opção é manter a <literal>Session</literal> aberta até que todas as ""coleções e proxies necessários sejam carregados. Em algumas arquiteturas de ""aplicações, particularmente onde o código que acessa os dados usando ""Hibernate e o código que usa os dados estão em diferentes camadas da ""aplicação ou diferentes processos físicos, será um problema garantir que a ""<literal>Session</literal> esteja aberta quando uma coleção for ""inicializada. Existem dois caminhos básicos para lidar com esse problema:"#. Tag: para#: performance.xml:402#, no-c-formatmsgid """In a web-based application, a servlet filter can be used to close the ""<literal>Session</literal> only at the very end of a user request, once the ""rendering of the view is complete (the <emphasis>Open Session in View</""emphasis> pattern). Of course, this places heavy demands on the correctness ""of the exception handling of your application infrastructure. It is vitally ""important that the <literal>Session</literal> is closed and the transaction ""ended before returning to the user, even when an exception occurs during ""rendering of the view. See the Hibernate Wiki for examples of this \"Open ""Session in View\" pattern."msgstr """Em aplicações web, um filtro servlet pode ser usado para fechar a ""<literal>Session</literal> somente no final da requisição do usuário, já que ""a renderização da visão estará completa (o pattern <emphasis>Open Session In ""View</emphasis>). Claro, que isto cria a necessidade de um correto manuseio ""de exceções na infraestrutura de sua aplicação. É vitalmente importante que ""a <literal>Session</literal> esteja fechada e a transação terminada antes de ""retornar para o usuário, mesmo que uma exceção ocorra durante a renderização ""da view. Veja o Wiki do Hibernate para exemplos do pattern \"Open Session In ""View\""#. Tag: para#: performance.xml:415#, no-c-formatmsgid """In an application with a separate business tier, the business logic must ""\"prepare\" all collections that will be needed by the web tier before ""returning. This means that the business tier should load all the data and ""return all the data already initialized to the presentation/web tier that is ""required for a particular use case. Usually, the application calls ""<literal>Hibernate.initialize()</literal> for each collection that will be ""needed in the web tier (this call must occur before the session is closed) ""or retrieves the collection eagerly using a Hibernate query with a ""<literal>FETCH</literal> clause or a <literal>FetchMode.JOIN</literal> in ""<literal>Criteria</literal>. This is usually easier if you adopt the ""<emphasis>Command</emphasis> pattern instead of a <emphasis>Session Facade</""emphasis>."msgstr """Em uma aplicação com uma camada de negócios separada, a lógica de negócios ""deve \"preparar\" todas as coleções que serão usadas pela camada web antes ""de retornar. Isto sgnifica que a camada de negócios deve carregar todos os ""dados e retorná-los já inicializados para a camada de apresentação. ""Usualmente a aplicação chama <literal>Hibernate.initialize()</literal> para ""cada coleção que será usada pela camada web (essa chamada de método deve ""ocorrer antes da sessão ser fechada ou retornar a coleção usando uma ""consulta Hibernate com uma cláusula <literal>FETCH</literal> ou um ""<literal>FetchMode.JOIN</literal> na <literal>Criteria</literal>. Fica muito ""mais fácil se você adotar o pattern <emphasis>Command</emphasis> ao invés do ""<emphasis>Session Facade</emphasis>."#. Tag: para#: performance.xml:430#, no-c-formatmsgid """You may also attach a previously loaded object to a new <literal>Session</""literal> with <literal>merge()</literal> or <literal>lock()</literal> before ""accessing uninitialized collections (or other proxies). No, Hibernate does ""not, and certainly <emphasis>should</emphasis> not do this automatically, ""since it would introduce ad hoc transaction semantics!"msgstr """Você também pode anexar um objeto prevaimente carregado em uma nova ""<literal>Session</literal><literal>merge()</literal> or <literal>lock()</""literal> antes de acessar coleções não inicializadas (ou outros proxies). O ""Hibernate não faz e certamente <literal>não deve</literal> isso ""automaticamente pois isso introduziria semantica em transações ad hoc."#. Tag: para#: performance.xml:440#, no-c-formatmsgid """Sometimes you don't want to initialize a large collection, but still need ""some information about it (like its size) or a subset of the data."msgstr """As vezes você não quer inicializar uma coleção muito grande, mas precisa de ""algumas informações (como o tamanho) ou alguns de seus dados."#. Tag: para#: performance.xml:445#, no-c-formatmsgid """You can use a collection filter to get the size of a collection without ""initializing it:"msgstr """Você pode usar um filtro de coleção para saber seu tamanho sem a inicializar:"#. Tag: programlisting#: performance.xml:449#, no-c-formatmsgid """<![CDATA[( (Integer) s.createFilter( collection, \"select count(*)\" ).list""().get(0) ).intValue()]]>"msgstr ""#. Tag: para#: performance.xml:451#, no-c-formatmsgid """The <literal>createFilter()</literal> method is also used to efficiently ""retrieve subsets of a collection without needing to initialize the whole ""collection:"msgstr """O método <literal>createFilter()</literal> é usado também para retornar ""algus dados de uma coleção eficientemente sem precisar inicializar a coleção ""inteira:"#. Tag: programlisting#: performance.xml:456#, no-c-formatmsgid """<![CDATA[s.createFilter( lazyCollection, \"\").setFirstResult(0).""setMaxResults(10).list();]]>"msgstr ""#. Tag: title#: performance.xml:461#, no-c-formatmsgid "Using batch fetching"msgstr "Usando busca em lote"#. Tag: para#: performance.xml:463#, no-c-formatmsgid """Hibernate can make efficient use of batch fetching, that is, Hibernate can ""load several uninitialized proxies if one proxy is accessed (or collections. ""Batch fetching is an optimization of the lazy select fetching strategy. ""There are two ways you can tune batch fetching: on the class and the ""collection level."msgstr """O Hibernate pode fazer uso eficiente de busca em lote, isto é, o Hibernate ""pode carregar diversos proxies não inicializados se um proxy é acessado (ou ""coleções. A busca em lote é uma otimização da estratégia de select ""fetching). Existe duas maneiras em que você pode usar busca em lote: no ""nível da classe ou no nível da coleção."#. Tag: para#: performance.xml:469#, no-c-formatmsgid """Batch fetching for classes/entities is easier to understand. Imagine you ""have the following situation at runtime: You have 25 <literal>Cat</literal> ""instances loaded in a <literal>Session</literal>, each <literal>Cat</""literal> has a reference to its <literal>owner</literal>, a <literal>Person</""literal>. The <literal>Person</literal> class is mapped with a proxy, ""<literal>lazy=\"true\"</literal>. If you now iterate through all cats and ""call <literal>getOwner()</literal> on each, Hibernate will by default ""execute 25 <literal>SELECT</literal> statements, to retrieve the proxied ""owners. You can tune this behavior by specifying a <literal>batch-size</""literal> in the mapping of <literal>Person</literal>:"msgstr """A recuperação em lote para classes/entidades é mais fácil de entender. ""Imagine que você tem a seguinte situação em tempo de execução: Você tem 25 ""instâncias de <literal>Cat</literal> carregadas em uma <literal>Session</""literal>, cada <literal>Cat</literal> tem uma referência ao seu ""<literal>owner</literal>, que é da classe <literal>Person</literal>. A ""classe <literal>Person</literal> é mapeada com um proxy, <literal>lazy=\"true""\"</literal>. Se você iterar sobre todos os Cat's e chamar <literal>getOwner""()</literal> em cada, o Hibernate irá por padrão executar 25 comandos ""<literal>SELECT()</literal>, para buscar os proxies de owners. Você pode ""melhorar esse comportamento especificando um <literal>batch-size</literal> ""no mapeamento da classe <literal>Person</literal>:"#. Tag: programlisting#: performance.xml:479#, no-c-formatmsgid "<![CDATA[<class name=\"Person\" batch-size=\"10\">...</class>]]>"msgstr ""#. Tag: para#: performance.xml:481#, no-c-formatmsgid """Hibernate will now execute only three queries, the pattern is 10, 10, 5."msgstr """O Hibernate irá executar agora apenas três consultas, buscando por vez, 10, ""10 e 5 Person."#. Tag: para#: performance.xml:485#, no-c-formatmsgid """You may also enable batch fetching of collections. For example, if each ""<literal>Person</literal> has a lazy collection of <literal>Cat</literal>s, ""and 10 persons are currently loaded in the <literal>Sesssion</literal>, ""iterating through all persons will generate 10 <literal>SELECT</literal>s, ""one for every call to <literal>getCats()</literal>. If you enable batch ""fetching for the <literal>cats</literal> collection in the mapping of ""<literal>Person</literal>, Hibernate can pre-fetch collections:"msgstr """Você também pode habilitar busca em lote de uma coleção. Por exemplo, se ""cada <literal>Person</literal> tem uma coleção preguiçosa de <literal>Cat</""literal>s, e 10 pessoas estão já carregados em uma <literal>Sesssion</""literal>, serão gerados 10 <literal>SELECT</literal>s ao se iterar todas as ""pessoas, um para cada chamada de <literal>getCats()</literal>.. Se você ""habilitar busca em lote para a coleção de <literal>cats</literal> no ""mapeamento da classe <literal>Person</literal>, o Hibernate pode fazer uma ""pré carga das coleções:"#. Tag: programlisting#: performance.xml:494#, no-c-formatmsgid """<![CDATA[<class name=\"Person\">\n"" <set name=\"cats\" batch-size=\"3\">\n"" ...\n"" </set>\n""</class>]]>"msgstr ""#. Tag: para
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -