alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Hibernate example source code file (performance.po)

This example Hibernate source code file (performance.po) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Hibernate tags/keywords

cache, cat, cat, cdata, hibernate, hibernate, if, mbean, tag, tag, the, this, this, you

The Hibernate performance.po source code

# translation of performance.po to
# Xi Huang <xhuang@redhat.com>, 2006.
# Xi HUANG <xhuang@redhat.com>, 2007, 2009.
# translation of Collection_Mapping.po to
msgid ""
msgstr ""
"Project-Id-Version: performance\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2010-07-20 21:02+0000\n"
"PO-Revision-Date: 2010-03-15 15:27+1000\n"
"Last-Translator: Xi HUANG <xhuang@redhat.com>\n"
"Language-Team:  <en@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: KBabel 1.11.4\n"

#. Tag: title
#: performance.xml:31
#, no-c-format
msgid "Improving performance"
msgstr "提升性能"

#. Tag: title
#: performance.xml:34
#, no-c-format
msgid "Fetching strategies"
msgstr "抓取策略(Fetching strategies)"

#. Tag: para
#: performance.xml:36
#, no-c-format
msgid ""
"Hibernate uses a <emphasis>fetching strategy to retrieve "
"associated objects if the application needs to navigate the association. "
"Fetch strategies can be declared in the O/R mapping metadata, or over-ridden "
"by a particular HQL or <literal>Criteria query."
msgstr ""
"当应用程序需要在(Hibernate实体对象图的)关联关系间进行导航的时候,Hibernate "
"使用 <emphasis>抓取策略(fetching strategy) 获取关联对象。抓取策"
"略可以在 O/R 映射的元数据中声明,也可以在特定的 HQL 或<literal>条件查询"
"(Criteria Query)</literal>中重载声明。"

#. Tag: para
#: performance.xml:42
#, no-c-format
msgid "Hibernate3 defines the following fetching strategies:"
msgstr "Hibernate3 定义了如下几种抓取策略:"

#. Tag: para
#: performance.xml:46
#, no-c-format
msgid ""
"<emphasis>Join fetching: Hibernate retrieves the associated "
"instance or collection in the same <literal>SELECT, using an "
"<literal>OUTER JOIN."
msgstr ""
"<emphasis>连接抓取(Join fetching):Hibernate 通过在 "
"<literal>SELECT  语句使用 OUTER JOIN(外连接)来"
"获得对象的关联实例或者关联集合。 "

#. Tag: para
#: performance.xml:53
#, no-c-format
msgid ""
"<emphasis>Select fetching: a second SELECT is "
"used to retrieve the associated entity or collection. Unless you explicitly "
"disable lazy fetching by specifying <literal>lazy=\"false\", this "
"second select will only be executed when you access the association."
msgstr ""
"<emphasis>查询抓取(Select fetching):另外发送一条 "
"<literal>SELECT 语句抓取当前对象的关联实体或集合。除非你显式的指定 "
"<literal>lazy=\"false\" 禁止 延迟抓取(lazy fetching),否则只有当"
"你真正访问关联关系的时候,才会执行第二条 select 语句。"

#. Tag: para
#: performance.xml:61
#, no-c-format
msgid ""
"<emphasis>Subselect fetching: a second SELECT "
"is used to retrieve the associated collections for all entities retrieved in "
"a previous query or fetch. Unless you explicitly disable lazy fetching by "
"specifying <literal>lazy=\"false\", this second select will only "
"be executed when you access the association."
msgstr ""
"<emphasis>子查询抓取(Subselect fetching):另外发送一条  "
"<literal>SELECT 语句抓取在前面查询到(或者抓取到)的所有实体对象的"
"关联集合。除非你显式的指定 <literal>lazy=\"false\" 禁止延迟抓取"
"(lazy fetching),否则只有当你真正访问关联关系的时候,才会执行第二条 select "
"语句。"

#. Tag: para
#: performance.xml:70
#, no-c-format
msgid ""
"<emphasis>Batch fetching: an optimization strategy for select "
"fetching. Hibernate retrieves a batch of entity instances or collections in "
"a single <literal>SELECT by specifying a list of primary or "
"foreign keys."
msgstr ""
"<emphasis>批量抓取(Batch fetching):对查询抓取的优化方案,通过指"
"定一个主键或外键列表,Hibernate 使用单条 <literal>SELECT 语句获取一"
"批对象实例或集合。"

#. Tag: para
#: performance.xml:77
#, no-c-format
msgid "Hibernate also distinguishes between:"
msgstr "Hibernate 会区分下列各种情况:"

#. Tag: para
#: performance.xml:81
#, no-c-format
msgid ""
"<emphasis>Immediate fetching: an association, collection or "
"attribute is fetched immediately when the owner is loaded."
msgstr ""
"<emphasis>Immediate fetching,立即抓取:当宿主被加载时,关联、集合"
"或属性被立即抓取。"

#. Tag: para
#: performance.xml:87
#, no-c-format
msgid ""
"<emphasis>Lazy collection fetching: a collection is fetched when "
"the application invokes an operation upon that collection. This is the "
"default for collections."
msgstr ""
"<emphasis>Lazy collection fetching,延迟集合抓取:直到应用程序对集"
"合进行了一次操作时,集合才被抓取(对集合而言这是默认行为)。"

#. Tag: para
#: performance.xml:93
#, no-c-format
msgid ""
"<emphasis>\"Extra-lazy\" collection fetching: individual elements "
"of the collection are accessed from the database as needed. Hibernate tries "
"not to fetch the whole collection into memory unless absolutely needed. It "
"is suitable for large collections."
msgstr ""
"<emphasis>\"Extra-lazy\" collection fetching,\"Extra-lazy\" 集合抓取: a single-valued association is fetched "
"when a method other than the identifier getter is invoked upon the "
"associated object."
msgstr ""
"<emphasis>Proxy fetching,代理抓取:对返回单值的关联而言,当其某个"
"方法被调用,而非对其关键字进行 get 操作时才抓取。"

#. Tag: para
#: performance.xml:107
#, no-c-format
msgid ""
"<emphasis>\"No-proxy\" fetching: a single-valued association is "
"fetched when the instance variable is accessed. Compared to proxy fetching, "
"this approach is less lazy; the association is fetched even when only the "
"identifier is accessed. It is also more transparent, since no proxy is "
"visible to the application. This approach requires buildtime bytecode "
"instrumentation and is rarely necessary."
msgstr ""
"<emphasis>\"No-proxy\" fetching,非代理抓取:对返回单值的关联而"
"言,当实例变量被访问的时候进行抓取。与上面的代理抓取相比,这种方法没有那么“延"
"迟”得厉害(就算只访问标识符,也会导致关联抓取)但是更加透明,因为对应用程序来"
"说,不再看到 proxy。这种方法需要在编译期间进行字节码增强操作,因此很少需要用"
"到。"

#. Tag: para
#: performance.xml:117
#, no-c-format
msgid ""
"<emphasis>Lazy attribute fetching: an attribute or single valued "
"association is fetched when the instance variable is accessed. This approach "
"requires buildtime bytecode instrumentation and is rarely necessary."
msgstr ""
"<emphasis>Lazy attribute fetching,属性延迟加载:对属性或返回单值"
"的关联而言,当其实例变量被访问的时候进行抓取。需要编译期字节码强化,因此这一"
"方法很少是必要的。"

#. Tag: para
#: performance.xml:124
#, no-c-format
msgid ""
"We have two orthogonal notions here: <emphasis>when is the "
"association fetched and <emphasis>how is it fetched. It is "
"important that you do not confuse them. We use <literal>fetch to "
"tune performance. We can use <literal>lazy to define a contract "
"for what data is always available in any detached instance of a particular "
"class."
msgstr ""
"这里有两个正交的概念:关联<emphasis>何时被抓取,以及被如"
"何</emphasis>抓取(会采用什么样的 SQL 语句)。注意不要混淆它们。我们使用"
"<literal>抓取来改善性能。我们使用延迟来定义一些"
"契约,对某特定类的某个脱管的实例,知道有哪些数据是可以使用的。"

#. Tag: title
#: performance.xml:132
#, no-c-format
msgid "Working with lazy associations"
msgstr "操作延迟加载的关联"

#. Tag: para
#: performance.xml:134
#, no-c-format
msgid ""
"By default, Hibernate3 uses lazy select fetching for collections and lazy "
"proxy fetching for single-valued associations. These defaults make sense for "
"most associations in the majority of applications."
msgstr ""
"默认情况下,Hibernate 3 对集合使用延迟 select 抓取,对返回单值的关联使用延迟"
"代理抓取。对几乎是所有的应用而言,其绝大多数的关联,这种策略都是有效的。"

#. Tag: para
#: performance.xml:138
#, no-c-format
msgid ""
"If you set <literal>hibernate.default_batch_fetch_size, Hibernate "
"will use the batch fetch optimization for lazy fetching. This optimization "
"can also be enabled at a more granular level."
msgstr ""
"假若你设置了 <literal>hibernate.default_batch_fetch_size,"
"Hibernate 会对延迟加载采取批量抓取优化措施(这种优化也可能会在更细化的级别打"
"开)。"

#. Tag: para
#: performance.xml:142
#, no-c-format
msgid ""
"Please be aware that access to a lazy association outside of the context of "
"an open Hibernate session will result in an exception. For example:"
msgstr ""
"然而,你必须了解延迟抓取带来的一个问题。在一个打开的 Hibernate session 上下文"
"之外调用延迟集合会导致一次意外。比如: "

#. Tag: programlisting
#: performance.xml:146
#, fuzzy, no-c-format
msgid ""
"s = sessions.openSession();\n"
"Transaction tx = s.beginTransaction();\n"
"            \n"
"User u = (User) s.createQuery(\"from User u where u.name=:userName\")\n"
"    .setString(\"userName\", userName).uniqueResult();\n"
"Map permissions = u.getPermissions();\n"
"\n"
"tx.commit();\n"
"s.close();\n"
"\n"
"Integer accessLevel = (Integer) permissions.get(\"accounts\");  // Error!"
msgstr ""
"<![CDATA[s = sessions.openSession();\n"
"Transaction tx = s.beginTransaction();\n"
"            \n"
"User u = (User) s.createQuery(\"from User u where u.name=:userName\")\n"
"    .setString(\"userName\", userName).uniqueResult();\n"
"Map permissions = u.getPermissions();\n"
"\n"
"tx.commit();\n"
"s.close();\n"
"\n"
"Integer accessLevel = (Integer) permissions.get(\"accounts\");  // Error!]]>"

#. Tag: para
#: performance.xml:148
#, no-c-format
msgid ""
"Since the permissions collection was not initialized when the "
"<literal>Session was closed, the collection will not be able to "
"load its state. <emphasis>Hibernate does not support lazy initialization for "
"detached objects</emphasis>. This can be fixed by moving the code that reads "
"from the collection to just before the transaction is committed."
msgstr ""
"在 <literal>Session 关闭后,permessions 集合将是未实例化的、不再可"
"用,因此无法正常载入其状态。 <emphasis>Hibernate 对脱管对象不支持延迟实例化 for the association mapping. "
"However, it is intended that lazy initialization be used for almost all "
"collections and associations. If you define too many non-lazy associations "
"in your object model, Hibernate will fetch the entire database into memory "
"in every transaction."
msgstr ""
"除此之外,通过对关联映射指定 <literal>lazy=\"false\",我们也可以使"
"用非延迟的集合或关联。但是,对绝大部分集合来说,更推荐使用延迟方式抓取数据。"
"如果在你的对象模型中定义了太多的非延迟关联,Hibernate 最终几乎需要在每个事务"
"中载入整个数据库到内存中。"

#. Tag: para
#: performance.xml:162
#, no-c-format
msgid ""
"On the other hand, you can use join fetching, which is non-lazy by nature, "
"instead of select fetching in a particular transaction. We will now explain "
"how to customize the fetching strategy. In Hibernate3, the mechanisms for "
"choosing a fetch strategy are identical for single-valued associations and "
"collections."
msgstr ""
"但是,另一方面,在一些特殊的事务中,我们也经常需要使用到连接抓取(它本身上就"
"是非延迟的),以代替查询抓取。 下面我们将会很快明白如何具体的定制 Hibernate "
"中的抓取策略。在 Hibernate3 中,具体选择哪种抓取策略的机制是和选择 单值关联或"
"集合关联相一致的。 "

#. Tag: title
#: performance.xml:170
#, no-c-format
msgid "Tuning fetch strategies"
msgstr "调整抓取策略(Tuning fetch strategies)"

