Hibernate example source code file (batch.po)
This example Hibernate source code file (batch.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 batch.po source code
# translation of Collection_Mapping.po to
# Xi Huang <xhuang@redhat.com>, 2006.
# Xi HUANG <xhuang@redhat.com>, 2007.
msgid ""
msgstr ""
"Project-Id-Version: Collection_Mapping\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2010-02-11T05:38:15\n"
"PO-Revision-Date: 2010-03-15 08:58+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
#, no-c-format
msgid "Batch processing"
msgstr "批é‡å¤„ç†ï¼ˆBatch processing)"
#. Tag: para
#, no-c-format
msgid "A naive approach to inserting 100,000 rows in the database using Hibernate might look like this:"
msgstr "使用 Hibernate å°† 100,000 æ¡è®°å½•æ’入到数æ®åº“的一个很天真的åšæ³•å¯èƒ½æ˜¯è¿™æ ·çš„:"
#. Tag: para
#, no-c-format
msgid "This would fall over with an <literal>OutOfMemoryException somewhere around the 50,000th row. That is because Hibernate caches all the newly inserted Customer instances in the session-level cache. In this chapter we will show you how to avoid this problem."
msgstr "这段程åºå¤§æ¦‚è¿è¡Œåˆ° 50,000 æ¡è®°å½•å·¦å³ä¼šå¤±è´¥å¹¶æŠ›å‡º<literal>内å˜æº¢å‡ºå¼‚常(OutOfMemoryException) ã€‚è¿™æ˜¯å› ä¸º Hibernate 把所有新æ’入的客户(Customer) 实例在 session 级别的缓å˜åŒºè¿›è¡Œäº†ç¼“å˜çš„缘故。 "
#. Tag: para
#, no-c-format
msgid "If you are undertaking batch processing you will need to enable the use of JDBC batching. This is absolutely essential if you want to achieve optimal performance. Set the JDBC batch size to a reasonable number (10-50, for example):"
msgstr "æˆ‘ä»¬ä¼šåœ¨æœ¬ç« å‘Šè¯‰ä½ å¦‚ä½•é¿å…æ¤ç±»é—®é¢˜ã€‚é¦–å…ˆï¼Œå¦‚æžœä½ è¦æ‰§è¡Œæ‰¹é‡å¤„ç†å¹¶ä¸”想è¦è¾¾åˆ°ä¸€ä¸ªç†æƒ³çš„性能,那么使用 JDBC 的批é‡ï¼ˆbatching)功能是至关é‡è¦ã€‚å°† JDBC 的批é‡æŠ“å–æ•°é‡ï¼ˆbatch size)å‚数设置到一个åˆé€‚值(比如,10 - 50 之间):"
#. Tag: para
#, no-c-format
msgid "Hibernate disables insert batching at the JDBC level transparently if you use an <literal>identity identifier generator."
msgstr "注æ„,å‡è‹¥ä½ 使用了 <literal>identiy æ ‡è¯†ç¬¦ç”Ÿæˆå™¨ï¼ŒHibernate 在 JDBC 级别é€æ˜Žçš„å…³é—æ’å…¥è¯å¥çš„批é‡æ‰§è¡Œã€‚ "
#. Tag: para
#, no-c-format
msgid "You can also do this kind of work in a process where interaction with the second-level cache is completely disabled:"
msgstr "ä½ ä¹Ÿå¯èƒ½æƒ³åœ¨æ‰§è¡Œæ‰¹é‡å¤„ç†æ—¶å®Œå…¨å…³é—二级缓å˜ï¼š"
#. Tag: para
#, no-c-format
msgid "However, this is not absolutely necessary, since we can explicitly set the <literal>CacheMode to disable interaction with the second-level cache."
msgstr "但是,这ä¸æ˜¯ç»å¯¹å¿…é¡»çš„ï¼Œå› ä¸ºæˆ‘ä»¬å¯ä»¥æ˜¾å¼è®¾ç½® <literal>CacheMode æ¥å…³é—与二级缓å˜çš„交互。"
#. Tag: title
#, no-c-format
msgid "Batch inserts"
msgstr "批é‡æ’入(Batch inserts)"
#. Tag: para
#, no-c-format
msgid "When making new objects persistent <literal>flush() and then clear() the session regularly in order to control the size of the first-level cache."
msgstr "如果è¦å°†å¾ˆå¤šå¯¹è±¡æŒä¹…åŒ–ï¼Œä½ å¿…é¡»é€šè¿‡ç»å¸¸çš„调用 <literal>flush() 以åŠç¨åŽè°ƒç”¨ clear() æ¥æŽ§åˆ¶ç¬¬ä¸€çº§ç¼“å˜çš„大å°ã€‚ "
#. Tag: title
#, no-c-format
msgid "Batch updates"
msgstr "批é‡æ›´æ–°ï¼ˆBatch updates)"
#. Tag: para
#, no-c-format
msgid "For retrieving and updating data, the same ideas apply. In addition, you need to use <literal>scroll() to take advantage of server-side cursors for queries that return many rows of data."
msgstr "æ¤æ–¹æ³•åŒæ ·é€‚用于检索和更新数æ®ã€‚æ¤å¤–,在进行会返回很多行数æ®çš„æŸ¥è¯¢æ—¶ï¼Œä½ éœ€è¦ä½¿ç”¨ <literal>scroll() 方法以便充分利用æœåŠ¡å™¨ç«¯æ¸¸æ ‡æ‰€å¸¦æ¥çš„好处。 "
#. Tag: title
#, no-c-format
msgid "The StatelessSession interface"
msgstr "StatelessSessionï¼ˆæ— çŠ¶æ€ session)接å£"
#. Tag: para
#, no-c-format
msgid "Alternatively, Hibernate provides a command-oriented API that can be used for streaming data to and from the database in the form of detached objects. A <literal>StatelessSession has no persistence context associated with it and does not provide many of the higher-level life cycle semantics. In particular, a stateless session does not implement a first-level cache nor interact with any second-level or query cache. It does not implement transactional write-behind or automatic dirty checking. Operations performed using a stateless session never cascade to associated instances. Collections are ignored by a stateless session. Operations performed via a stateless session bypass Hibernate's event model and interceptors. Due to the lack of a first-level cache, Stateless sessions are vulnerable to data aliasing effects. A stateless session is a lower-level abstraction that is much closer to the underlying JDBC."
msgstr "作为选择,Hibernate æ供了基于命令的 API,å¯ä»¥ç”¨ detached object çš„å½¢å¼æŠŠæ•°æ®ä»¥æµçš„æ–¹æ³•åŠ å…¥åˆ°æ•°æ®åº“,或从数æ®åº“输出。<literal>StatelessSession 没有æŒä¹…化上下文,也ä¸æ供多少高层的生命周期è¯ä¹‰ã€‚ç‰¹åˆ«æ˜¯ï¼Œæ— çŠ¶æ€ session ä¸å®žçŽ°ç¬¬ä¸€çº§ cache,也ä¸å’Œç¬¬äºŒçº§ç¼“å˜ï¼Œæˆ–者查询缓å˜äº¤äº’。它ä¸å®žçŽ°äº‹åŠ¡åŒ–写,也ä¸å®žçŽ°è„æ•°æ®æ£€æŸ¥ã€‚用 stateless session 进行的æ“作甚至ä¸çº§è”到关è”实例。stateless session 忽略集åˆç±»ï¼ˆCollections)。通过 stateless session 进行的æ“作ä¸è§¦å‘ Hibernate çš„äº‹ä»¶æ¨¡åž‹å’Œæ‹¦æˆªå™¨ã€‚æ— çŠ¶æ€ session 对数æ®çš„混淆现象å…ç–«ï¼Œå› ä¸ºå®ƒæ²¡æœ‰ç¬¬ä¸€çº§ç¼“å˜ã€‚æ— çŠ¶æ€ session 是低层的抽象,和低层 JDBC 相当接近。 "
#. Tag: para
#, no-c-format
msgid "In this code example, the <literal>Customer instances returned by the query are immediately detached. They are never associated with any persistence context."
msgstr "注æ„在上é¢çš„例åä¸ï¼ŒæŸ¥è¯¢è¿”回的 <literal>Customer 实例立å³è¢«è„±ç®¡ï¼ˆdetach)。它们与任何æŒä¹…化上下文都没有关系。 "
#. Tag: para
#, no-c-format
msgid "The <literal>insert(), update() and delete() operations defined by the StatelessSession interface are considered to be direct database row-level operations. They result in the immediate execution of a SQL INSERT, UPDATE or DELETE respectively. They have different semantics to the save(), saveOrUpdate() and delete() operations defined by the Session interface."
msgstr "<literal>StatelessSession 接å£å®šä¹‰çš„ insert(), update() å’Œ delete() æ“作是直接的数æ®åº“行级别æ“ä½œï¼Œå…¶ç»“æžœæ˜¯ç«‹åˆ»æ‰§è¡Œä¸€æ¡ INSERT, UPDATE 或 DELETE è¯å¥ã€‚å› æ¤ï¼Œå®ƒä»¬çš„è¯ä¹‰å’Œ Session 接å£å®šä¹‰çš„ save(), saveOrUpdate() å’Œdelete() æ“作有很大的ä¸åŒã€‚ "
#. Tag: title
#, no-c-format
msgid "DML-style operations"
msgstr "DML(数æ®æ“作è¯è¨€ï¼‰é£Žæ ¼çš„æ“作(DML-style operations)"
#. Tag: para
#, no-c-format
msgid "As already discussed, automatic and transparent object/relational mapping is concerned with the management of the object state. The object state is available in memory. This means that manipulating data directly in the database (using the SQL <literal>Data Manipulation Language (DML) the statements: INSERT , UPDATE , DELETE ) will not affect in-memory state. However, Hibernate provides methods for bulk SQL-style DML statement execution that is performed through the Hibernate Query Language ( HQL)."
msgstr "å°±åƒå·²ç»è®¨è®ºçš„é‚£æ ·ï¼Œè‡ªåŠ¨å’Œé€æ˜Žçš„对象/å…³ç³»æ˜ å°„ï¼ˆobject/relational mapping)关注于管ç†å¯¹è±¡çš„状æ€ã€‚这就æ„味ç€å¯¹è±¡çš„状æ€å˜åœ¨äºŽå†…å˜ï¼Œå› æ¤ç›´æŽ¥æ“作(使用 SQL <literal>Data Manipulation Language(DML,æ•°æ®æ“作è¯è¨€ï¼‰è¯å¥ :INSERT ,UPDATE å’Œ DELETE ) æ•°æ®åº“ä¸çš„æ•°æ®å°†ä¸ä¼šå½±å“内å˜ä¸çš„对象状æ€å’Œå¯¹è±¡æ•°æ®ã€‚ä¸è¿‡ï¼ŒHibernate æ供通过 Hibernate 查询è¯è¨€ï¼ˆ HQL)æ¥æ‰§è¡Œå¤§æ‰¹é‡ SQL é£Žæ ¼çš„ DML è¯å¥çš„方法。 "
#. Tag: para
#, no-c-format
msgid "The pseudo-syntax for <literal>UPDATE and DELETE statements is: ( UPDATE | DELETE ) FROM? EntityName (WHERE where_conditions)? ."
msgstr "<literal>UPDATE å’Œ DELETE è¯å¥çš„伪è¯æ³•ä¸ºï¼š( UPDATE | DELETE ) FROM? EntityName (WHERE where_conditions)? 。"
#. Tag: para
#, no-c-format
msgid "Some points to note:"
msgstr "è¦æ³¨æ„的事项:"
#. Tag: para
#, no-c-format
msgid "In the from-clause, the FROM keyword is optional"
msgstr "在 FROM åå¥ï¼ˆfrom-clause)ä¸ï¼ŒFROM 关键å—是å¯é€‰çš„"
#. Tag: para
#, no-c-format
msgid "There can only be a single entity named in the from-clause. It can, however, be aliased. If the entity name is aliased, then any property references must be qualified using that alias. If the entity name is not aliased, then it is illegal for any property references to be qualified."
msgstr "在 FROM åå¥ï¼ˆfrom-clause)ä¸åªèƒ½æœ‰ä¸€ä¸ªå®žä½“å,它å¯ä»¥æ˜¯åˆ«å。如果实体å是别åï¼Œé‚£ä¹ˆä»»ä½•è¢«å¼•ç”¨çš„å±žæ€§éƒ½å¿…é¡»åŠ ä¸Šæ¤åˆ«åçš„å‰ç¼€ï¼›å¦‚æžœä¸æ˜¯åˆ«å,那么任何有å‰ç¼€çš„属性引用都是éžæ³•çš„。 "
#. Tag: para
#, no-c-format
msgid "No <link linkend=\"queryhql-joins-forms\">joins, either implicit or explicit, can be specified in a bulk HQL query. Sub-queries can be used in the where-clause, where the subqueries themselves may contain joins."
msgstr "ä¸èƒ½åœ¨å¤§æ‰¹é‡ HQL è¯å¥ä¸ä½¿ç”¨ <link linkend=\"queryhql-joins-forms\">joins 连接(显å¼æˆ–者éšå¼çš„都ä¸è¡Œï¼‰ã€‚ä¸è¿‡åœ¨ WHERE åå¥ä¸å¯ä»¥ä½¿ç”¨å查询。å¯ä»¥åœ¨ where åå¥ä¸ä½¿ç”¨å查询,å查询本身å¯ä»¥åŒ…å« join。 "
#. Tag: para
#, no-c-format
msgid "The where-clause is also optional."
msgstr "整个 WHERE åå¥æ˜¯å¯é€‰çš„。"
#. Tag: para
#, no-c-format
msgid "As an example, to execute an HQL <literal>UPDATE, use the Query.executeUpdate() method. The method is named for those familiar with JDBC's PreparedStatement.executeUpdate() :"
msgstr "举个例å,使用 <literal>Query.executeUpdate() 方法执行一个 HQL UPDATE è¯å¥ï¼ˆæ–¹æ³•å‘½å是æ¥æºäºŽ JDBC çš„ PreparedStatement.executeUpdate() ): "
#. Tag: para
#, no-c-format
msgid "In keeping with the EJB3 specification, HQL <literal>UPDATE statements, by default, do not effect the version or the timestamp property values for the affected entities. However, you can force Hibernate to reset the version or timestamp property values through the use of a versioned update . This is achieved by adding the VERSIONED keyword after the UPDATE keyword."
msgstr "HQL <literal>UPDATE è¯å¥ï¼Œé»˜è®¤ä¸ä¼šå½±å“更新实体的 version 或 the timestamp 属性值。这和 EJB3 规范是一致的。但是,通过使用 versioned update ï¼Œä½ å¯ä»¥å¼ºåˆ¶ Hibernate æ£ç¡®çš„é‡ç½®version 或者 timestamp 属性值。这通过在 UPDATE 关键å—åŽé¢å¢žåŠ VERSIONED 关键å—æ¥å®žçŽ°çš„。 "
#. Tag: para
#, no-c-format
msgid "Custom version types, <literal>org.hibernate.usertype.UserVersionType, are not allowed in conjunction with a update versioned statement."
msgstr "注æ„,自定义的版本类型(<literal>org.hibernate.usertype.UserVersionType)ä¸å…许和 update versioned è¯å¥è”用。 "
#. Tag: para
#, no-c-format
msgid "To execute an HQL <literal>DELETE, use the same Query.executeUpdate() method:"
msgstr "执行一个 HQL <literal>DELETE,åŒæ ·ä½¿ç”¨ Query.executeUpdate() 方法:"
#. Tag: para
#, no-c-format
msgid "The <literal>int value returned by the Query.executeUpdate() method indicates the number of entities effected by the operation. This may or may not correlate to the number of rows effected in the database. An HQL bulk operation might result in multiple actual SQL statements being executed (for joined-subclass, for example). The returned number indicates the number of actual entities affected by the statement. Going back to the example of joined-subclass, a delete against one of the subclasses may actually result in deletes against not just the table to which that subclass is mapped, but also the \"root\" table and potentially joined-subclass tables further down the inheritance hierarchy."
msgstr "ç”± <literal>Query.executeUpdate() 方法返回的整型 值表明了å—æ¤æ“作影å“的记录数é‡ã€‚注æ„这个数值å¯èƒ½ä¸Žæ•°æ®åº“ä¸è¢«ï¼ˆæœ€åŽä¸€æ¡ SQL è¯å¥ï¼‰å½±å“了的“行â€æ•°æœ‰å…³ï¼Œä¹Ÿå¯èƒ½æ²¡æœ‰ã€‚ä¸€ä¸ªå¤§æ‰¹é‡ HQL æ“作å¯èƒ½å¯¼è‡´å¤šæ¡å®žé™…çš„SQLè¯å¥è¢«æ‰§è¡Œï¼Œä¸¾ä¸ªä¾‹å,对 joined-subclass æ˜ å°„æ–¹å¼çš„类进行的æ¤ç±»æ“作。这个返回值代表了实际被è¯å¥å½±å“了的记录数é‡ã€‚在那个 joined-subclass 的例åä¸ï¼Œ 对一个åç±»çš„åˆ é™¤å®žé™…ä¸Šå¯èƒ½ä¸ä»…ä»…ä¼šåˆ é™¤åç±»æ˜ å°„åˆ°çš„è¡¨è€Œä¸”ä¼šå½±å“â€œæ ¹â€è¡¨ï¼Œè¿˜æœ‰å¯èƒ½å½±å“与之有继承关系的 joined-subclass æ˜ å°„æ–¹å¼çš„å类的表。 "
#. Tag: para
#, no-c-format
msgid "The pseudo-syntax for <literal>INSERT statements is: INSERT INTO EntityName properties_list select_statement . Some points to note:"
msgstr "<literal>INSERT è¯å¥çš„伪ç 是:INSERT INTO EntityName properties_list select_statement 。è¦æ³¨æ„的是:"
#. Tag: para
#, no-c-format
msgid "Only the INSERT INTO ... SELECT ... form is supported; not the INSERT INTO ... VALUES ... form."
msgstr "åªæ”¯æŒ INSERT INTO ... SELECT ... å½¢å¼ï¼Œä¸æ”¯æŒ INSERT INTO ... VALUES ... å½¢å¼ã€‚"
#. Tag: para
#, no-c-format
msgid "The properties_list is analogous to the <literal>column specification in the SQL INSERT statement. For entities involved in mapped inheritance, only properties directly defined on that given class-level can be used in the properties_list. Superclass properties are not allowed and subclass properties do not make sense. In other words, INSERT statements are inherently non-polymorphic."
msgstr "properties_list å’Œ SQL <literal>INSERT è¯å¥ä¸çš„å—段定义(column speficiation) 类似。对å‚ä¸Žç»§æ‰¿æ ‘æ˜ å°„çš„å®žä½“è€Œè¨€ï¼Œåªæœ‰ç›´æŽ¥å®šä¹‰åœ¨ç»™å®šçš„类级别的属性æ‰èƒ½ç›´æŽ¥åœ¨ properties_list ä¸ä½¿ç”¨ã€‚超类的属性ä¸è¢«æ”¯æŒï¼›åç±»çš„å±žæ€§æ— æ„义。æ¢å¥è¯è¯´ï¼ŒINSERT 天生ä¸æ”¯æŒå¤šæ€æ€§ã€‚"
#. Tag: para
#, no-c-format
msgid "select_statement can be any valid HQL select query, with the caveat that the return types must match the types expected by the insert. Currently, this is checked during query compilation rather than allowing the check to relegate to the database. This might, however, cause problems between Hibernate <literal>Types which are equivalent as opposed to equal . This might cause issues with mismatches between a property defined as a org.hibernate.type.DateType and a property defined as a org.hibernate.type.TimestampType , even though the database might not make a distinction or might be able to handle the conversion."
msgstr "select_statement å¯ä»¥æ˜¯ä»»ä½•åˆæ³•çš„ HQL 选择查询,ä¸è¿‡è¦ä¿è¯è¿”回类型必须和è¦æ’入的类型完全匹é…。目å‰ï¼Œè¿™ä¸€æ£€æŸ¥æ˜¯åœ¨æŸ¥è¯¢ç¼–译的时候进行的,而ä¸æ˜¯æŠŠå®ƒäº¤ç»™æ•°æ®åº“。注æ„,在Hibernate<literal>Type 间如果åªæ˜¯ç‰ä»·ï¼ˆequivalent) 而éžç›¸ç‰ï¼ˆequal) ,会导致问题。定义为 org.hibernate.type.DateType å’Œ org.hibernate.type.TimestampType 的两个属性å¯èƒ½ä¼šäº§ç”Ÿç±»åž‹ä¸åŒ¹é…错误,虽然数æ®åº“级å¯èƒ½ä¸åŠ 区分或者å¯ä»¥å¤„ç†è¿™ç§è½¬æ¢ã€‚ "
#. Tag: para
#, no-c-format
msgid "For the id property, the insert statement gives you two options. You can either explicitly specify the id property in the properties_list, in which case its value is taken from the corresponding select expression, or omit it from the properties_list, in which case a generated value is used. This latter option is only available when using id generators that operate in the database; attempting to use this option with any \"in memory\" type generators will cause an exception during parsing. For the purposes of this discussion, in-database generators are considered to be <literal>org.hibernate.id.SequenceGenerator (and its subclasses) and any implementers of org.hibernate.id.PostInsertIdentifierGenerator . The most notable exception here is org.hibernate.id.TableHiLoGenerator , which cannot be used because it does not expose a selectable way to get its values."
msgstr "对 id 属性æ¥è¯´ï¼Œinsert è¯å¥ç»™ä½ ä¸¤ä¸ªé€‰æ‹©ã€‚ä½ å¯ä»¥æ˜Žç¡®åœ°åœ¨ properties_list 表ä¸æŒ‡å®š id å±žæ€§ï¼ˆè¿™æ ·å®ƒçš„å€¼æ˜¯ä»Žå¯¹åº”çš„ select 表达å¼ä¸èŽ·å¾—),或者在 properties_list ä¸çœç•¥å®ƒï¼ˆæ¤æ—¶ä½¿ç”¨ç”ŸæˆæŒ‡ï¼‰ã€‚åŽä¸€ç§é€‰æ‹©åªæœ‰å½“使用在数æ®åº“ä¸ç”Ÿæˆå€¼çš„ id 产生器时æ‰èƒ½ä½¿ç”¨ï¼›å¦‚果是“内å˜â€ä¸è®¡ç®—的类型生æˆå™¨ï¼Œåœ¨è§£æžæ—¶ä¼šæŠ›å‡ºä¸€ä¸ªå¼‚常。注æ„,为了说明这一问题,数æ®åº“产生值的生æˆå™¨æ˜¯ <literal>org.hibernate.id.SequenceGenerator(和它的å类),以åŠä»»ä½• org.hibernate.id.PostInsertIdentifierGenerator 接å£çš„实现。这儿最值得注æ„çš„æ„外是 org.hibernate.id.TableHiLoGenerator ,它ä¸èƒ½åœ¨æ¤ä½¿ç”¨ï¼Œå› 为它没有得到其值的途径。 "
#. Tag: para
#, no-c-format
msgid "For properties mapped as either <literal>version or timestamp , the insert statement gives you two options. You can either specify the property in the properties_list, in which case its value is taken from the corresponding select expressions, or omit it from the properties_list, in which case the seed value defined by the org.hibernate.type.VersionType is used."
msgstr "å¯¹æ˜ å°„ä¸º <literal>version 或 timestamp 的属性æ¥è¯´ï¼Œinsert è¯å¥ä¹Ÿç»™ä½ ä¸¤ä¸ªé€‰æ‹©ï¼Œä½ å¯ä»¥åœ¨ properties_list 表ä¸æŒ‡å®šï¼ˆæ¤æ—¶å…¶å€¼ä»Žå¯¹åº”çš„ select 表达å¼ä¸èŽ·å¾—),或者在 properties_list ä¸çœç•¥å®ƒï¼ˆæ¤æ—¶ï¼Œä½¿ç”¨åœ¨ org.hibernate.type.VersionType ä¸å®šä¹‰çš„ seed value(ç§å值) )。"
#. Tag: para
#, no-c-format
msgid "The following is an example of an HQL <literal>INSERT statement execution:"
msgstr "下é¢æ˜¯ä¸€ä¸ªæ‰§è¡Œ HQL <literal>INSERT è¯å¥çš„例å:"
#~ msgid ""
#~ "<![CDATA[Session session = sessionFactory.openSession();\n"
#~ "Transaction tx = session.beginTransaction();\n"
#~ "for ( int i=0; i<100000; i++ ) {\n"
#~ " Customer customer = new Customer(.....);\n"
#~ " session.save(customer);\n"
#~ "}\n"
#~ "tx.commit();\n"
#~ "session.close();]]>"
#~ msgstr ""
#~ "<![CDATA[Session session = sessionFactory.openSession();\n"
#~ "Transaction tx = session.beginTransaction();\n"
#~ "for ( int i=0; i<100000; i++ ) {\n"
#~ " Customer customer = new Customer(.....);\n"
#~ " session.save(customer);\n"
#~ "}\n"
#~ "tx.commit();\n"
#~ "session.close();]]>"
#~ msgid "<![CDATA[hibernate.jdbc.batch_size 20]]>"
#~ msgstr "<![CDATA[hibernate.jdbc.batch_size 20]]>"
#~ msgid "<![CDATA[hibernate.cache.use_second_level_cache false]]>"
#~ msgstr "<![CDATA[hibernate.cache.use_second_level_cache false]]>"
#~ msgid ""
#~ "<![CDATA[Session session = sessionFactory.openSession();\n"
#~ "Transaction tx = session.beginTransaction();\n"
#~ " \n"
#~ "for ( int i=0; i<100000; i++ ) {\n"
#~ " Customer customer = new Customer(.....);\n"
#~ " session.save(customer);\n"
#~ " if ( i % 20 == 0 ) { //20, same as the JDBC batch size\n"
#~ " //flush a batch of inserts and release memory:\n"
#~ " session.flush();\n"
#~ " session.clear();\n"
#~ " }\n"
#~ "}\n"
#~ " \n"
#~ "tx.commit();\n"
#~ "session.close();]]>"
#~ msgstr ""
#~ "<![CDATA[Session session = sessionFactory.openSession();\n"
#~ "Transaction tx = session.beginTransaction();\n"
#~ " \n"
#~ "for ( int i=0; i<100000; i++ ) {\n"
#~ " Customer customer = new Customer(.....);\n"
#~ " session.save(customer);\n"
#~ " if ( i % 20 == 0 ) { //20, same as the JDBC batch size\n"
#~ " //flush a batch of inserts and release memory:\n"
#~ " session.flush();\n"
#~ " session.clear();\n"
#~ " }\n"
#~ "}\n"
#~ " \n"
#~ "tx.commit();\n"
#~ "session.close();]]>"
#~ msgid ""
#~ "<![CDATA[Session session = sessionFactory.openSession();\n"
#~ "Transaction tx = session.beginTransaction();\n"
#~ " \n"
#~ "ScrollableResults customers = session.getNamedQuery(\"GetCustomers\")\n"
#~ " .setCacheMode(CacheMode.IGNORE)\n"
#~ " .scroll(ScrollMode.FORWARD_ONLY);\n"
#~ "int count=0;\n"
#~ "while ( customers.next() ) {\n"
#~ " Customer customer = (Customer) customers.get(0);\n"
#~ " customer.updateStuff(...);\n"
#~ " if ( ++count % 20 == 0 ) {\n"
#~ " //flush a batch of updates and release memory:\n"
#~ " session.flush();\n"
#~ " session.clear();\n"
#~ " }\n"
#~ "}\n"
#~ " \n"
#~ "tx.commit();\n"
#~ "session.close();]]>"
#~ msgstr ""
#~ "<![CDATA[Session session = sessionFactory.openSession();\n"
#~ "Transaction tx = session.beginTransaction();\n"
#~ " \n"
#~ "ScrollableResults customers = session.getNamedQuery(\"GetCustomers\")\n"
#~ " .setCacheMode(CacheMode.IGNORE)\n"
#~ " .scroll(ScrollMode.FORWARD_ONLY);\n"
#~ "int count=0;\n"
#~ "while ( customers.next() ) {\n"
#~ " Customer customer = (Customer) customers.get(0);\n"
#~ " customer.updateStuff(...);\n"
#~ " if ( ++count % 20 == 0 ) {\n"
#~ " //flush a batch of updates and release memory:\n"
#~ " session.flush();\n"
#~ " session.clear();\n"
#~ " }\n"
#~ "}\n"
#~ " \n"
#~ "tx.commit();\n"
#~ "session.close();]]>"
#~ msgid ""
#~ "<![CDATA[StatelessSession session = sessionFactory.openStatelessSession"
#~ "();\n"
#~ "Transaction tx = session.beginTransaction();\n"
#~ " \n"
#~ "ScrollableResults customers = session.getNamedQuery(\"GetCustomers\")\n"
#~ " .scroll(ScrollMode.FORWARD_ONLY);\n"
#~ "while ( customers.next() ) {\n"
#~ " Customer customer = (Customer) customers.get(0);\n"
#~ " customer.updateStuff(...);\n"
#~ " session.update(customer);\n"
#~ "}\n"
#~ " \n"
#~ "tx.commit();\n"
#~ "session.close();]]>"
#~ msgstr ""
#~ "<![CDATA[StatelessSession session = sessionFactory.openStatelessSession"
#~ "();\n"
#~ "Transaction tx = session.beginTransaction();\n"
#~ " \n"
#~ "ScrollableResults customers = session.getNamedQuery(\"GetCustomers\")\n"
#~ " .scroll(ScrollMode.FORWARD_ONLY);\n"
#~ "while ( customers.next() ) {\n"
#~ " Customer customer = (Customer) customers.get(0);\n"
#~ " customer.updateStuff(...);\n"
#~ " session.update(customer);\n"
#~ "}\n"
#~ " \n"
#~ "tx.commit();\n"
#~ "session.close();]]>"
#~ msgid ""
#~ "<![CDATA[Session session = sessionFactory.openSession();\n"
#~ "Transaction tx = session.beginTransaction();\n"
#~ "\n"
#~ "String hqlUpdate = \"update Customer c set c.name = :newName where c.name "
#~ "= :oldName\";\n"
#~ "// or String hqlUpdate = \"update Customer set name = :newName where name "
#~ "= :oldName\";\n"
#~ "int updatedEntities = s.createQuery( hqlUpdate )\n"
#~ " .setString( \"newName\", newName )\n"
#~ " .setString( \"oldName\", oldName )\n"
#~ " .executeUpdate();\n"
#~ "tx.commit();\n"
#~ "session.close();]]>"
#~ msgstr ""
#~ "<![CDATA[Session session = sessionFactory.openSession();\n"
#~ "Transaction tx = session.beginTransaction();\n"
#~ "\n"
#~ "String hqlUpdate = \"update Customer c set c.name = :newName where c.name "
#~ "= :oldName\";\n"
#~ "// or String hqlUpdate = \"update Customer set name = :newName where name "
#~ "= :oldName\";\n"
#~ "int updatedEntities = s.createQuery( hqlUpdate )\n"
#~ " .setString( \"newName\", newName )\n"
#~ " .setString( \"oldName\", oldName )\n"
#~ " .executeUpdate();\n"
#~ "tx.commit();\n"
#~ "session.close();]]>"
#~ msgid ""
#~ "<![CDATA[Session session = sessionFactory.openSession();\n"
#~ "Transaction tx = session.beginTransaction();\n"
#~ "String hqlVersionedUpdate = \"update versioned Customer set name = :"
#~ "newName where name = :oldName\";\n"
#~ "int updatedEntities = s.createQuery( hqlUpdate )\n"
#~ " .setString( \"newName\", newName )\n"
#~ " .setString( \"oldName\", oldName )\n"
#~ " .executeUpdate();\n"
#~ "tx.commit();\n"
#~ "session.close();]]>"
#~ msgstr ""
#~ "<![CDATA[Session session = sessionFactory.openSession();\n"
#~ "Transaction tx = session.beginTransaction();\n"
#~ "String hqlVersionedUpdate = \"update versioned Customer set name = :"
#~ "newName where name = :oldName\";\n"
#~ "int updatedEntities = s.createQuery( hqlUpdate )\n"
#~ " .setString( \"newName\", newName )\n"
#~ " .setString( \"oldName\", oldName )\n"
#~ " .executeUpdate();\n"
#~ "tx.commit();\n"
#~ "session.close();]]>"
#~ msgid ""
#~ "<![CDATA[Session session = sessionFactory.openSession();\n"
#~ "Transaction tx = session.beginTransaction();\n"
#~ "\n"
#~ "String hqlDelete = \"delete Customer c where c.name = :oldName\";\n"
#~ "// or String hqlDelete = \"delete Customer where name = :oldName\";\n"
#~ "int deletedEntities = s.createQuery( hqlDelete )\n"
#~ " .setString( \"oldName\", oldName )\n"
#~ " .executeUpdate();\n"
#~ "tx.commit();\n"
#~ "session.close();]]>"
#~ msgstr ""
#~ "<![CDATA[Session session = sessionFactory.openSession();\n"
#~ "Transaction tx = session.beginTransaction();\n"
#~ "\n"
#~ "String hqlDelete = \"delete Customer c where c.name = :oldName\";\n"
#~ "// or String hqlDelete = \"delete Customer where name = :oldName\";\n"
#~ "int deletedEntities = s.createQuery( hqlDelete )\n"
#~ " .setString( \"oldName\", oldName )\n"
#~ " .executeUpdate();\n"
#~ "tx.commit();\n"
#~ "session.close();]]>"
#~ msgid ""
#~ "<![CDATA[Session session = sessionFactory.openSession();\n"
#~ "Transaction tx = session.beginTransaction();\n"
#~ "\n"
#~ "String hqlInsert = \"insert into DelinquentAccount (id, name) select c."
#~ "id, c.name from Customer c where ...\";\n"
#~ "int createdEntities = s.createQuery( hqlInsert )\n"
#~ " .executeUpdate();\n"
#~ "tx.commit();\n"
#~ "session.close();]]>"
#~ msgstr ""
#~ "<![CDATA[Session session = sessionFactory.openSession();\n"
#~ "Transaction tx = session.beginTransaction();\n"
#~ "\n"
#~ "String hqlInsert = \"insert into DelinquentAccount (id, name) select c."
#~ "id, c.name from Customer c where ...\";\n"
#~ "int createdEntities = s.createQuery( hqlInsert )\n"
#~ " .executeUpdate();\n"
#~ "tx.commit();\n"
#~ "session.close();]]>"
Other Hibernate examples (source code examples)
Here is a short list of links related to this Hibernate batch.po source code file: