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

📄 performance.po

📁 hibernate 开源框架的代码 jar包希望大家能喜欢
💻 PO
📖 第 1 页 / 共 5 页
字号:
#: performance.xml:179#, no-c-formatmsgid "<![CDATA[<many-to-one name=\"mother\" class=\"Cat\" fetch=\"join\"/>]]>"msgstr ""#. Tag: para#: performance.xml:181#, no-c-formatmsgid """The <literal>fetch</literal> strategy defined in the mapping document ""affects:"msgstr """A estratégia de <literal>fetch</literal> definida no documento de mapeamento ""afeta:"#. Tag: para#: performance.xml:187#, no-c-formatmsgid "retrieval via <literal>get()</literal> or <literal>load()</literal>"msgstr "recupera via <literal>get()</literal> ou <literal>load()</literal>"#. Tag: para#: performance.xml:192#, no-c-formatmsgid "retrieval that happens implicitly when an association is navigated"msgstr """Recuperações que acontecem implicitamente quando navegamos por uma associação"#. Tag: para#: performance.xml:197#, no-c-formatmsgid "<literal>Criteria</literal> queries"msgstr "<literal>Criteria</literal> queries"#. Tag: para#: performance.xml:202#, no-c-formatmsgid "HQL queries if <literal>subselect</literal> fetching is used"msgstr "buscas por HQL se buscar por <literal>subselect</literal> for usado"#. Tag: para#: performance.xml:208#, no-c-formatmsgid """No matter what fetching strategy you use, the defined non-lazy graph is ""guaranteed to be loaded into memory. Note that this might result in several ""immediate selects being used to execute a particular HQL query."msgstr """Independentemente da estratégia de busca que você usar, o grafo não ""preguiçoso definido será garantidamente carregado na memória. Note que isso ""irá resultar em diversos selects imediatos sendo usados em um HQL em ""particular."#. Tag: para#: performance.xml:214#, no-c-formatmsgid """Usually, we don't use the mapping document to customize fetching. Instead, ""we keep the default behavior, and override it for a particular transaction, ""using <literal>left join fetch</literal> in HQL. This tells Hibernate to ""fetch the association eagerly in the first select, using an outer join. In ""the <literal>Criteria</literal> query API, you would use ""<literal>setFetchMode(FetchMode.JOIN)</literal>."msgstr """Usualmente não usamos documentos de mapeamento para customizar as buscas. Ao ""invés disso, nós deixamos o comportamento padrão e sobrescrevemos isso em ""uma transação em particular, usando <literal>left join fetch</literal> no ""HQL. Isso diz ao Hibernate para buscar a associação inteira no primeiro ""select, usando um outer join. Na API de busca <literal>Criteria</literal>, ""você irá usar <literal>setFetchMode(FetchMode.JOIN)</literal>."#. Tag: para#: performance.xml:223#, no-c-formatmsgid """If you ever feel like you wish you could change the fetching strategy used ""by <literal>get()</literal> or <literal>load()</literal>, simply use a ""<literal>Criteria</literal> query, for example:"msgstr """Se você quiser mudar a estratégia de busca usada pelo <literal>get()</""literal> ou <literal>load()</literal>, simplesmente use uma query ""<literal>Criteria</literal>, por exemplo:"#. Tag: programlisting#: performance.xml:229#, no-c-formatmsgid """<![CDATA[User user = (User) session.createCriteria(User.class)\n""                .setFetchMode(\"permissions\", FetchMode.JOIN)\n""                .add( Restrictions.idEq(userId) )\n""                .uniqueResult();]]>"msgstr ""#. Tag: para#: performance.xml:231#, no-c-formatmsgid """(This is Hibernate's equivalent of what some ORM solutions call a \"fetch ""plan\".)"msgstr """(Isto é o equivalente do Hibernate para o que algumas soluções ORM chamam de ""\"plano de busca\")"#. Tag: para#: performance.xml:235#, no-c-formatmsgid """A completely different way to avoid problems with N+1 selects is to use the ""second-level cache."msgstr """Um meio totalmente diferente de evitar problemas com selects N+1 é usar um ""cache de segundo nível."#. Tag: title#: performance.xml:243#, no-c-formatmsgid "Single-ended association proxies"msgstr "Proxies de associação single-ended"#. Tag: para#: performance.xml:245#, no-c-formatmsgid """Lazy fetching for collections is implemented using Hibernate's own ""implementation of persistent collections. However, a different mechanism is ""needed for lazy behavior in single-ended associations. The target entity of ""the association must be proxied. Hibernate implements lazy initializing ""proxies for persistent objects using runtime bytecode enhancement (via the ""excellent CGLIB library)."msgstr """A recuperação preguiçosa para coleções é implementada usando uma ""implementação própria do Hibernate para coleções persistentes. Porém, um ""mecanismo diferente é necessário para comportamento preguiçoso para ""associações de um lado só. A entidade alvo da associação precisa usar um ""proxy. O Hibernate implementa proxies para inicialização preguiçosa em ""objetos persistentes usando manipulação de bytecode (via a excelente ""biblioteca CGLIB)."#. Tag: para#: performance.xml:253#, no-c-formatmsgid """By default, Hibernate3 generates proxies (at startup) for all persistent ""classes and uses them to enable lazy fetching of <literal>many-to-one</""literal> and <literal>one-to-one</literal> associations."msgstr """Por padrão, o Hibernate3 gera proxies (na inicialização) para todas as ""classes persistentes que usem eles para habilitar recuperaçãopreguiçosa de ""associações <literal>many-to-one</literal> e <literal>one-to-one</literal>."#. Tag: para#: performance.xml:259#, no-c-formatmsgid """The mapping file may declare an interface to use as the proxy interface for ""that class, with the <literal>proxy</literal> attribute. By default, ""Hibernate uses a subclass of the class. <emphasis>Note that the proxied ""class must implement a default constructor with at least package visibility. ""We recommend this constructor for all persistent classes!</emphasis>"msgstr """O arquivo de mapeamento deve declaram uma interface para usar como interface ""de proxy para aquela classe, com o atributo <literal>proxy</literal>. Por ""padrão, o Hibernate usa uma subclasse dessa classe. <emphasis>Note que a ""classe a ser usada via proxy precisa implementar o construtor padrão com ""pelo menos visibilidade de package. Nós recomendamos esse construtor para ""todas as classes persistentes!</emphasis>"#. Tag: para#: performance.xml:266#, no-c-formatmsgid """There are some gotchas to be aware of when extending this approach to ""polymorphic classes, eg."msgstr """Existe alguns truques que você deve saber quando extender esse comportamento ""para classes polimórficas, dessa maneira:"#. Tag: programlisting#: performance.xml:271#, no-c-formatmsgid """<![CDATA[<class name=\"Cat\" proxy=\"Cat\">\n""    ......\n""    <subclass name=\"DomesticCat\">\n""        .....\n""    </subclass>\n""</class>]]>"msgstr ""#. Tag: para#: performance.xml:273#, no-c-formatmsgid """Firstly, instances of <literal>Cat</literal> will never be castable to ""<literal>DomesticCat</literal>, even if the underlying instance is an ""instance of <literal>DomesticCat</literal>:"msgstr """Primeiramente, instâncias de <literal>Cat</literal> nunca seráo convertidas ""para <literal>DomesticCat</literal>, mesmo que a instância em questão seja ""uma estância de <literal>DomesticCat</literal>:"#. Tag: programlisting#: performance.xml:279#, no-c-formatmsgid """<![CDATA[Cat cat = (Cat) session.load(Cat.class, id);  // instantiate a ""proxy (does not hit the db)\n""if ( cat.isDomesticCat() ) {                  // hit the db to initialize ""the proxy\n""    DomesticCat dc = (DomesticCat) cat;       // Error!\n""    ....\n""}]]>"msgstr ""#. Tag: para#: performance.xml:281#, no-c-formatmsgid "Secondly, it is possible to break proxy <literal>==</literal>."msgstr "É possível quebrar o proxy <literal>==</literal>."#. Tag: programlisting#: performance.xml:285#, no-c-formatmsgid """<![CDATA[Cat cat = (Cat) session.load(Cat.class, id);            // ""instantiate a Cat proxy\n""DomesticCat dc = \n""        (DomesticCat) session.load(DomesticCat.class, id);  // acquire new ""DomesticCat proxy!\n""System.out.println(cat==dc);                            // false]]>"msgstr ""#. Tag: para#: performance.xml:287#, no-c-formatmsgid """However, the situation is not quite as bad as it looks. Even though we now ""have two references to different proxy objects, the underlying instance will ""still be the same object:"msgstr """Porém a situação não é tão ruim como parece. Mesmo quando temos duas ""referências para objetos proxies diferentes, a instância deles será o mesmo ""objeto"#. Tag: programlisting#: performance.xml:292#, no-c-formatmsgid """<![CDATA[cat.setWeight(11.0);  // hit the db to initialize the proxy\n""System.out.println( dc.getWeight() );  // 11.0]]>"msgstr ""#. Tag: para#: performance.xml:294#, no-c-formatmsgid """Third, you may not use a CGLIB proxy for a <literal>final</literal> class or ""a class with any <literal>final</literal> methods."msgstr """Terceiro, Você não pode usar um proxy CGLIB em uma classe <literal>final</""literal> ou com qualquer método <literal>final</literal>."#. Tag: para#: performance.xml:299#, no-c-formatmsgid """Finally, if your persistent object acquires any resources upon instantiation ""(eg. in initializers or default constructor), then those resources will also ""be acquired by the proxy. The proxy class is an actual subclass of the ""persistent class."msgstr """Finalmente, se o seu objeto persistente adquirir qualquer recursto durante a ""instanciação (em inicializadores ou construtor padrão), então esses recursos ""serão adquiridos pelo proxy também. A classe de proxy é uma subclasse da ""classe persistente."#. Tag: para#: performance.xml:305#, no-c-formatmsgid """These problems are all due to fundamental limitations in Java's single ""inheritance model. If you wish to avoid these problems your persistent ""classes must each implement an interface that declares its business methods. ""You should specify these interfaces in the mapping file. eg."msgstr """Esses problemas são todos devido a limitação fundamental do modelo de ""herança simples do Java. Se você quiser evitar esse problemas em suas ""classes persistentes você deve imeplementar uma interface que declare seus ""métodos de negócio. Você deve especificar essas interfaces no arquivo de ""mapeamento. Ex:"#. Tag: programlisting#: performance.xml:311#, no-c-formatmsgid """<![CDATA[<class name=\"CatImpl\" proxy=\"Cat\">\n""    ......\n""    <subclass name=\"DomesticCatImpl\" proxy=\"DomesticCat\">\n""        .....\n""    </subclass>\n""</class>]]>"msgstr ""#. Tag: para#: performance.xml:313#, no-c-formatmsgid """where <literal>CatImpl</literal> implements the interface <literal>Cat</""literal> and <literal>DomesticCatImpl</literal> implements the interface ""<literal>DomesticCat</literal>. Then proxies for instances of <literal>Cat</""literal> and <literal>DomesticCat</literal> may be returned by <literal>load""()</literal> or <literal>iterate()</literal>. (Note that <literal>list()</""literal> does not usually return proxies.)"msgstr """onde <literal>CatImpl</literal> implementa a interface <literal>Cat</""literal> e <literal>DomesticCatImpl</literal> implementa a interface ""<literal>DomesticCat</literal>. Então proxies para instâncias de ""<literal>Cat</literal> e <literal>DomesticCat</literal> serão retornadas por ""<literal>load()</literal> ou <literal>iterate()</literal>. (Note que ""<literal>list()</literal> geralmente não retorna proxies)."#. Tag: programlisting#: performance.xml:321#, no-c-formatmsgid """<![CDATA[Cat cat = (Cat) session.load(CatImpl.class, catid);\n""Iterator iter = session.createQuery(\"from CatImpl as cat where cat.""name='fritz'\").iterate();\n""Cat fritz = (Cat) iter.next();]]>"msgstr ""#. Tag: para#: performance.xml:323#, no-c-formatmsgid """Relationships are also lazily initialized. This means you must declare any ""properties to be of type <literal>Cat</literal>, not <literal>CatImpl</""literal>."msgstr """Relacionamentos são também carregados preguiçosamente. Isso significa que ""você precisa declarar qualquer propriedade como sendo do tipo <literal>Cat</""literal>, e não <literal>CatImpl</literal>."#. Tag: para#: performance.xml:328#, no-c-format

⌨️ 快捷键说明

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