#. Tag: para
#: performance.xml:172
#, no-c-format
msgid ""
"Select fetching (the default) is extremely vulnerable to N+1 selects "
"problems, so we might want to enable join fetching in the mapping document:"
msgstr ""
"查询抓取(默认的)在 N+1 查询的情况下是极其脆弱的,因此我们可能会要求在映射文"
"档中定义使用连接抓取:"

#. Tag: programlisting
#: performance.xml:176
#, fuzzy, no-c-format
msgid ""
"<set name=\"permissions\"\n"
"            fetch=\"join\">\n"
"    <key column=\"userId\"/>\n"
"    <one-to-many class=\"Permission\"/>\n"
"</set"
msgstr ""
"<![CDATA["

#. Tag: para
#: performance.xml:180
#, no-c-format
msgid ""
"The <literal>fetch strategy defined in the mapping document "
"affects:"
msgstr ""
"在映射文档中定义的<literal>抓取策略将会对以下列表条目产生影响:"

#. Tag: para
#: performance.xml:185
#, no-c-format
msgid "retrieval via <literal>get() or load()"
msgstr ""
"通过 <literal>get() 或 load() 方法取得数据。"

#. Tag: para
#: performance.xml:190
#, no-c-format
msgid "retrieval that happens implicitly when an association is navigated"
msgstr "只有在关联之间进行导航时,才会隐式的取得数据。"

#. Tag: para
#: performance.xml:195
#, no-c-format
msgid "<literal>Criteria queries"
msgstr "条件查询"

#. Tag: para
#: performance.xml:199
#, no-c-format
msgid "HQL queries if <literal>subselect fetching is used"
msgstr "使用了 <literal>subselect 抓取的 HQL 查询"

#. Tag: para
#: performance.xml:204
#, no-c-format
msgid ""
"Irrespective of the fetching strategy you use, the defined non-lazy graph is "
"guaranteed to be loaded into memory. This might, however, result in several "
"immediate selects being used to execute a particular HQL query."
msgstr ""
"不管你使用哪种抓取策略,定义为非延迟的类图会被保证一定装载入内存。注意这可能"
"意味着在一条 HQL 查询后紧跟着一系列的查询。 "

#. Tag: para
#: performance.xml:209
#, no-c-format
msgid ""
"Usually, the mapping document is not used to customize fetching. Instead, we "
"keep the default behavior, and override it for a particular transaction, "
"using <literal>left join fetch in HQL. This tells Hibernate to "
"fetch the association eagerly in the first select, using an outer join. In "
"the <literal>Criteria query API, you would use "
"<literal>setFetchMode(FetchMode.JOIN)."
msgstr ""
"通常情况下,我们并不使用映射文档进行抓取策略的定制。更多的是,保持其默认值,"
"然后在特定的事务中, 使用 HQL 的<literal>左连接抓取(left join fetch) API 中,应该调用 "
"<literal>setFetchMode(FetchMode.JOIN)语句。 "

#. Tag: para
#: performance.xml:216
#, no-c-format
msgid ""
"If you want to change the fetching strategy used by <literal>get() "
"or <literal>load(), you can use a Criteria "
"query. For example:"
msgstr ""
"也许你喜欢仅仅通过条件查询,就可以改变 <literal>get() 或 "
"<literal>load() 语句中的数据抓取策略。例如: "

#. Tag: programlisting
#: performance.xml:220
#, fuzzy, no-c-format
msgid ""
"User user = (User) session.createCriteria(User.class)\n"
"                .setFetchMode(\"permissions\", FetchMode.JOIN)\n"
"                .add( Restrictions.idEq(userId) )\n"
"                .uniqueResult();"
msgstr ""
"<![CDATA[User user = (User) session.createCriteria(User.class)\n"
"                .setFetchMode(\"permissions\", FetchMode.JOIN)\n"
"                .add( Restrictions.idEq(userId) )\n"
"                .uniqueResult();]]>"

#. Tag: para
#: performance.xml:222
#, no-c-format
msgid ""
"This is Hibernate's equivalent of what some ORM solutions call a \"fetch plan"
"\"."
msgstr ""
"这就是其他 ORM 解决方案的“抓取计划(fetch plan)”在 Hibernate 中的等价物。"

#. Tag: para
#: performance.xml:225
#, no-c-format
msgid ""
"A completely different approach to problems with N+1 selects is to use the "
"second-level cache."
msgstr "截然不同的一种避免 N+1 次查询的方法是,使用二级缓存。 "

#. Tag: title
#: performance.xml:230
#, no-c-format
msgid "Single-ended association proxies"
msgstr "单端关联代理(Single-ended association proxies)"

#. Tag: para
#: performance.xml:232
#, no-c-format
msgid ""
"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 which is "
"accessed via the CGLIB library."
msgstr ""
"在 Hinerbate 中,对集合的延迟抓取的采用了自己的实现方法。但是,对于单端关联的"
"延迟抓取,则需要采用 其他不同的机制。单端关联的目标实体必须使用代理,"
"Hihernate 在运行期二进制级(通过优异的 CGLIB 库), 为持久对象实现了延迟载入"
"代理。 "

#. Tag: para
#: performance.xml:239
#, no-c-format
msgid ""
"At startup, Hibernate3 generates proxies by default for all persistent "
"classes and uses them to enable lazy fetching of <literal>many-to-oneone-to-one associations."
msgstr ""
"默认的,Hibernate3 将会为所有的持久对象产生代理(在启动阶段),然后使用他们实"
"现 <literal>多对一(many-to-one)关联和一对一(one-to-"
"one)</literal> 关联的延迟抓取。 "

#. Tag: para
#: performance.xml:244
#, no-c-format
msgid ""
"The mapping file may declare an interface to use as the proxy interface for "
"that class, with the <literal>proxy attribute. By default, "
"Hibernate uses a subclass of the class. <emphasis>The proxied class must "
"implement a default constructor with at least package visibility. This "
"constructor is recommended for all persistent classes</emphasis>."
msgstr ""
"在映射文件中,可以通过设置 <literal>proxy 属性为目标 class 声明一个"
"接口供代理接口使用。 默认的,Hibernate 将会使用该类的一个子类。<emphasis>注"
"意:被代理的类必须实现一个至少包可见的默认构造函数,我们建议所有的持久类都应"
"拥有这样的构造函数。</emphasis>"

#. Tag: para
#: performance.xml:251
#, no-c-format
msgid ""
"There are potential problems to note when extending this approach to "
"polymorphic classes.For example:"
msgstr "在如此方式定义一个多态类的时候,有许多值得注意的常见性的问题,例如: "

#. Tag: programlisting
#: performance.xml:254
#, fuzzy, no-c-format
msgid ""
"<class name=\"Cat\" proxy=\"Cat\">\n"
"    ......\n"
"    <subclass name=\"DomesticCat\">\n"
"        .....\n"
"    </subclass>\n"
"</class>"
msgstr ""
"<![CDATA["

#. Tag: para
#: performance.xml:256
#, no-c-format
msgid ""
"Firstly, instances of <literal>Cat will never be castable to "
"<literal>DomesticCat, even if the underlying instance is an "
"instance of <literal>DomesticCat:"
msgstr ""
"首先,<literal>Cat 实例永远不可以被强制转换为 "
"<literal>DomesticCat,即使它本身就是 DomesticCat:"
msgstr "其次,代理的“<literal>==”可能不再成立。 "

#. Tag: programlisting
#: performance.xml:265
#, fuzzy, no-c-format
msgid ""
"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 ""
"<![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]]>"

#. Tag: para
#: performance.xml:267
#, no-c-format
msgid ""
"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 ""
"虽然如此,但实际情况并没有看上去那么糟糕。虽然我们现在有两个不同的引用,分别"
"指向这两个不同的代理对象,但实际上,其底层应该是同一个实例对象:"

#. Tag: programlisting
#: performance.xml:271
#, fuzzy, no-c-format
msgid ""
"cat.setWeight(11.0);  // hit the db to initialize the proxy\n"
"System.out.println( dc.getWeight() );  // 11.0"
msgstr ""
"<![CDATA[cat.setWeight(11.0);  // hit the db to initialize the proxy\n"
"System.out.println( dc.getWeight() );  // 11.0]]>"

#. Tag: para
#: performance.xml:273
#, no-c-format
msgid ""
"Third, you cannot use a CGLIB proxy for a <literal>final class or "
"a class with any <literal>final methods."
msgstr ""
"第三,你不能对 <literal>final 类或具有 final 方"
"法的类使用 CGLIB 代理。"

#. Tag: para
#: performance.xml:276
#, no-c-format
msgid ""
"Finally, if your persistent object acquires any resources upon instantiation "
"(e.g. 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 ""
"最后,如果你的持久化对象在实例化时需要某些资源(例如,在实例化方法、默认构造"
"方法中),那么代理对象也同样需要使用这些资源。实际上,代理类是持久化类的子"
"类。"

#. Tag: para
#: performance.xml:281
#, no-c-format
msgid ""
"These problems are all due to fundamental limitations in Java's single "
"inheritance model. 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 where <literal>CatImplCat and "
"<literal>DomesticCatImpl implements the interface "
"<literal>DomesticCat. For example:"
msgstr ""
"这些问题都源于 Java 的单根继承模型的天生限制。如果你希望避免这些问题,那么你"
"的每个持久化类必须实现一个接口, 在此接口中已经声明了其业务方法。然后,你需要"
"在映射文档中再指定这些接口,如 <literal>CatImpl 实现 CatDomesticCatImpl 实现 DomesticCat"

#. Tag: para
#: performance.xml:291
#, no-c-format
msgid ""
"Then proxies for instances of <literal>Cat and "
"<literal>DomesticCat can be returned by load() "
"or <literal>iterate()."
msgstr ""
"然后,<literal>load() 和 iterate() 永远也不会返"
"回 <literal>Cat 和 DomesticCat 实例的代理。"

#. Tag: programlisting
#: performance.xml:295
#, fuzzy, no-c-format
msgid ""
"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 ""
"<![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();]]>"

#. Tag: title
#: performance.xml:298
#, no-c-format
msgid "Note"
msgstr "注意"

#. Tag: para
#: performance.xml:300
#, no-c-format
msgid "<literal>list() does not usually return proxies."
msgstr "<literal>list() 通常不返回代理。"

#. Tag: para
#: performance.xml:304
#, no-c-format
msgid ""
"Relationships are also lazily initialized. This means you must declare any "
"properties to be of type <literal>Cat, not CatImpl,而不是 CatImpl。"

#. Tag: para
#: performance.xml:308
#, no-c-format
msgid ""
"Certain operations do <emphasis>not require proxy initialization:"
msgstr "有些方法中是<emphasis>不需要代理初始化的:"

#. Tag: para
#: performance.xml:313
#, no-c-format
msgid ""
"<literal>equals(): if the persistent class does not override "
"<literal>equals()"
msgstr ""
"<literal>equals() 方法,如果持久类没有重载 equals(): if the persistent class does not override "
"<literal>hashCode()"
msgstr ""
"<literal>hashCode():如果持久类没有重载 hashCode()hashCode()."
msgstr ""
"Hibernate 将会识别出那些重载了 <literal>equals()、或 "
"<literal>hashCode() 方法的持久化类。"

#. Tag: para
#: performance.xml:330
#, no-c-format
msgid ""
"By choosing <literal>lazy=\"no-proxy\" instead of the default "
"<literal>lazy=\"proxy\", you can avoid problems associated with "
"typecasting. However, buildtime bytecode instrumentation is required, and "
"all operations will result in immediate proxy initialization."
msgstr ""
"若选择 <literal>lazy=\"no-proxy\" 而非默认的 lazy=\"proxy"
"\"</literal>,我们可以避免类型转换带来的问题。然而,这样我们就需要编译期字节"
"码增强,并且所有的操作都会导致立刻进行代理初始化。 "

#. Tag: title
#: performance.xml:338
#, no-c-format
msgid "Initializing collections and proxies"
msgstr "实例化集合和代理(Initializing collections and proxies)"

#. Tag: para
#: performance.xml:340
#, no-c-format
msgid ""
"A <literal>LazyInitializationException will be thrown by Hibernate "
"if an uninitialized collection or proxy is accessed outside of the scope of "
"the <literal>Session, i.e., when the entity owning the collection "
"or having the reference to the proxy is in the detached state."
msgstr ""
"在 <literal>Session 范围之外访问未初始化的集合或代理,Hibernate 将"
"会抛出 <literal>LazyInitializationException 异常。也就是说,在分离"
"状态下,访问一个实体所拥有的集合,或者访问其指向代理的属性时,会引发此异常。 "

