📄 performance.po
字号:
"où <literal>CatImpl</literal> implémente l'interface <literal>Cat</literal> ""et <literal>DomesticCatImpl</literal> implémente l'interface ""<literal>DomesticCat</literal>. Ainsi, des proxys pour les instances de ""<literal>Cat</literal> et <literal>DomesticCat</literal> pourraient être ""retournées par <literal>load()</literal> ou <literal>iterate()</literal> ""(Notez que <literal>list()</literal> ne retourne généralement pas de proxy)."#. Tag: programlisting#: performance.xml:345#, 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:347#, 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 """Les relations sont aussi initialisées tardivement. Ceci signifie que vous ""devez déclarer chaque propriété comme étant de type <literal>Cat</literal>, ""et non <literal>CatImpl</literal>."#. Tag: para#: performance.xml:352#, no-c-formatmsgid """Certain operations do <emphasis>not</emphasis> require proxy initialization"msgstr "Certaines opérations ne nécessitent pas l'initialisation du proxy"#. Tag: para#: performance.xml:358#, no-c-formatmsgid """<literal>equals()</literal>, if the persistent class does not override ""<literal>equals()</literal>"msgstr """<literal>equals()</literal>, si la classe persistante ne surcharge pas ""<literal>equals()</literal>"#. Tag: para#: performance.xml:364#, no-c-formatmsgid """<literal>hashCode()</literal>, if the persistent class does not override ""<literal>hashCode()</literal>"msgstr """<literal>hashCode()</literal>, si la classe persistante ne surcharge pas ""<literal>hashCode()</literal>"#. Tag: para#: performance.xml:370#, no-c-formatmsgid "The identifier getter method"msgstr "Le getter de l'identifiant"#. Tag: para#: performance.xml:376#, no-c-formatmsgid """Hibernate will detect persistent classes that override <literal>equals()</""literal> or <literal>hashCode()</literal>."msgstr """Hibernate détectera les classes qui surchargent <literal>equals()</literal> ""ou <literal>hashCode()</literal>."#. Tag: para#: performance.xml:381#, 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 """Eh choisissant <literal>lazy=\"no-proxy\"</literal> au lieu de <literal>lazy=""\"proxy\"</literal> qui est la valeur par défaut, il est possible d'éviter ""les problèmes liés au transtypage. Il faudra alors une instrumentation du ""bytecode à la compilation et toutes les opérations résulterons immédiatement ""en une initialisation du proxy."#. Tag: title#: performance.xml:391#, no-c-formatmsgid "Initializing collections and proxies"msgstr "Initialisation des collections et des proxys"#. Tag: para#: performance.xml:393#, 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 """Une exception de type <literal>LazyInitializationException</literal> sera ""renvoyée par hibernate si une collection ou un proxy non initialisé est ""accédé en dehors de la portée de la <literal>Session</literal>, e.g. lorsque ""l'entité à laquelle appartient la collection ou qui a une référence vers le ""proxy est dans l'état \"détachée\"."#. Tag: para#: performance.xml:399#, 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 """Parfois, nous devons nous assurer qu'un proxy ou une collection est ""initialisée avant de fermer la <literal>Session</literal>. Bien sûr, nous ""pouvons toujours forcer l'initialisation en appelant par exemple ""<literal>cat.getSex()</literal> ou <literal>cat.getKittens().size()</""literal>. Mais ceci n'est pas très lisible pour les personnes parcourant le ""code et n'est pas très générique."#. Tag: para#: performance.xml:406#, 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 """Les méthodes statiques <literal>Hibernate.initialize()</literal> et ""<literal>Hibernate.isInitialized()</literal> fournissent à l'application un ""moyen de travailler avec des proxys ou des collections initialisés. ""<literal>Hibernate.initialize(cat)</literal> forcera l'initialisation d'un ""proxy de <literal>cat</literal>, si tant est que sa <literal>Session</""literal> est ouverte. <literal>Hibernate.initialize( cat.getKittens() )</""literal> a le même effet sur la collection kittens."#. Tag: para#: performance.xml:415#, 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 """Une autre option est de conserver la <literal>Session</literal> ouverte ""jusqu'à ce que toutes les collections et tous les proxys aient été chargés. ""Dans certaines architectures applicatives, particulièrement celles ou le ""code d'accès aux données via hiberante et le code qui utilise ces données ""sont dans des couches applicatives différentes ou des processus physiques ""différents, il peut devenir problématique de garantir que la ""<literal>Session</literal> est ouverte lorsqu'une collection est ""initialisée. Il y a deux moyens de traiter ce problème :"#. Tag: para#: performance.xml:426#, 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 """Dans une application web, un filtre de servlet peut être utilisé pour fermer ""la <literal>Session</literal> uniquement lorsque la requête a été ""entièrement traitée, lorsque le rendu de la vue est fini (il s'agit du ""pattern <emphasis>Open Session in View</emphasis>). Bien sûr, cela demande ""plus d'attention à la bonne gestion des exceptions de l'application. Il est ""d'une importance vitale que la <literal>Session</literal> soit fermée et la ""transaction terminée avant que l'on rende la main à l'utilisateur même si ""une exception survient durant le traitement de la vue. Voir le wiki ""Hibernate pour des exemples sur le pattern \"Open Session in View\"."#. Tag: para#: performance.xml:439#, 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 """Dans une application avec une couche métier séparée, la couche contenant la ""logique métier doit \"préparer\" toutes les collections qui seront ""nécessaires à la couche web avant de retourner les données. Cela signifie ""que la couche métier doit charger toutes les données et retourner toutes les ""données déjà initialisées à la couche de présentation/web pour un cas ""d'utilisation donné. En général l'application appelle la méthode ""<literal>Hibernate.initialize()</literal> pour chaque collection nécessaire ""dans la couche web (cet appel doit être fait avant la fermeture de la ""session) ou bien récupère les collections de manière agressive à l'aide ""d'une requête HQL avec une clause <literal>FETCH</literal> ou à l'aide du ""mode <literal>FetchMode.JOIN</literal> pour une requête de type ""<literal>Criteria</literal>. Cela est en général plus facile si vous ""utilisez le pattern <emphasis>Command</emphasis> plutôt que ""<emphasis>Session Facade</emphasis>."#. Tag: para#: performance.xml:454#, 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 """Vous pouvez également attacher à une <literal>Session</literal> un objet ""chargé au préalable à l'aide des méthodes <literal>merge()</literal> ou ""<literal>lock()</literal> avant d'accéder aux collections (ou aux proxys) ""non initialisés. Non, Hibernate ne fait pas, et ne doit pas faire, cela ""automatiquement car cela pourrait introduire une sémantique transactionnelle ""ad hoc."#. Tag: para#: performance.xml:464#, 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 """Parfois, vous ne voulez pas initialiser une grande collection mais vous avez ""quand même besoin d'informations sur elle (comme sa taille) ou un sous ""ensemble de ses données"#. Tag: para#: performance.xml:469#, no-c-formatmsgid """You can use a collection filter to get the size of a collection without ""initializing it:"msgstr """Vous pouvez utiliser un filtre de collection pour récupérer sa taille sans ""l'initialiser :"#. Tag: programlisting#: performance.xml:473#, no-c-formatmsgid """<![CDATA[( (Integer) s.createFilter( collection, \"select count(*)\" ).list""().get(0) ).intValue()]]>"msgstr ""#. Tag: para#: performance.xml:475#, 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 """La méthode <literal>createFilter()</literal> est également utilisée pour ""récupérer de manière efficace des sous ensembles d'une collection sans avoir ""besoin de l'initialiser dans son ensemble."#. Tag: programlisting#: performance.xml:480#, no-c-formatmsgid """<![CDATA[s.createFilter( lazyCollection, \"\").setFirstResult(0).""setMaxResults(10).list();]]>"msgstr ""#. Tag: title#: performance.xml:485#, no-c-formatmsgid "Using batch fetching"msgstr "Utiliser le chargement par lot"#. Tag: para#: performance.xml:487#, 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 """Pour améliorer les performances, Hibernate peut utiliser le chargement par ""lot ce qui veut dire qu'Hibernate peut charger plusieurs proxys (ou ""collections) non initialisés en une seule requête lorsque l'on accède à l'un ""de ces proxys. Le chargement par lot est une optimisation intimement liée à ""la stratégie de chargement tardif par select. Il y a deux moyens d'activer ""le chargement par lot : au niveau de la classe et au niveau de la collection."#. Tag: para#: performance.xml:493#, 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 """Le chargement par lot pour les classes/entités est plus simple à comprendre. ""Imaginez que vous ayez la situation suivante à l'exécution : vous avez 25 ""instances de <literal>Cat</literal> chargées dans une <literal>Session</""literal>, chaque <literal>Cat</literal> a une référence à son ""<literal>owner</literal>, une <literal>Person</literal>. La classe ""<literal>Person</literal> est mappée avec un proxy, <literal>lazy=\"true\"</""literal>. Si vous itérez sur tous les cats et appelez <literal>getOwner()</""literal> sur chacun d'eux, Hibernate exécutera par défaut 25 ""<literal>SELECT</literal>, pour charger les owners (initialiser le proxy). ""Vous pouvez paramétrer ce comportement en spécifiant une <literal>batch-""size</literal> (taille du lot) dans le mapping de <literal>Person</literal> :"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -