|
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.
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-writeã€nonstrict-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 QueryStatisticsã€EntityStatisticsCollectionStatisticsã€"
"<literal>SecondLevelCacheStatistics 和 QueryStatistics, "
"<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:
|