#. Tag: para
#: performance.xml:346
#, no-c-format
msgid ""
"Sometimes a proxy or collection needs to be initialized before closing the "
"<literal>Session. You can force initialization by calling "
"<literal>cat.getSex() or cat.getKittens().size() 或者 cat."
"getKittens().size()</literal> 之类的方法来确保这一点。 但是这样的程序会造成读"
"者的疑惑,也不符合通常的代码规范。 "

#. Tag: para
#: performance.xml:353
#, no-c-format
msgid ""
"The static methods <literal>Hibernate.initialize() and "
"<literal>Hibernate.isInitialized(), provide the application with a "
"convenient way of working with lazily initialized collections or proxies. "
"<literal>Hibernate.initialize(cat) will force the initialization "
"of a proxy, <literal>cat, as long as its SessionHibernate.initialize( cat.getKittens() ) 为你的应用程序提供了一个"
"便捷的途径来延迟加载集合或代理。 只要它的 Session 处于 open 状态,"
"<literal>Hibernate.initialize(cat) 将会为 cat 强制对代理实例化。同"
"样,<literal>Hibernate.initialize(cat.getKittens()) 对 kittens 的集"
"合具有同样的功能。 "

#. Tag: para
#: performance.xml:362
#, no-c-format
msgid ""
"Another option is to keep the <literal>Session open until all "
"required 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 is open when a collection is initialized. There "
"are two basic ways to deal with this issue:"
msgstr ""
"还有另外一种选择,就是保持 <literal>Session 一直处于 open 状态,直"
"到所有需要的集合或代理都被载入。 在某些应用架构中,特别是对于那些使用 "
"Hibernate 进行数据访问的代码,以及那些在不同应用层和不同物理进程中使用 "
"Hibernate 的代码。 在集合实例化时,如何保证 <literal>Session 处于 "
"open 状态经常会是一个问题。有两种方法可以解决此问题: "

#. Tag: para
#: performance.xml:372
#, no-c-format
msgid ""
"In a web-based application, a servlet filter can be used to close the "
"<literal>Session only at the end of a user request, once the "
"rendering of the view is complete (the <emphasis>Open Session in View 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 ""
"在一个基于 Web 的应用中,可以利用 servlet 过滤器(filter),在用户请求"
"(request)结束、页面生成 结束时关闭 <literal>Session(这里使用了"
"<emphasis>在展示层保持打开 Session 模式(Open Session in View) "
"clause or a <literal>FetchMode.JOIN in CriteriaCommandSession Facade."
msgstr ""
"在一个拥有单独业务层的应用中,业务层必须在返回之前,为 web 层“准备”好其所需的"
"数据集合。这就意味着 业务层应该载入所有表现层/web 层所需的数据,并将这些已实"
"例化完毕的数据返回。通常,应用程序应该为 web 层所需的每个集合调用 "
"<literal>Hibernate.initialize()(这个调用必须发生咱 session 关闭之"
"前);或者使用带有 <literal>FETCH 从句,或 FetchMode."
"JOIN</literal> 的 Hibernate 查询,事先取得所有的数据集合。如果你在应用中使用"
"了 <emphasis>Command 模式,代替 Session Facademerge() or lock() before "
"accessing uninitialized collections or other proxies. Hibernate does not, "
"and certainly <emphasis>should not, do this automatically since "
"it would introduce impromptu transaction semantics."
msgstr ""
"你也可以通过 <literal>merge() 或 lock() 方法,在"
"访问未实例化的集合(或代理)之前,为先前载入的对象绑定一个新的 "
"<literal>Session。显然,Hibernate 将不会,也不应该 method is also used to efficiently "
"retrieve subsets of a collection without needing to initialize the whole "
"collection:"
msgstr ""
"这里的 <literal>createFilter() 方法也可以被用来有效的抓取集合的部分"
"内容,而无需实例化整个集合:"

#. Tag: programlisting
#: performance.xml:423
#, fuzzy, no-c-format
msgid ""
"s.createFilter( lazyCollection, \"\").setFirstResult(0).setMaxResults(10)."
"list();"
msgstr ""
"<![CDATA[s.createFilter( lazyCollection, \"\").setFirstResult(0)."
"setMaxResults(10).list();]]>"

#. Tag: title
#: performance.xml:427
#, no-c-format
msgid "Using batch fetching"
msgstr "使用批量抓取(Using batch fetching)"

#. Tag: para
#: performance.xml:429
#, no-c-format
msgid ""
"Using batch fetching, Hibernate can load several uninitialized proxies if "
"one proxy is accessed. Batch fetching is an optimization of the lazy select "
"fetching strategy. There are two ways you can configure batch fetching: on "
"the class level and the collection level."
msgstr ""
"Hibernate 可以充分有效的使用批量抓取,也就是说,如果仅一个访问代理(或集"
"合),那么 Hibernate 将不载入其他未实例化的代理。批量抓取是延迟查询抓取的优化"
"方案,你可以在两种批量抓取方案之间进行选择:在类级别和集合级别。 "

#. Tag: para
#: performance.xml:434
#, no-c-format
msgid ""
"Batch fetching for classes/entities is easier to understand. Consider the "
"following example: at runtime you have 25 <literal>Cat instances "
"loaded in a <literal>Session, and each Cat has "
"a reference to its <literal>owner, a Person. "
"The <literal>Person class is mapped with a proxy, lazy="
"\"true\"</literal>. If you now iterate through all cats and call "
"<literal>getOwner() on each, Hibernate will, by default, execute "
"25 <literal>SELECT statements to retrieve the proxied owners. You "
"can tune this behavior by specifying a <literal>batch-size in the "
"mapping of <literal>Person:"
msgstr ""
"类/实体级别的批量抓取很容易理解。假设你在运行时将需要面对下面的问题:你在一"
"个 <literal>Session 中载入了 25 个 Cat 实例,每"
"个 <literal>Cat 实例都拥有一个引用成员 owner,其"
"指向 <literal>Person,而 Person 类是代理,同时 "
"<literal>lazy=\"true\"。如果你必须遍历整个 cats 集合,对每个元素调"
"用 <literal>getOwner() 方法,Hibernate 将会默认的执行 25 次 "
"<literal>SELECT 查询, 得到其 owner 的代理对象。这时,你可以通过在"
"映射文件的 <literal>Person 属性,显式声明 batch-size]]>"

#. Tag: para
#: performance.xml:449
#, no-c-format
msgid ""
"Hibernate will now execute only three queries: the pattern is 10, 10, 5."
msgstr "随之,Hibernate 将只需要执行三次查询,分别为 10、10、 5。 "

#. Tag: para
#: performance.xml:452
#, no-c-format
msgid ""
"You can also enable batch fetching of collections. For example, if each "
"<literal>Person has a lazy collection of Cats, "
"and 10 persons are currently loaded in the <literal>Session, "
"iterating through all persons will generate 10 <literal>SELECTs, "
"one for every call to <literal>getCats(). If you enable batch "
"fetching for the <literal>cats collection in the mapping of "
"<literal>Person, Hibernate can pre-fetch collections:"
msgstr ""
"你也可以在集合级别定义批量抓取。例如,如果每个 <literal>Person 都拥"
"有一个延迟载入的 <literal>Cats 集合, 现在,Sesssion 查询,每次查询都会调用 getCats()Person 的映射定义部分,允许对 "
"<literal>cats 批量抓取,那么,Hibernate 将可以预先抓取整个集合。请"
"看例子: "

#. Tag: programlisting
#: performance.xml:461
#, fuzzy, no-c-format
msgid ""
"<class name=\"Person\">\n"
"    <set name=\"cats\" batch-size=\"3\">\n"
"        ...\n"
"    </set>\n"
"</class>"
msgstr ""
"<![CDATA["

#. Tag: para
#: performance.xml:463
#, no-c-format
msgid ""
"With a <literal>batch-size of 3, Hibernate will load 3, 3, 3, 1 "
"collections in four <literal>SELECTs. Again, the value of the "
"attribute depends on the expected number of uninitialized collections in a "
"particular <literal>Session."
msgstr ""
"如果整个的 <literal>batch-size 是 3,那么 Hibernate 将会分四次执行 "
"<literal>SELECT 查询, 按照 3、3、3、1 的大小分别载入数据。这里的每"
"次载入的数据量还具体依赖于当前 <literal>Session 中未实例化集合的个"
"数。 "

#. Tag: para
#: performance.xml:468
#, no-c-format
msgid ""
"Batch fetching of collections is particularly useful if you have a nested "
"tree of items, i.e. the typical bill-of-materials pattern. However, a "
"<emphasis>nested set or a materialized path "
"might be a better option for read-mostly trees."
msgstr ""
"如果你的模型中有嵌套的树状结构,例如典型的帐单-原料结构(bill-of-materials "
"pattern),集合的批量抓取是非常有用的。(尽管在更多情况下对树进行读取时,"
"<emphasis>嵌套集合(nested set)或原料路径"
"(materialized path)</emphasis>可能是更好的解决方法。)"

#. Tag: title
#: performance.xml:475
#, no-c-format
msgid "Using subselect fetching"
msgstr "使用子查询抓取(Using subselect fetching)"

#. Tag: para
#: performance.xml:477
#, no-c-format
msgid ""
"If one lazy collection or single-valued proxy has to be fetched, Hibernate "
"will load all of them, re-running the original query in a subselect. This "
"works in the same way as batch-fetching but without the piecemeal loading."
msgstr ""
"假若一个延迟集合或单值代理需要抓取,Hibernate 会使用一个 subselect 重新运行原"
"来的查询,一次性读入所有的实例。这和批量抓取的实现方法是一样的,不会有破碎的"
"加载。 "

#. Tag: title
#: performance.xml:486
#, no-c-format
msgid "Fetch profiles"
msgstr "Fetch profile(抓取策略)"

#. Tag: para
#: performance.xml:488
#, fuzzy, no-c-format
msgid ""
"Another way to affect the fetching strategy for loading associated objects "
"is through something called a fetch profile, which is a named configuration "
"associated with the <interfacename>org.hibernate.SessionFactoryorg.hibernate."
"Session</interfacename>. Once enabled on a org.hibernate."
"Session</interfacename>, the fetch profile will be in affect for that "
"<interfacename>org.hibernate.Session until it is explicitly "
"disabled."
msgstr ""
"影响抓取加载相关对象的策略的另外一个方法是通过抓取配置(fetch profile),它是"
"和 <interfacename>org.hibernate.SessionFactory 相关的配置但"
"对 <interfacename>org.hibernate.Session 启用。一旦在 "
"<interfacename>org.hibernate.Session 上启用,抓取配置将对这"
"个 <interfacename>org.hibernate.Session 生效直至它被显性地禁"
"用。"

#. Tag: para
#: performance.xml:498
#, fuzzy, no-c-format
msgid ""
"So what does that mean? Well lets explain that by way of an example which "
"show the different available approaches to configure a fetch profile:"
msgstr "这是什么意思呢?让我们通过一个例子进行解释。假设我们有下列映射:"

#. Tag: title
#: performance.xml:503
#, no-c-format
msgid "Specifying a fetch profile using <classname>@FetchProfile"
msgstr ""

#. Tag: programlisting
#: performance.xml:506
#, no-c-format
msgid ""
"@Entity\n"
"@FetchProfile(name = \"customer-with-orders\", fetchOverrides = {\n"
"   @FetchProfile.FetchOverride(entity = Customer.class, association = "
"\"orders\", mode = FetchMode.JOIN)\n"
"})\n"
"public class Customer {\n"
"   @Id\n"
"   @GeneratedValue\n"
"   private long id;\n"
"\n"
"   private String name;\n"
"\n"
"   private long customerNumber;\n"
"\n"
"   @OneToMany\n"
"   private Set<Order> orders;\n"
"\n"
"   // standard getter/setter\n"
"   ...\n"
"}"
msgstr ""

#. Tag: title
#: performance.xml:510
#, no-c-format
msgid ""
"Specifying a fetch profile using <literal><fetch-profile> "
"outside <literal><class> node"
msgstr ""

#. Tag: programlisting
#: performance.xml:514
#, no-c-format
msgid ""
"<hibernate-mapping>\n"
"    <class name=\"Customer\">\n"
"        ...\n"
"        <set name=\"orders\" inverse=\"true\">\n"
"            <key column=\"cust_id\"/>\n"
"            <one-to-many class=\"Order\"/>\n"
"        </set>\n"
"    </class>\n"
"    <class name=\"Order\">\n"
"        ...\n"
"    </class>\n"
"    <fetch-profile name=\"customer-with-orders\">\n"
"        <fetch entity=\"Customer\" association=\"orders\" style=\"join\"/"
">\n"
"    </fetch-profile>\n"
"</hibernate-mapping>"
msgstr ""

