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

📄 performance.pot

📁 hibernate 开源框架的代码 jar包希望大家能喜欢
💻 POT
📖 第 1 页 / 共 4 页
字号:
#: performance.xml:365(para) msgid "Certain operations do <emphasis>not</emphasis> require proxy initialization"msgstr ""#: performance.xml:371(para) msgid "<literal>equals()</literal>, if the persistent class does not override <literal>equals()</literal>"msgstr ""#: performance.xml:377(para) msgid "<literal>hashCode()</literal>, if the persistent class does not override <literal>hashCode()</literal>"msgstr ""#: performance.xml:383(para) msgid "The identifier getter method"msgstr ""#: performance.xml:389(para) msgid "Hibernate will detect persistent classes that override <literal>equals()</literal> or <literal>hashCode()</literal>."msgstr ""#: performance.xml:394(para) msgid "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 ""#: performance.xml:404(title) msgid "Initializing collections and proxies"msgstr ""#: performance.xml:406(para) msgid "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 ""#: performance.xml:412(para) msgid "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 ""#: performance.xml:419(para) msgid "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 ""#: performance.xml:428(para) msgid "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 ""#: performance.xml:439(para) msgid "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 ""#: performance.xml:452(para) msgid "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 ""#: performance.xml:467(para) msgid "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 ""#: performance.xml:477(para) msgid "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 ""#: performance.xml:482(para) msgid "You can use a collection filter to get the size of a collection without initializing it:"msgstr ""#: performance.xml:488(para) msgid "The <literal>createFilter()</literal> method is also used to efficiently retrieve subsets of a collection without needing to initialize the whole collection:"msgstr ""#: performance.xml:498(title) msgid "Using batch fetching"msgstr ""#: performance.xml:500(para) msgid "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 ""#: performance.xml:506(para) msgid "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 ""#: performance.xml:518(para) msgid "Hibernate will now execute only three queries, the pattern is 10, 10, 5."msgstr ""#: performance.xml:522(para) msgid "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 ""#: performance.xml:537(para) msgid "With a <literal>batch-size</literal> of 3, Hibernate will load 3, 3, 3, 1 collections in four <literal>SELECT</literal>s. Again, the value of the attribute depends on the expected number of uninitialized collections in a particular <literal>Session</literal>."msgstr ""#: performance.xml:543(para) msgid "Batch fetching of collections is particularly useful if you have a nested tree of items, ie. the typical bill-of-materials pattern. (Although a <emphasis>nested set</emphasis> or a <emphasis>materialized path</emphasis> might be a better option for read-mostly trees.)"msgstr ""#: performance.xml:552(title) msgid "Using subselect fetching"msgstr ""#: performance.xml:554(para) msgid "If one lazy collection or single-valued proxy has to be fetched, Hibernate loads all of them, re-running the original query in a subselect. This works in the same way as batch-fetching, without the piecemeal loading."msgstr ""#: performance.xml:565(title) msgid "Using lazy property fetching"msgstr ""#: performance.xml:567(para) msgid "Hibernate3 supports the lazy fetching of individual properties. This optimization technique is also known as <emphasis>fetch groups</emphasis>. Please note that this is mostly a marketing feature, as in practice, optimizing row reads is much more important than optimization of column reads. However, only loading some properties of a class might be useful in extreme cases, when legacy tables have hundreds of columns and the data model can not be improved."msgstr ""#: performance.xml:576(para) msgid "To enable lazy property loading, set the <literal>lazy</literal> attribute on your particular property mappings:"msgstr ""#: performance.xml:590(para) msgid "Lazy property loading requires buildtime bytecode instrumentation! If your persistent classes are not enhanced, Hibernate will silently ignore lazy property settings and fall back to immediate fetching."msgstr ""#: performance.xml:596(para) msgid "For bytecode instrumentation, use the following Ant task:"msgstr ""#: performance.xml:614(para) msgid "A different (better?) way to avoid unnecessary column reads, at least for read-only transactions is to use the projection features of HQL or Criteria queries. This avoids the need for buildtime bytecode processing and is certainly a prefered solution."msgstr ""#: performance.xml:621(para) msgid "You may force the usual eager fetching of properties using <literal>fetch all properties</literal> in HQL."msgstr ""#: performance.xml:631(title) msgid "The Second Level Cache"msgstr ""#: performance.xml:633(para) msgid "A Hibernate <literal>Session</literal> is a transaction-level cache of persistent data. It is possible to configure a cluster or JVM-level (<literal>SessionFactory</literal>-level) cache on a class-by-class and collection-by-collection basis. You may even plug in a clustered cache. Be careful. Caches are never aware of changes made to the persistent store by another application (though they may be configured to regularly expire cached data)."msgstr ""#: performance.xml:641(para) msgid "You have the option to tell Hibernate which caching implementation to use by specifying the name of a class that implements <literal>org.hibernate.cache.CacheProvider</literal> using the property <literal>hibernate.cache.provider_class</literal>. Hibernate comes bundled with a number of built-in integrations with open-source cache providers (listed below); additionally, you could implement your own and plug it in as outlined above. Note that versions prior to 3.2 defaulted to use EhCache as the default cache provider; that is no longer the case as of 3.2."msgstr ""#: performance.xml:652(title) msgid "Cache Providers"msgstr ""#: performance.xml:661(entry) performance.xml:848(entry) msgid "Cache"msgstr ""#: performance.xml:662(entry) msgid "Provider class"msgstr ""#: performance.xml:663(entry) msgid "Type"msgstr ""#: performance.xml:664(entry) msgid "Cluster Safe"msgstr ""#: performance.xml:665(entry) msgid "Query Cache Supported"msgstr ""#: performance.xml:670(entry) performance.xml:857(entry) msgid "Hashtable (not intended for production use)"msgstr ""#: performance.xml:671(literal) msgid "org.hibernate.cache.HashtableCacheProvider"msgstr ""#: performance.xml:672(entry) msgid "memory"msgstr ""#: performance.xml:674(entry) performance.xml:681(entry) performance.xml:688(entry) performance.xml:858(entry) performance.xml:859(entry) performance.xml:860(entry) performance.xml:865(entry) performance.xml:866(entry) performance.xml:867(entry) performance.xml:872(entry) performance.xml:873(entry) performance.xml:874(entry) performance.xml:879(entry) performance.xml:880(entry) performance.xml:886(entry) performance.xml:889(entry) msgid "yes"msgstr ""#: performance.xml:677(entry) performance.xml:864(entry) msgid "EHCache"msgstr ""#: performance.xml:678(literal) msgid "org.hibernate.cache.EhCacheProvider"msgstr ""#: performance.xml:679(entry) performance.xml:686(entry) msgid "memory, disk"msgstr ""#: performance.xml:684(entry) performance.xml:871(entry) msgid "OSCache"msgstr ""#: performance.xml:685(literal) msgid "org.hibernate.cache.OSCacheProvider"msgstr ""

⌨️ 快捷键说明

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