#. Tag: title
#: performance.xml:518
#, no-c-format
msgid ""
"Specifying a fetch profile using <literal><fetch-profile> "
"inside <literal><class> node"
msgstr ""

#. Tag: programlisting
#: performance.xml:522
#, no-c-format
msgid ""
"<hibernate-mapping>\n"
"    <class name=\"Customer\">\n"
"        ...\n"
"        <set name=\"orders\" inverse=\"true\">\n"
"            <key column=\"cust_id\"/>\n"
"            <one-to-many class=\"Order\"/>\n"
"        </set>\n"
"        <fetch-profile name=\"customer-with-orders\">\n"
"            <fetch association=\"orders\" style=\"join\"/>\n"
"        </fetch-profile>\n"
"    </class>\n"
"    <class name=\"Order\">\n"
"        ...\n"
"    </class>\n"
"</hibernate-mapping>"
msgstr ""

#. Tag: para
#: performance.xml:525
#, fuzzy, no-c-format
msgid ""
"Now normally when you get a reference to a particular customer, that "
"customer's set of orders will be lazy meaning we will not yet have loaded "
"those orders from the database. Normally this is a good thing. Now lets say "
"that you have a certain use case where it is more efficient to load the "
"customer and their orders together. One way certainly is to use \"dynamic "
"fetching\" strategies via an HQL or criteria queries. But another option is "
"to use a fetch profile to achieve that. The following code will load both "
"the customer <emphasis>andtheir orders:"
msgstr ""
"现在,当你获得某个特定客户的引用时,这个客户的订单将处于 lazy 状态,表示我们"
"暂不会从数据库里加载这些订单。这样通常没有问题。假设在某种情况下,加载客户及"
"其订单会更高效。其中一个办法当然是使用通过 HQL 或 Criteria 查询“动态抓取”的策"
"略。另外一个方法就是使用抓取配置(Fetch Profile)。你可以在映射里加入下面的内"
"容:"

#. Tag: title
#: performance.xml:536
#, no-c-format
msgid "Activating a fetch profile for a given <classname>Session"
msgstr ""

#. Tag: programlisting
#: performance.xml:539
#, no-c-format
msgid ""
"Session session = ...;\n"
"session.enableFetchProfile( \"customer-with-orders\" );  // name matches "
"from mapping\n"
"Customer customer = (Customer) session.get( Customer.class, customerId );"
msgstr ""

#. Tag: para
#: performance.xml:543
#, no-c-format
msgid ""
"<classname>@FetchProfile definitions are global and it does not "
"matter on which class you place them. You can place the "
"<classname>@FetchProfile annotation either onto a class or "
"package (package-info.java). In order to define multiple fetch profiles for "
"the same class or package <classname>@FetchProfiles can be used."
msgstr ""

#. Tag: para
#: performance.xml:551
#, no-c-format
msgid ""
"Currently only join style fetch profiles are supported, but they plan is to "
"support additional styles. See <ulink url=\"http://opensource.atlassian.com/"
"projects/hibernate/browse/HHH-3414\">HHH-3414</ulink> for details."
msgstr ""
"目前只有 join 风格的抓取策略被支持,但其他风格也将被支持。更多细节请参考 "
"<ulink url=\"http://opensource.atlassian.com/projects/hibernate/browse/HHH-"
"3414\">HHH-3414</ulink>。"

#. Tag: title
#: performance.xml:558
#, no-c-format
msgid "Using lazy property fetching"
msgstr "使用延迟属性抓取(Using lazy property fetching)"

#. Tag: para
#: performance.xml:560
#, no-c-format
msgid ""
"Hibernate3 supports the lazy fetching of individual properties. This "
"optimization technique is also known as <emphasis>fetch groups. "
"Please note that this is mostly a marketing feature; optimizing row reads is "
"much more important than optimization of column reads. However, only loading "
"some properties of a class could be useful in extreme cases. For example, "
"when legacy tables have hundreds of columns and the data model cannot be "
"improved."
msgstr ""
"Hibernate3 对单独的属性支持延迟抓取,这项优化技术也被称为<emphasis>组抓取"
"(fetch groups)</emphasis>。 请注意,该技术更多的属于市场特性。在实际应用"
"中,优化行读取比优化列读取更重要。但是,仅载入类的部分属性在某些特定情况下会"
"有用,例如在原有表中拥有几百列数据、数据模型无法改动的情况下。 "

#. Tag: para
#: performance.xml:568
#, no-c-format
msgid ""
"To enable lazy property loading, set the <literal>lazy attribute "
"on your particular property mappings:"
msgstr ""
"可以在映射文件中对特定的属性设置 <literal>lazy,定义该属性为延迟载"
"入。"

#. Tag: programlisting
#: performance.xml:571
#, fuzzy, no-c-format
msgid ""
"<class name=\"Document\">\n"
"       <id name=\"id\">\n"
"        <generator class=\"native\"/>\n"
"    </id>\n"
"    <property name=\"name\" not-null=\"true\" length=\"50\"/>\n"
"    <property name=\"summary\" not-null=\"true\" length=\"200\" lazy="
"\"true\"/>\n"
"    <property name=\"text\" not-null=\"true\" length=\"2000\" lazy=\"true"
"\"/>\n"
"</class>"
msgstr ""
"<![CDATA["

#. Tag: para
#: performance.xml:573
#, no-c-format
msgid ""
"Lazy property loading requires buildtime bytecode instrumentation. If your "
"persistent classes are not enhanced, Hibernate will ignore lazy property "
"settings and return to immediate fetching."
msgstr ""
"属性的延迟载入要求在其代码构建时加入二进制指示指令(bytecode "
"instrumentation),如果你的持久类代码中未含有这些指令, Hibernate 将会忽略这"
"些属性的延迟设置,仍然将其直接载入。 "

#. Tag: para
#: performance.xml:577
#, no-c-format
msgid "For bytecode instrumentation, use the following Ant task:"
msgstr "你可以在 Ant 的 Task 中,进行如下定义,对持久类代码加入“二进制指令。”"

#. Tag: programlisting
#: performance.xml:579
#, fuzzy, no-c-format
msgid ""
"<target name=\"instrument\" depends=\"compile\">\n"
"    <taskdef name=\"instrument\" classname=\"org.hibernate.tool."
"instrument.InstrumentTask\">\n"
"        <classpath path=\"${jar.path}\"/>\n"
"        <classpath path=\"${classes.dir}\"/>\n"
"        <classpath refid=\"lib.class.path\"/>\n"
"    </taskdef>\n"
"\n"
"    <instrument verbose=\"true\">\n"
"        <fileset dir=\"${testclasses.dir}/org/hibernate/auction/model"
"\">\n"
"            <include name=\"*.class\"/>\n"
"        </fileset>\n"
"    </instrument>\n"
"</target>"
msgstr ""
"<![CDATA["

#. Tag: para
#: performance.xml:581
#, no-c-format
msgid ""
"A different way of avoiding 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 "
"preferred solution."
msgstr ""
"还有一种可以优化的方法,它使用 HQL 或条件查询的投影(projection)特性,可以避"
"免读取非必要的列, 这一点至少对只读事务是非常有用的。它无需在代码构建时“二进"
"制指令”处理,因此是一个更加值得选择的解决方法。 "

#. Tag: para
#: performance.xml:586
#, no-c-format
msgid ""
"You can force the usual eager fetching of properties using <literal>fetch "
"all properties</literal> in HQL."
msgstr ""
"有时你需要在 HQL 中通过<literal>抓取所有属性,强行抓取所有内容。 "

#. Tag: title
#: performance.xml:592
#, no-c-format
msgid "The Second Level Cache"
msgstr "二级缓存(The Second Level Cache)"

#. Tag: para
#: performance.xml:594
#, no-c-format
msgid ""
"A Hibernate <literal>Session is a transaction-level cache of "
"persistent data. It is possible to configure a cluster or JVM-level "
"(<literal>SessionFactory-level) cache on a class-by-class and "
"collection-by-collection basis. You can even plug in a clustered cache. Be "
"aware that caches are not aware of changes made to the persistent store by "
"another application. They can, however, be configured to regularly expire "
"cached data."
msgstr ""
"Hibernate 的 <literal>Session 在事务级别进行持久化数据的缓存操作。 "
"当然,也有可能分别为每个类(或集合),配置集群、或 JVM 级别"
"(<literal>SessionFactory 级别)的缓存。你甚至可以为之插入一个集群"
"的缓存。注意,缓存永远不知道其他应用程序对持久化仓库(数据库)可能进行的修改 "
"(即使可以将缓存数据设定为定期失效)。 "

#. Tag: para
#: performance.xml:602
#, fuzzy, no-c-format
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 hibernate.cache."
"provider_class</literal>. Hibernate is bundled with a number of built-in "
"integrations with the open-source cache providers that are listed in <xref "
"linkend=\"cacheproviders\"/>. You can also implement your own and plug it in "
"as outlined above. Note that versions prior to Hibernate 3.2 use EhCache as "
"the default cache provider."
msgstr ""
"通过在 <literal>hibernate.cache.provider_class 属性中指定  "
"<literal>org.hibernate.cache.CacheProvider 的某个实现的类名,你可以"
"选择让 Hibernate 使用哪个缓存实现。Hibernate 打包一些开源缓存实现,提供对它们"
"的内置支持(见下表)。除此之外,你也可以实现你自己的实现,将它们插入到系统"
"中。注意,在 3.2 版本之前,默认使用 EhCache 作为缓存实现,但从 3.2 起就不再这"
"样了。 "

#. Tag: title
#: performance.xml:613
#, no-c-format
msgid "Cache Providers"
msgstr "缓存策略提供商(Cache Providers)"

#. Tag: entry
#: performance.xml:628 performance.xml:976
#, no-c-format
msgid "Cache"
msgstr "Cache"

#. Tag: entry
#: performance.xml:630
#, no-c-format
msgid "Provider class"
msgstr "Provider class"

#. Tag: entry
#: performance.xml:632
#, no-c-format
msgid "Type"
msgstr "Type"

#. Tag: entry
#: performance.xml:634
#, no-c-format
msgid "Cluster Safe"
msgstr "Cluster Safe"

#. Tag: entry
#: performance.xml:636
#, no-c-format
msgid "Query Cache Supported"
msgstr "Query Cache Supported"

#. Tag: entry
#: performance.xml:642 performance.xml:990
#, no-c-format
msgid "Hashtable (not intended for production use)"
msgstr "Hashtable (not intended for production use)"

#. Tag: literal
#: performance.xml:644
#, fuzzy, no-c-format
msgid "org.hibernate.cache.HashtableCacheProvider"
msgstr "<literal>org.hibernate.cache.HashtableCacheProvider "

#. Tag: entry
#: performance.xml:646
#, no-c-format
msgid "memory"
msgstr "memory"

#. Tag: entry
#: performance.xml:650 performance.xml:662 performance.xml:674
#: performance.xml:992 performance.xml:994 performance.xml:996
#: performance.xml:1004 performance.xml:1006 performance.xml:1008
#: performance.xml:1016 performance.xml:1018 performance.xml:1020
#: performance.xml:1028 performance.xml:1030 performance.xml:1040
#: performance.xml:1046 performance.xml:1052 performance.xml:1058
#, no-c-format
msgid "<entry>yes"
msgstr "<entry>yes"

#. Tag: entry
#: performance.xml:654 performance.xml:1002
#, no-c-format
msgid "EHCache"
msgstr "EHCache"

#. Tag: literal
#: performance.xml:656
#, fuzzy, no-c-format
msgid "org.hibernate.cache.EhCacheProvider"
msgstr "<literal>org.hibernate.cache.EhCacheProvider "

#. Tag: entry
#: performance.xml:658 performance.xml:670
#, no-c-format
msgid "memory, disk"
msgstr "memory,disk"

#. Tag: entry
#: performance.xml:666 performance.xml:1014
#, no-c-format
msgid "OSCache"
msgstr "OSCache"

#. Tag: literal
#: performance.xml:668
#, fuzzy, no-c-format
msgid "org.hibernate.cache.OSCacheProvider"
msgstr "<literal>org.hibernate.cache.OSCacheProvider "

#. Tag: entry
#: performance.xml:678 performance.xml:1026
#, no-c-format
msgid "SwarmCache"
msgstr "SwarmCache"

#. Tag: literal
#: performance.xml:680
#, fuzzy, no-c-format
msgid "org.hibernate.cache.SwarmCacheProvider"
msgstr "<literal>org.hibernate.cache.SwarmCacheProvider"

#. Tag: entry
#: performance.xml:682
#, no-c-format
msgid "clustered (ip multicast)"
msgstr "clustered (ip multicast)"

#. Tag: entry
#: performance.xml:684
#, no-c-format
msgid "yes (clustered invalidation)"
msgstr "yes (clustered invalidation)"

#. Tag: entry
#: performance.xml:690 performance.xml:1038
#, no-c-format
msgid "JBoss Cache 1.x"
msgstr "JBoss Cache 1.x"

#. Tag: literal
#: performance.xml:692
#, fuzzy, no-c-format
msgid "org.hibernate.cache.TreeCacheProvider"
msgstr "<literal>org.hibernate.cache.TreeCacheProvider "

#. Tag: entry
#: performance.xml:694 performance.xml:706
#, no-c-format
msgid "clustered (ip multicast), transactional"
msgstr "clustered (ip multicast), transactional"

#. Tag: entry
#: performance.xml:696
#, no-c-format
msgid "yes (replication)"
msgstr "yes (replication)"

#. Tag: entry
#: performance.xml:698 performance.xml:710
#, no-c-format
msgid "yes (clock sync req.)"
msgstr "yes (clock sync req.)"

#. Tag: entry
#: performance.xml:702 performance.xml:1050
#, no-c-format
msgid "JBoss Cache 2"
msgstr "JBoss Cache 2"

#. Tag: literal
#: performance.xml:704
#, fuzzy, no-c-format
msgid "org.hibernate.cache.jbc.JBossCacheRegionFactory"
msgstr "<literal>org.hibernate.cache.jbc.JBossCacheRegionFactory"

#. Tag: entry
#: performance.xml:708
#, no-c-format
msgid "yes (replication or invalidation)"
msgstr "yes (replication or invalidation)"

#. Tag: title
#: performance.xml:717
#, no-c-format
msgid "Cache mappings"
msgstr "缓存映射(Cache mappings)"

#. Tag: para
#: performance.xml:719
#, no-c-format
msgid ""
"As we have done in previous chapters we are looking at the two different "
"possibiltites to configure caching. First configuration via annotations and "
"then via Hibernate mapping files."
msgstr ""

#. Tag: para
#: performance.xml:723
#, no-c-format
msgid ""
"By default, entities are not part of the second level cache and we recommend "
"you to stick to this setting. However, you can override this by setting the "
"<literal>shared-cache-mode element in your persistence."
"xml</filename> file or by using the javax.persistence.sharedCache."
"mode </literal>property in your configuration. The following values are "
"possible:"
msgstr ""

#. Tag: para
#: performance.xml:732
#, no-c-format
msgid ""
"<literal>ENABLE_SELECTIVE (Default and recommended value): "
"entities are not cached unless explicitly marked as cacheable."
msgstr ""

#. Tag: para
#: performance.xml:738
#, no-c-format
msgid ""
"<literal>DISABLE_SELECTIVE: entities are cached unless explicitly "
"marked as not cacheable."
msgstr ""

#. Tag: para
#: performance.xml:743
#, no-c-format
msgid ""
"<literal>ALL: all entities are always cached even if marked as non "
"cacheable."
msgstr ""

#. Tag: para
#: performance.xml:748
#, no-c-format
msgid ""
"<literal>NONE: no entity are cached even if marked as cacheable. "
"This option can make sense to disable second-level cache altogether."
msgstr ""

#. Tag: para
#: performance.xml:754
#, no-c-format
msgid ""
"The cache concurrency strategy used by default can be set globaly via the "
"<literal>hibernate.cache.default_cache_concurrency_strategy "
"configuration property. The values for this property are:"
msgstr ""

#. Tag: literal
#: performance.xml:761
#, fuzzy, no-c-format
msgid "<literal>read-only"
msgstr "条件查询"

#. Tag: literal
#: performance.xml:765
#, fuzzy, no-c-format
msgid "<literal>read-write"
msgstr "条件查询"

#. Tag: literal
#: performance.xml:769
#, fuzzy, no-c-format
msgid "<literal>nonstrict-read-write"
msgstr "nonstrict-read-write"

#. Tag: literal
#: performance.xml:773
#, fuzzy, no-c-format
msgid "<literal>transactional"
msgstr "条件查询"

#. Tag: para
#: performance.xml:778
#, no-c-format
msgid ""
"It is recommended to define the cache concurrency strategy per entity rather "
"than using a global one. Use the <classname>@org.hibernate.annotations."
"Cache</classname> annotation for that."
msgstr ""

#. Tag: title
#: performance.xml:785
#, no-c-format
msgid ""
"Definition of cache concurrency strategy via <classname>@Cache"
msgstr ""

#. Tag: programlisting
#: performance.xml:788
#, no-c-format
msgid ""
"@Entity \n"
"@Cacheable\n"
"@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)\n"
"public class Forest { ... }"
msgstr ""

#. Tag: para
#: performance.xml:791
#, no-c-format
msgid ""
"Hibernate also let's you cache the content of a collection or the "
"identifiers if the collection contains other entities. Use the "
"<classname>@Cache annotation on the collection property."
msgstr ""

#. Tag: title
#: performance.xml:797
#, fuzzy, no-c-format
msgid "Caching collections using annotations"
msgstr "实例化集合和代理(Initializing collections and proxies)"

#. Tag: programlisting
#: performance.xml:799
#, no-c-format
msgid ""
"@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)\n"
"@JoinColumn(name=\"CUST_ID\")\n"
"@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)\n"
"public SortedSet<Ticket> getTickets() {\n"
"    return tickets;\n"
"}"
msgstr ""

#. Tag: para
#: performance.xml:802
#, no-c-format
msgid ""
"shows the<literal> @org.hibernate.annotations.Cache annotations "
"with its attributes. It allows you to define the caching strategy and region "
"of a given second level cache."
msgstr ""

#. Tag: title
#: performance.xml:808
#, no-c-format
msgid "<classname>@Cache annotation with attributes"
msgstr ""

#. Tag: programlisting
#: performance.xml:820
#, no-c-format
msgid ""
"@Cache(\n"
"    CacheConcurrencyStrategy usage();\n"
"    String region() default \"\";\n"
"    String include() default \"all\";\n"
")"
msgstr ""

#. Tag: para
#: performance.xml:824
#, no-c-format
msgid ""
"usage: the given cache concurrency strategy (NONE, READ_ONLY, "
"NONSTRICT_READ_WRITE, READ_WRITE, TRANSACTIONAL)"
msgstr ""

#. Tag: para
#: performance.xml:830
#, no-c-format
msgid ""
"region (optional): the cache region (default to the fqcn of the class or the "
"fq role name of the collection)"
msgstr ""

#. Tag: para
#: performance.xml:835
#, no-c-format
msgid ""
"<literal>include (optional): all to include all properties, non-"
"lazy to only include non lazy properties (default all)."
msgstr ""

#. Tag: para
#: performance.xml:843
#, no-c-format
msgid ""
"Let's now take a look at Hibernate mapping files. There the <literal><"
"cache></literal> element of a class or collection mapping is used to "
"configure the second level cache. Looking at <xref linkend=\"example-"
"hibernate-cache-mapping-element\"/> the parallels to anotations is obvious."
msgstr ""

#. Tag: title
#: performance.xml:850
#, no-c-format
msgid "The Hibernate <literal><cache> mapping element"
msgstr ""

#. Tag: programlisting
#: performance.xml:862
#, fuzzy, no-c-format
msgid ""
"<cache\n"
"    usage=\"transactional|read-write|nonstrict-read-write|read-only\"\n"
"    region=\"RegionName\"\n"
"    include=\"all|non-lazy\"\n"
"/>"
msgstr ""
"<![CDATA["

#. Tag: para
#: performance.xml:866
#, no-c-format
msgid ""
"<literal>usage (required) specifies the caching strategy: "
"<literal>transactional, read-write, "
"<literal>nonstrict-read-write or read-only"
msgstr ""
"<literal>usage(必须)说明了缓存的策略:transactionalread-writenonstrict-read-writeread-only。"

#. Tag: para
#: performance.xml:874
#, no-c-format
msgid ""
"<literal>region (optional: defaults to the class or collection "
"role name): specifies the name of the second level cache region"
msgstr ""
"<literal>region (可选,默认为类或者集合的名字(class or "
"collection role name)) 指定第二级缓存的区域名(name of the second level "
"cache region) "

#. Tag: para
#: performance.xml:880
#, no-c-format
msgid ""
"<literal>include (optional: defaults to all) "
"<literal>non-lazy: specifies that properties of the entity mapped "
"with <literal>lazy=\"true\" cannot be cached when attribute-level "
"lazy fetching is enabled"
msgstr ""
"<literal>include(可选,默认为 all) "
"<literal>non-lazy 当属性级延迟抓取打开时,标记为 lazy="
"\"true\"</literal> 的实体的属性可能无法被缓存 "

#. Tag: para
#: performance.xml:890
#, fuzzy, no-c-format
msgid ""
"Alternatively to <literal><cache>, you can use <"
"class-cache></literal> and <collection-cache> "
"elements in <literal>hibernate.cfg.xml."
msgstr ""
"另外(首选?),你可以在<literal>hibernate.cfg.xml 中指定 "
"<literal><class-cache> 和 <collection-cache> cache can be used. This is the "
"simplest and optimal performing strategy. It is even safe for use in a "
"cluster."
msgstr ""
"如果你的应用程序只需读取一个持久化类的实例,而无需对其修改, 那么就可以对其进"
"行<literal>只读 缓存。这是最简单,也是实用性最好的方法。甚至在集群"
"中,它也能完美地运作。 "

#. Tag: title
#: performance.xml:909
#, no-c-format
msgid "Strategy: read/write"
msgstr "策略:读写/缓存(Strategy:read/write)"

#. Tag: para
#: performance.xml:911
#, no-c-format
msgid ""
"If the application needs to update data, a <literal>read-write "
"cache might be appropriate. This cache strategy should never be used if "
"serializable transaction isolation level is required. If the cache is used "
"in a JTA environment, you must specify the property <literal>hibernate."
"transaction.manager_lookup_class</literal> and naming a strategy for "
"obtaining the JTA <literal>TransactionManager. In other "
"environments, you should ensure that the transaction is completed when "
"<literal>Session.close() or Session.disconnect() support locking."
msgstr ""
"如果应用程序需要更新数据,那么使用<literal>读/写缓存 比较合适。 如"
"果应用程序要求“序列化事务”的隔离级别(serializable transaction isolation "
"level),那么就决不能使用这种缓存策略。 如果在 JTA 环境中使用缓存,你必须指"
"定 <literal>hibernate.transaction.manager_lookup_class 属性的值, "
"通过它,Hibernate 才能知道该应用程序中 JTA 的<literal>TransactionManagerSession.close()Session.disconnect() 调用前, 整个事务已经结"
"束。 如果你想在集群环境中使用此策略,你必须保证底层的缓存实现支持锁定"
"(locking)。Hibernate 内置的缓存策略并不支持锁定功能。 "

#. Tag: title
#: performance.xml:927
#, no-c-format
msgid "Strategy: nonstrict read/write"
msgstr "策略:非严格读/写缓存(Strategy:nonstrict read/write)"

#. Tag: para
#: performance.xml:929
#, no-c-format
msgid ""
"If the application only occasionally needs to update data (i.e. if it is "
"extremely unlikely that two transactions would try to update the same item "
"simultaneously), and strict transaction isolation is not required, a "
"<literal>nonstrict-read-write cache might be appropriate. If the "
"cache is used in a JTA environment, you must specify <literal>hibernate."
"transaction.manager_lookup_class</literal>. In other environments, you "
"should ensure that the transaction is completed when <literal>Session.close()"
"</literal> or Session.disconnect() is called."
msgstr ""
"如果应用程序只偶尔需要更新数据(也就是说,两个事务同时更新同一记录的情况很不"
"常见),也不需要十分严格的事务隔离,那么比较适合使用<literal>非严格读/写缓存"
"</literal>策略。如果在 JTA 环境中使用该策略,你必须为其指定 "
"<literal>hibernate.transaction.manager_lookup_class 属性的值,在其"
"它环境中,你必须保证在<literal>Session.close()、或 "
"<literal>Session.disconnect() 调用前,整个事务已经结束。 "

#. Tag: title
#: performance.xml:941
#, no-c-format
msgid "Strategy: transactional"
msgstr "策略:事务缓存(transactional)"

#. Tag: para
#: performance.xml:943
#, no-c-format
msgid ""
"The <literal>transactional cache strategy provides support for "
"fully transactional cache providers such as JBoss TreeCache. Such a cache "
"can only be used in a JTA environment and you must specify "
"<literal>hibernate.transaction.manager_lookup_class."
msgstr ""
"Hibernate 的<literal>事务缓存策略提供了全事务的缓存支持,例如对 "
"JBoss TreeCache 的支持。这样的缓存只能用于 JTA 环境中,你必须指定为其  "
"<literal>hibernate.transaction.manager_lookup_class 属性。 "

#. Tag: title
#: performance.xml:950
#, no-c-format
msgid "Cache-provider/concurrency-strategy compatibility"
msgstr "各种缓存提供商/缓存并发策略的兼容性"

#. Tag: para
#: performance.xml:953
#, no-c-format
msgid ""
"None of the cache providers support all of the cache concurrency strategies."
msgstr ""
"没有一种缓存提供商能够支持上列的所有缓存并发策略。下表中列出了各种提供器、及"
"其各自适用的并发策略。 "

#. Tag: para
#: performance.xml:957
#, no-c-format
msgid ""
"The following table shows which providers are compatible with which "
"concurrency strategies."
msgstr ""
"没有一种缓存提供商能够支持上列的所有缓存并发策略。下表中列出了各种提供器、及"
"其各自适用的并发策略。 "

#. Tag: title
#: performance.xml:961
#, no-c-format
msgid "Cache Concurrency Strategy Support"
msgstr ""
"各种缓存提供商对缓存并发策略的支持情况(Cache Concurrency Strategy Support)"

#. Tag: entry
#: performance.xml:978
#, fuzzy, no-c-format
msgid "<entry>read-only"
msgstr "<entry>yes"

#. Tag: entry
#: performance.xml:980
#, fuzzy, no-c-format
msgid "<entry>nonstrict-read-write"
msgstr "nonstrict-read-write"

#. Tag: entry
#: performance.xml:982
#, fuzzy, no-c-format
msgid "<entry>read-write"
msgstr "<entry>yes"

#. Tag: entry
#: performance.xml:984
#, fuzzy, no-c-format
msgid "<entry>transactional"
msgstr "<entry>yes"

#. Tag: title
#: performance.xml:1067
#, no-c-format
msgid "Managing the caches"
msgstr "管理缓存(Managing the caches)"

#. Tag: para
#: performance.xml:1069
#, no-c-format
msgid ""
"Whenever you pass an object to <literal>save(), update()saveOrUpdate(), and whenever you retrieve an "
"object using <literal>load(), get(), "
"<literal>list(), iterate() or scroll()"
"</literal>, that object is added to the internal cache of the "
"<literal>Session."
msgstr ""
"无论何时,当你给 <literal>save()、update() 或  "
"<literal>saveOrUpdate() 方法传递一个对象时,或使用 load()"
"</literal>、get()list()、"
"<literal>iterate()scroll() 方法获得一个对象"
"时,该对象都将被加入到 <literal>Session 的内部缓存中。 "

#. Tag: para
#: performance.xml:1076
#, no-c-format
msgid ""
"When <literal>flush() is subsequently called, the state of that "
"object will be synchronized with the database. If you do not want this "
"synchronization to occur, or if you are processing a huge number of objects "
"and need to manage memory efficiently, the <literal>evict() method "
"can be used to remove the object and its collections from the first-level "
"cache."
msgstr ""
"当随后 flush() 方法被调用时,对象的状态会和数据库取得同步。如果你不希望此同步"
"操作发生,或者你正处理大量对象、需要对有效管理内存时,你可以调用 "
"<literal>evict() 方法,从一级缓存中去掉这些对象及其集合。 "

#. Tag: title
#: performance.xml:1084
#, no-c-format
msgid ""
"Explcitly evicting a cached instance from the first level cache using "
"<methodname>Session.evict()"
msgstr ""

#. Tag: programlisting
#: performance.xml:1087
#, fuzzy, no-c-format
msgid ""
"ScrollableResult cats = sess.createQuery(\"from Cat as cat\").scroll(); //a "
"huge result set\n"
"while ( cats.next() ) {\n"
"    Cat cat = (Cat) cats.get(0);\n"
"    doSomethingWithACat(cat);\n"
"    sess.evict(cat);\n"
"}"
msgstr ""
"<![CDATA[ScrollableResult cats = sess.createQuery(\"from Cat as cat\").scroll"
"(); //a huge result set\n"
"while ( cats.next() ) {\n"
"    Cat cat = (Cat) cats.get(0);\n"
"    doSomethingWithACat(cat);\n"
"    sess.evict(cat);\n"
"}]]>"

#. Tag: para
#: performance.xml:1090
#, no-c-format
msgid ""
"The <literal>Session also provides a contains() "
"method to determine if an instance belongs to the session cache."
msgstr ""
"Session 还提供了一个 <literal>contains() 方法,用来判断某个实例是否"
"处于当前 session 的缓存中。"

#. Tag: para
#: performance.xml:1094
#, no-c-format
msgid ""
"To evict all objects from the session cache, call <literal>Session.clear() for evicting the cached state of an "
"instance, entire class, collection instance or entire collection role."
msgstr ""
"对于二级缓存来说,在 <literal>SessionFactory 中定义了许多方法,清除"
"缓存中实例、整个类、集合实例或者整个集合。"

#. Tag: title
#: performance.xml:1103
#, no-c-format
msgid ""
"Second-level cache eviction via <methodname>SessionFactoty.evict() SessionFacyory.evictCollection()"
msgstr ""

#. Tag: programlisting
#: performance.xml:1107
#, fuzzy, no-c-format
msgid ""
"sessionFactory.evict(Cat.class, catId); //evict a particular Cat\n"
"sessionFactory.evict(Cat.class);  //evict all Cats\n"
"sessionFactory.evictCollection(\"Cat.kittens\", catId); //evict a particular "
"collection of kittens\n"
"sessionFactory.evictCollection(\"Cat.kittens\"); //evict all kitten "
"collections"
msgstr ""
"<![CDATA[sessionFactory.evict(Cat.class, catId); //evict a particular Cat\n"
"sessionFactory.evict(Cat.class);  //evict all Cats\n"
"sessionFactory.evictCollection(\"Cat.kittens\", catId); //evict a particular "
"collection of kittens\n"
"sessionFactory.evictCollection(\"Cat.kittens\"); //evict all kitten "
"collections]]>"

#. Tag: para
#: performance.xml:1110
#, no-c-format
msgid ""
"The <literal>CacheMode controls how a particular session interacts "
"with the second-level cache:"
msgstr ""
"<literal>CacheMode 参数用于控制具体的 Session 如何与二级缓存进行交"
"互。 "

#. Tag: para
#: performance.xml:1115
#, no-c-format
msgid ""
"<literal>CacheMode.NORMAL: will read items from and write items to "
"the second-level cache"
msgstr "<literal>CacheMode.NORMAL:从二级缓存中读、写数据。"

#. Tag: para
#: performance.xml:1120
#, no-c-format
msgid ""
"<literal>CacheMode.GET: will read items from the second-level "
"cache. Do not write to the second-level cache except when updating data"
msgstr ""
"<literal>CacheMode.GET:从二级缓存中读取数据,仅在数据更新时对二级"
"缓存写数据。"

#. Tag: para
#: performance.xml:1126
#, no-c-format
msgid ""
"<literal>CacheMode.PUT: will write items to the second-level "
"cache. Do not read from the second-level cache"
msgstr ""
"<literal>CacheMode.PUT:仅向二级缓存写数据,但不从二级缓存中读数"
"据。"

#. Tag: para
#: performance.xml:1131
#, no-c-format
msgid ""
"<literal>CacheMode.REFRESH: will write items to the second-level "
"cache. Do not read from the second-level cache. Bypass the effect of "
"<literal>hibernate.cache.use_minimal_puts forcing a refresh of the "
"second-level cache for all items read from the database"
msgstr ""
"<literal>CacheMode.REFRESH:仅向二级缓存写数据,但不从二级缓存中读"
"数据。通过 <literal>hibernate.cache.use_minimal_puts 的设置,强制二"
"级缓存从数据库中读取数据,刷新缓存内容。"

#. Tag: para
#: performance.xml:1139
#, no-c-format
msgid ""
"To browse the contents of a second-level or query cache region, use the "
"<literal>Statistics API:"
msgstr ""
"如若需要查看二级缓存或查询缓存区域的内容,你可以使用<literal>统计"
"(Statistics)</literal> API。"

#. Tag: title
#: performance.xml:1143
#, fuzzy, no-c-format
msgid ""
"Browsing the second-level cache entries via the <classname>Statistics, holding the "
"cached query results"
msgstr ""
"<classname>org.hibernate.cache.StandardQueryCache,保存缓存的查询"
"结果"

#. Tag: para
#: performance.xml:1186
#, no-c-format
msgid ""
"<classname>org.hibernate.cache.UpdateTimestampsCache, holding "
"timestamps of the most recent updates to queryable tables. These are used to "
"validate the results as they are served from the query cache."
msgstr ""
"<classname>org.hibernate.cache.UpdateTimestampsCache,保存对可查"
"询表的最近更新的时间戳。它们用于检验查询结果。"

#. Tag: para
#: performance.xml:1194
#, fuzzy, no-c-format
msgid ""
"If you configure your underlying cache implementation to use expiry or "
"timeouts is very important that the cache timeout of the underlying cache "
"region for the UpdateTimestampsCache be set to a higher value than the "
"timeouts of any of the query caches. In fact, we recommend that the the "
"UpdateTimestampsCache region not be configured for expiry at all. Note, in "
"particular, that an LRU cache expiry policy is never appropriate."
msgstr ""
"如果你配置底层缓存实现来使用过期(expiry)或超时(timeout),把用于 "
"UpdateTimestampsCache 的底层缓存 region 的缓存超时时间设置为比任何查询缓存的"
"超时时间更长的值是非常重要的。事实上,我们推荐根本不把 UpdateTimestampsCache "
"region 用于 expiry。请注意,特别是 LRU 缓存 expiry 策略总是不合适的。"

#. Tag: para
#: performance.xml:1203
#, no-c-format
msgid ""
"As mentioned above, most queries do not benefit from caching or their "
"results. So by default, individual queries are not cached even after "
"enabling query caching. To enable results caching for a particular query, "
"call <literal>org.hibernate.Query.setCacheable(true). This call "
"allows the query to look for existing cache results or add its results to "
"the cache when it is executed."
msgstr ""
"如上面所提及的,绝大多数的查询并不能从查询缓存中受益,所以 Hibernate 默认是不"
"进行查询缓存的。如若需要进行缓存,请调用 <literal>org.hibernate.Query."
"setCacheable(true)</literal>方法。这个调用会让查询在执行过程中时先从缓存中"
"查找结果,并将自己的结果集放到缓存中去。 "

#. Tag: para
#: performance.xml:1211
#, no-c-format
msgid ""
"The query cache does not cache the state of the actual entities in the "
"cache; it caches only identifier values and results of value type. For this "
"reaso, the query cache should always be used in conjunction with the second-"
"level cache for those entities expected to be cached as part of a query "
"result cache (just as with collection caching)."
msgstr ""
"查询缓存不会缓存缓存中实际实体的状态;它只缓存标识符值和值类型的结果。出于这"
"个原因,对于那些作为查询结果缓存的一部分(和集合缓存一样)进行缓存的实体,查"
"询缓存应该和二级缓存一起使用。"

#. Tag: title
#: performance.xml:1221
#, no-c-format
msgid "Query cache regions"
msgstr "查询缓存区"

#. Tag: para
#: performance.xml:1223
#, no-c-format
msgid ""
"If you require fine-grained control over query cache expiration policies, "
"you can specify a named cache region for a particular query by calling "
"<literal>Query.setCacheRegion()."
msgstr ""
"如果你要对查询缓存的失效政策进行精确的控制,你必须调用 <literal>Query."
"setCacheRegion()</literal> 方法,为每个查询指定其命名的缓存区域。 "

#. Tag: programlisting
#: performance.xml:1227
#, fuzzy, no-c-format
msgid ""
"List blogs = sess.createQuery(\"from Blog blog where blog.blogger = :blogger"
"\")\n"
"        .setEntity(\"blogger\", blogger)\n"
"        .setMaxResults(15)\n"
"        .setCacheable(true)\n"
"        .setCacheRegion(\"frontpages\")\n"
"        .list();"
msgstr ""
"<![CDATA[List blogs = sess.createQuery(\"from Blog blog where blog.blogger "
"= :blogger\")\n"
"    .setEntity(\"blogger\", blogger)\n"
"    .setMaxResults(15)\n"
"    .setCacheable(true)\n"
"    .setCacheRegion(\"frontpages\")\n"
"    .list();]]>"

#. Tag: para
#: performance.xml:1229
#, no-c-format
msgid ""
"If you want to force the query cache to refresh one of its regions "
"(disregard any cached results it finds there) you can use <literal>org."
"hibernate.Query.setCacheMode(CacheMode.REFRESH)</literal>. In conjunction "
"with the region you have defined for the given query, Hibernate will "
"selectively force the results cached in that particular region to be "
"refreshed. This is particularly useful in cases where underlying data may "
"have been updated via a separate process and is a far more efficient "
"alternative to bulk eviction of the region via <literal>org.hibernate."
"SessionFactory.evictQueries()</literal>."
msgstr ""
"如果查询需要强行刷新其查询缓存区域,那么你应该调用 <literal>org.hibernate."
"Query.setCacheMode(CacheMode.REFRESH)</literal>方法。 这对在其他进程中修改"
"底层数据(例如,不通过Hibernate修改数据),或对那些需要选择性更新特定查询结果"
"集的情况特别有用。这是对 <literal>org.hibernate.SessionFactory.evictQueries()"
"</literal> 的更为有效的替代方案,同样可以清除查询缓存区域。"

#. Tag: title
#: performance.xml:1242
#, no-c-format
msgid "Understanding Collection performance"
msgstr "理解集合性能(Understanding Collection performance)"

#. Tag: para
#: performance.xml:1244
#, no-c-format
msgid ""
"In the previous sections we have covered collections and their applications. "
"In this section we explore some more issues in relation to collections at "
"runtime."
msgstr ""
"在前面的章节里我们已经讨论了集合和相关应用程序。在本节我么将探索运行时集合的"
"更多问题。"

#. Tag: title
#: performance.xml:1249
#, no-c-format
msgid "Taxonomy"
msgstr "分类(Taxonomy)"

#. Tag: para
#: performance.xml:1251
#, no-c-format
msgid "Hibernate defines three basic kinds of collections:"
msgstr "Hibernate 定义了三种基本类型的集合:"

#. Tag: para
#: performance.xml:1255
#, no-c-format
msgid "collections of values"
msgstr "值数据集合"

#. Tag: para
#: performance.xml:1259
#, no-c-format
msgid "one-to-many associations"
msgstr "一对多关联(One-to-many Associations) "

#. Tag: para
#: performance.xml:1263
#, no-c-format
msgid "many-to-many associations"
msgstr "多对多关联 "

#. Tag: para
#: performance.xml:1267
#, no-c-format
msgid ""
"This classification distinguishes the various table and foreign key "
"relationships but does not tell us quite everything we need to know about "
"the relational model. To fully understand the relational structure and "
"performance characteristics, we must also consider the structure of the "
"primary key that is used by Hibernate to update or delete collection rows. "
"This suggests the following classification:"
msgstr ""
"这个分类是区分了不同的表和外键关系类型,但是它没有告诉我们关系模型的所有内"
"容。 要完全理解他们的关系结构和性能特点,我们必须同时考虑“用于 Hibernate 更新"
"或删除集合行数据的主键的结构”。因此得到了如下的分类:"

#. Tag: para
#: performance.xml:1276
#, no-c-format
msgid "indexed collections"
msgstr "有序集合类"

#. Tag: para
#: performance.xml:1280
#, no-c-format
msgid "sets"
msgstr "集合(sets)"

#. Tag: para
#: performance.xml:1284
#, no-c-format
msgid "bags"
msgstr "包(bags)"

#. Tag: para
#: performance.xml:1288
#, no-c-format
msgid ""
"All indexed collections (maps, lists, and arrays) have a primary key "
"consisting of the <literal><key> and <index><index> 组成的主键。这种情况下集合类的更"
"新是非常高效的 — 主键已经被有效的索引,因此当 Hibernate 试图更新或删除一行"
"时,可以迅速找到该行数据。 "

#. Tag: para
#: performance.xml:1295
#, no-c-format
msgid ""
"Sets have a primary key consisting of <literal><key> and "
"element columns. This can be less efficient for some types of collection "
"element, particularly composite elements or large text or binary fields, as "
"the database may not be able to index a complex primary key as efficiently. "
"However, for one-to-many or many-to-many associations, particularly in the "
"case of synthetic identifiers, it is likely to be just as efficient. If you "
"want <literal>SchemaExport to actually create the primary key of a "
"<literal><set>, you must declare all columns as not-"
"null=\"true\"</literal>."
msgstr ""
"集合(sets)的主键由 <literal><key> 和其他元素字段构成。对于"
"有些元素类型来说,这很低效,特别是组合元素或者大文本、大二进制字段;数据库可"
"能无法有效的对复杂的主键进行索引。另一方面,对于一对多、多对多关联,特别是合"
"成的标识符来说,集合也可以达到同样的高效性能。( 附注:如果你希望 "
"<literal>SchemaExport 为你的 <set> 创建主"
"键,你必须把所有的字段都声明为 <literal>not-null=\"true\"。) "

#. Tag: para
#: performance.xml:1306
#, no-c-format
msgid ""
"<literal><idbag> mappings define a surrogate key, so they "
"are efficient to update. In fact, they are the best case."
msgstr ""
"<literal><idbag> 映射定义了代理键,因此它总是可以很高效的被更"
"新。事实上,<literal><idbag> 拥有着最好的性能表现。 "

#. Tag: para
#: performance.xml:1309
#, no-c-format
msgid ""
"Bags are the worst case since they permit duplicate element values and, as "
"they have no index column, no primary key can be defined. Hibernate has no "
"way of distinguishing between duplicate rows. Hibernate resolves this "
"problem by completely removing in a single <literal>DELETE and "
"recreating the collection whenever it changes. This can be inefficient."
msgstr ""
"Bag 是最差的。因为 bag 允许重复的元素值,也没有索引字段,因此不可能定义主"
"键。 Hibernate 无法判断出重复的行。当这种集合被更改时,Hibernate 将会先完整地"
"移除 (通过一个(in a single <literal>DELETE))整个集合,然后再重"
"新创建整个集合。因此 Bag 是非常低效的。 "

#. Tag: para
#: performance.xml:1316
#, no-c-format
msgid ""
"For a one-to-many association, the \"primary key\" may not be the physical "
"primary key of the database table. Even in this case, the above "
"classification is still useful. It reflects how Hibernate \"locates\" "
"individual rows of the collection."
msgstr ""
"请注意:对于一对多关联来说,“主键”很可能并不是数据库表的物理主键。但就算在此"
"情况下,上面的分类仍然是有用的。(它仍然反映了 Hibernate 在集合的各数据行中是"
"如何进行“定位”的。) "

#. Tag: title
#: performance.xml:1323
#, no-c-format
msgid ""
"Lists, maps, idbags and sets are the most efficient collections to update"
msgstr "Lists,maps 和 sets 用于更新效率最高"

#. Tag: para
#: performance.xml:1326
#, no-c-format
msgid ""
"From the discussion above, it should be clear that indexed collections and "
"sets allow the most efficient operation in terms of adding, removing and "
"updating elements."
msgstr ""
"根据我们上面的讨论,显然有序集合类型和大多数 set 都可以在增加、删除、修改元素"
"中拥有最好的性能。 "

#. Tag: para
#: performance.xml:1330
#, no-c-format
msgid ""
"There is, arguably, one more advantage that indexed collections have over "
"sets for many-to-many associations or collections of values. Because of the "
"structure of a <literal>Set, Hibernate does not UPDATESetINSERT and DELETE 的内在结构, 如果“改变”了一个元素,Hibernate 并不"
"会<literal>更新(UPDATE)这一行。对于 Set 来说,"
"只有在<literal>插入(INSERT)和删除(DELETE) 操"
"作时“改变”才有效。再次强调:这段讨论对“一对多关联”并不适用。 "

#. Tag: para
#: performance.xml:1338
#, no-c-format
msgid ""
"After observing that arrays cannot be lazy, you can conclude that lists, "
"maps and idbags are the most performant (non-inverse) collection types, with "
"sets not far behind. You can expect sets to be the most common kind of "
"collection in Hibernate applications. This is because the \"set\" semantics "
"are most natural in the relational model."
msgstr ""
"注意到数组无法延迟载入,我们可以得出结论,list,map 和 idbags 是最高效的(非"
"反向)集合类型,set 则紧随其后。 在 Hibernate 中,set 应该时最通用的集合类"
"型,这时因为“set”的语义在关系模型中是最自然的。 "

#. Tag: para
#: performance.xml:1344
#, no-c-format
msgid ""
"However, in well-designed Hibernate domain models, most collections are in "
"fact one-to-many associations with <literal>inverse=\"true\". For "
"these associations, the update is handled by the many-to-one end of the "
"association, and so considerations of collection update performance simply "
"do not apply."
msgstr ""
"但是,在设计良好的 Hibernate 领域模型中,我们通常可以看到更多的集合事实上是带"
"有  <literal>inverse=\"true\" 的一对多的关联。对于这些关联,更新操"
"作将会在多对一的这一端进行处理。因此对于此类情况,无需考虑其集合的更新性能。 "

#. Tag: title
#: performance.xml:1352
#, no-c-format
msgid "Bags and lists are the most efficient inverse collections"
msgstr "Bag 和 list 是反向集合类中效率最高的"

#. Tag: para
#: performance.xml:1354
#, no-c-format
msgid ""
"There is a particular case, however, in which bags, and also lists, are much "
"more performant than sets. For a collection with <literal>inverse=\"true\", "
"<literal>Collection.add() or Collection.addAll()List. This "
"can make the following common code much faster:"
msgstr ""
"在把 bag 扔进水沟之前,你必须了解,在一种情况下,bag 的性能(包括list)要比 "
"set 高得多:对于指明了 <literal>inverse=\"true\" 的集合类(比如说,"
"标准的双向的一对多关联),我们可以在未初始化(fetch)包元素的情况下直接向 "
"bag 或 list 添加新元素! 这是因为 <literal>Collection.add())或者 "
"<literal>Collection.addAll() 方法对 bag 或者 List 总是返回 true(这"
"点与与 Set 不同)。因此对于下面的相同代码来说,速度会快得多。 "

#. Tag: programlisting
#: performance.xml:1365
#, fuzzy, no-c-format
msgid ""
"Parent p = (Parent) sess.load(Parent.class, id);\n"
"Child c = new Child();\n"
"c.setParent(p);\n"
"p.getChildren().add(c);  //no need to fetch the collection!\n"
"sess.flush();"
msgstr ""
"<![CDATA[Parent p = (Parent) sess.load(Parent.class, id);\n"
"Child c = new Child();\n"
"c.setParent(p);\n"
"p.getChildren().add(c);  //no need to fetch the collection!\n"
"sess.flush();]]>"

#. Tag: title
#: performance.xml:1369
#, no-c-format
msgid "One shot delete"
msgstr "一次性删除(One shot delete)"

#. Tag: para
#: performance.xml:1371
#, no-c-format
msgid ""
"Deleting collection elements one by one can sometimes be extremely "
"inefficient. Hibernate knows not to do that in the case of an newly-empty "
"collection (if you called <literal>list.clear(), for example). In "
"this case, Hibernate will issue a single <literal>DELETE."
msgstr ""
"偶尔的,逐个删除集合类中的元素是相当低效的。Hibernate 并没那么笨,如果你想要"
"把整个集合都删除(比如说调用 list.clear()),Hibernate 只需要一个 DELETE 就搞"
"定了。 "

#. Tag: para
#: performance.xml:1377
#, no-c-format
msgid ""
"Suppose you added a single element to a collection of size twenty and then "
"remove two elements. Hibernate will issue one <literal>INSERT "
"statement and two <literal>DELETE statements, unless the "
"collection is a bag. This is certainly desirable."
msgstr ""
"假设我们在一个长度为20的集合类中新增加了一个元素,然后再删除两个。Hibernate "
"会安排一条 <literal>INSERT 语句和两条 DELETE 语"
"句(除非集合类是一个 bag)。这当然是令人满意的。 "

#. Tag: para
#: performance.xml:1383
#, no-c-format
msgid ""
"However, suppose that we remove eighteen elements, leaving two and then add "
"thee new elements. There are two possible ways to proceed"
msgstr ""
"但是,假设我们删除了 18 个数据,只剩下 2 个,然后新增 3 个。则有两种处理方"
"式:"

#. Tag: para
#: performance.xml:1389
#, no-c-format
msgid "delete eighteen rows one by one and then insert three rows"
msgstr "逐一的删除这 18 个数据,再新增三个;"

#. Tag: para
#: performance.xml:1394
#, no-c-format
msgid ""
"remove the whole collection in one SQL <literal>DELETE and insert "
"all five current elements one by one"
msgstr "删除整个集合类(只用一句 DELETE 语句),然后逐一添加 5 个数据。"

#. Tag: para
#: performance.xml:1400
#, no-c-format
msgid ""
"Hibernate cannot know that the second option is probably quicker. It would "
"probably be undesirable for Hibernate to be that intuitive as such behavior "
"might confuse database triggers, etc."
msgstr ""
"Hibernate 还没那么聪明,知道第二种选择可能会比较快。(也许让 Hibernate 不这么"
"聪明也是好事,否则可能会引发意外的“数据库触发器”之类的问题。)"

#. Tag: para
#: performance.xml:1404
#, no-c-format
msgid ""
"Fortunately, you can force this behavior (i.e. the second strategy) at any "
"time by discarding (i.e. dereferencing) the original collection and "
"returning a newly instantiated collection with all the current elements."
msgstr ""
"幸运的是,你可以强制使用第二种策略。你需要取消原来的整个集合类(解除其引"
"用),然后再返回一个新的实例化的集合类,只包含需要的元素。有些时候这是非常有"
"用的。 "

#. Tag: para
#: performance.xml:1409
#, no-c-format
msgid ""
"One-shot-delete does not apply to collections mapped <literal>inverse=\"true"
"\"</literal>."
msgstr ""
"显然,一次性删除并不适用于被映射为 <literal>inverse=\"true\" 的集"
"合。 "

#. Tag: title
#: performance.xml:1415
#, no-c-format
msgid "Monitoring performance"
msgstr "监测性能(Monitoring performance)"

#. Tag: para
#: performance.xml:1417
#, no-c-format
msgid ""
"Optimization is not much use without monitoring and access to performance "
"numbers. Hibernate provides a full range of figures about its internal "
"operations. Statistics in Hibernate are available per "
"<literal>SessionFactory."
msgstr ""
"没有监测和性能参数而进行优化是毫无意义的。Hibernate 为其内部操作提供了一系列"
"的示意图,因此可以从 每个 <literal>SessionFactory 抓取其统计数据。"

#. Tag: title
#: performance.xml:1423
#, no-c-format
msgid "Monitoring a SessionFactory"
msgstr "监测 SessionFactory"

#. Tag: para
#: performance.xml:1425
#, no-c-format
msgid ""
"You can access <literal>SessionFactory metrics in two ways. Your "
"first option is to call <literal>sessionFactory.getStatistics() "
"and read or display the <literal>Statistics yourself."
msgstr ""
"你可以有两种方式访问 <literal>SessionFactory 的数据记录,第一种就是"
"自己直接调用 <literal>sessionFactory.getStatistics() 方法读取、显示"
"<literal>统计数据。"

#. Tag: para
#: performance.xml:1430
#, no-c-format
msgid ""
"Hibernate can also use JMX to publish metrics if you enable the "
"<literal>StatisticsService MBean. You can enable a single MBean "
"for all your <literal>SessionFactory or one per factory. See the "
"following code for minimalistic configuration examples:"
msgstr ""
"此外,如果你打开 <literal>StatisticsService MBean 选项,那么 "
"Hibernate 则可以使用 JMX 技术 发布其数据记录。你可以让应用中所有的 "
"<literal>SessionFactory 同时共享一个 MBean,也可以每个 "
"SessionFactory 分配一个 MBean。下面的代码即是其演示代码: "

#. Tag: programlisting
#: performance.xml:1435
#, fuzzy, no-c-format
msgid ""
"// MBean service registration for a specific SessionFactory\n"
"Hashtable tb = new Hashtable();\n"
"tb.put(\"type\", \"statistics\");\n"
"tb.put(\"sessionFactory\", \"myFinancialApp\");\n"
"ObjectName on = new ObjectName(\"hibernate\", tb); // MBean object name\n"
"\n"
"StatisticsService stats = new StatisticsService(); // MBean implementation\n"
"stats.setSessionFactory(sessionFactory); // Bind the stats to a "
"SessionFactory\n"
"server.registerMBean(stats, on); // Register the Mbean on the server"
msgstr ""
"<![CDATA[// MBean service registration for a specific SessionFactory\n"
"Hashtable tb = new Hashtable();\n"
"tb.put(\"type\", \"statistics\");\n"
"tb.put(\"sessionFactory\", \"myFinancialApp\");\n"
"ObjectName on = new ObjectName(\"hibernate\", tb); // MBean object name\n"
"\n"
"StatisticsService stats = new StatisticsService(); // MBean implementation\n"
"stats.setSessionFactory(sessionFactory); // Bind the stats to a "
"SessionFactory\n"
"server.registerMBean(stats, on); // Register the Mbean on the server]]>"

#. Tag: programlisting
#: performance.xml:1437
#, fuzzy, no-c-format
msgid ""
"// MBean service registration for all SessionFactory's\n"
"Hashtable tb = new Hashtable();\n"
"tb.put(\"type\", \"statistics\");\n"
"tb.put(\"sessionFactory\", \"all\");\n"
"ObjectName on = new ObjectName(\"hibernate\", tb); // MBean object name\n"
"\n"
"StatisticsService stats = new StatisticsService(); // MBean implementation\n"
"server.registerMBean(stats, on); // Register the MBean on the server"
msgstr ""
"<![CDATA[// MBean service registration for all SessionFactory's\n"
"Hashtable tb = new Hashtable();\n"
"tb.put(\"type\", \"statistics\");\n"
"tb.put(\"sessionFactory\", \"all\");\n"
"ObjectName on = new ObjectName(\"hibernate\", tb); // MBean object name\n"
"\n"
"StatisticsService stats = new StatisticsService(); // MBean implementation\n"
"server.registerMBean(stats, on); // Register the MBean on the server]]>"

#. Tag: para
#: performance.xml:1439
#, no-c-format
msgid ""
"You can activate and deactivate the monitoring for a "
"<literal>SessionFactory:"
msgstr ""
"你可以通过以下方法打开或关闭 <literal>SessionFactory 的监测功能: "

#. Tag: para
#: performance.xml:1444
#, no-c-format
msgid ""
"at configuration time, set <literal>hibernate.generate_statistics "
"to <literal>false"
msgstr ""
"在配置期间,将 <literal>hibernate.generate_statistics 设置为 "
"<literal>true 或 false;"

#. Tag: para
#: performance.xml:1452
#, no-c-format
msgid ""
"at runtime: <literal>sf.getStatistics().setStatisticsEnabled(true) "
"or <literal>hibernateStatsBean.setStatisticsEnabled(true)"
msgstr ""
"在运行期间,则可以可以通过 <literal>sf.getStatistics().setStatisticsEnabled"
"(true)</literal> 或 hibernateStatsBean.setStatisticsEnabled(true) method."
msgstr ""
"你也可以在程序中调用 <literal>clear() 方法重置统计数据,调用 "
"<literal>logSummary() 在日志中记录(info 级别)其总结。 "

#. Tag: title
#: performance.xml:1464
#, no-c-format
msgid "Metrics"
msgstr "数据记录(Metrics)"

#. Tag: para
#: performance.xml:1466
#, no-c-format
msgid ""
"Hibernate provides a number of metrics, from basic information to more "
"specialized information that is only relevant in certain scenarios. All "
"available counters are described in the <literal>Statistics "
"interface API, in three categories:"
msgstr ""
"Hibernate 提供了一系列数据记录,其记录的内容包括从最基本的信息到与具体场景的"
"特殊信息。所有的测量值都可以由 <literal>Statistics 接口 API 进行访"
"问,主要分为三类:"

#. Tag: para
#: performance.xml:1473
#, no-c-format
msgid ""
"Metrics related to the general <literal>Session usage, such as "
"number of open sessions, retrieved JDBC connections, etc."
msgstr ""
"使用 <literal>Session 的普通数据记录,例如打开的 Session 的个数、取"
"得的 JDBC 的连接数等;"

#. Tag: para
#: performance.xml:1479
#, no-c-format
msgid ""
"Metrics related to the entities, collections, queries, and caches as a whole "
"(aka global metrics)."
msgstr "实体、集合、查询、缓存等内容的统一数据记录。"

#. Tag: para
#: performance.xml:1484
#, no-c-format
msgid ""
"Detailed metrics related to a particular entity, collection, query or cache "
"region."
msgstr "和具体实体、集合、查询、缓存相关的详细数据记录"

#. Tag: para
#: performance.xml:1489
#, no-c-format
msgid ""
"For example, you can check the cache hit, miss, and put ratio of entities, "
"collections and queries, and the average time a query needs. Be aware that "
"the number of milliseconds is subject to approximation in Java. Hibernate is "
"tied to the JVM precision and on some platforms this might only be accurate "
"to 10 seconds."
msgstr ""
"例如:你可以检查缓存的命中成功次数,缓存的命中失败次数,实体、集合和查询的使"
"用概率,查询的平均时间等。请注意 Java 中时间的近似精度是毫秒。Hibernate 的数"
"据精度和具体的 JVM 有关,在有些平台上其精度甚至只能精确到 10 秒。 "

#. Tag: para
#: performance.xml:1495
#, no-c-format
msgid ""
"Simple getters are used to access the global metrics (i.e. not tied to a "
"particular entity, collection, cache region, etc.). You can access the "
"metrics of a particular entity, collection or cache region through its name, "
"and through its HQL or SQL representation for queries. Please refer to the "
"<literal>Statistics, EntityStatistics, "
"<literal>CollectionStatistics, "
"<literal>SecondLevelCacheStatistics, and QueryStatisticsEntityStatisticsCollectionStatistics、"
"<literal>SecondLevelCacheStatisticsQueryStatistics, "
"<literal>getEntityNames(), getCollectionRoleNames()getSecondLevelCacheRegionNames()."
msgstr ""
"如果你想得到所有实体、集合、查询和缓存区的数据,你可以通过以下方法获得实体、"
"集合、查询和缓存区列表:<literal>getQueries()、"
"<literal>getEntityNames()、getCollectionRoleNames()getSecondLevelCacheRegionNames()。"

#~ msgid "or even:"
#~ msgstr "甚至:"

#~ msgid ""
#~ "Now the following code will actually load both the customer <emphasis>and "
#~ "their orders</emphasis>:"
#~ msgstr "下面的代码将实际上加载客户<emphasis>以及订单:"

#~ msgid "yes"
#~ msgstr "yes"

#~ msgid ""
#~ "The <literal><cache> element of a class or collection "
#~ "mapping has the following form:"
#~ msgstr ""
#~ "类或者集合映射的“<literal><cache> 元素”可以有下列形式:"

#~ msgid ""
#~ "The <literal>usage attribute specifies a cache "
#~ "concurrency strategy</emphasis>."
#~ msgstr ""
#~ "这里的 <literal>usage 属性指明了缓存并发策略(cache "
#~ "concurrency strategy)</emphasis>。"

#~ msgid "read-only"
#~ msgstr "read-only"

#~ msgid "read-write"
#~ msgstr "read-write"

#~ msgid "transactional"
#~ msgstr "transactional"

#~ msgid ""
#~ "This setting creates two new cache regions: one holding cached query "
#~ "result sets (<literal>org.hibernate.cache.StandardQueryCache), "
#~ "the other holding timestamps of the most recent updates to queryable "
#~ "tables (<literal>org.hibernate.cache.UpdateTimestampsCache). "
#~ "Note that the query cache does not cache the state of the actual entities "
#~ "in the result set; it caches only identifier values and results of value "
#~ "type. The query cache should always be used in conjunction with the "
#~ "second-level cache."
#~ msgstr ""
#~ "该设置将会创建两个缓存区域 — 一个用于保存查询结果集(<literal>org."
#~ "hibernate.cache.StandardQueryCache</literal>); 另一个则用于保存最近查询"
#~ "的一系列表的时间戳(<literal>org.hibernate.cache.UpdateTimestampsCache"
#~ msgstr ""
#~ "<![CDATA["

#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<![CDATA["

Other Hibernate examples (source code examples)

Here is a short list of links related to this Hibernate performance.po source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.