📄 batch.po
字号:
#, fuzzymsgid ""msgstr """PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n""Last-Translator: FULL NAME <EMAIL@ADDRESS>\n""Content-Type: text/plain; charset=utf-8\n"#: index.docbook:5msgid "Batch processing"msgstr "Procesamiento por lotes"#: index.docbook:7msgid """A naive approach to inserting 100 000 rows in the database using Hibernate ""might look like this:"msgstr """Un enfoque ingenuo para insertar 100.000 filas en la base de datos usando ""Hibernate podría verse así:"#: index.docbook:12msgid """<![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();]]>"#: index.docbook:14msgid """This would fall over with an <literal>OutOfMemoryException</literal> ""somewhere around the 50 000th row. That's because Hibernate caches all the ""newly inserted <literal>Customer</literal> instances in the session-level ""cache."msgstr """Esto podría caer sobre una <literal>OutOfMemoryException</literal> en algún ""sitio cerca de la fila 50.000. Esto es porque Hibernate tiene en caché todas ""las instancias de <literal>Customer</literal> recién instanciadas en el ""caché de nivel de sesión."#: index.docbook:20msgid """In this chapter we'll show you how to avoid this problem. First, however, if ""you are doing batch processing, it is absolutely critical that you enable ""the use of JDBC batching, if you intend to achieve reasonable performance. ""Set the JDBC batch size to a reasonable number (say, 10-50):"msgstr """En este capítulo te mostraremos cómo evitar este problema. Primero, sin ""embargo, si estás haciendo procesamiento por lotes (batch processing), es ""absolutamente crítico que habilites el uso de loteo JDBC, si pretendes ""lograr un rendimiento razonable. Establece el tamaño de lote JDBC a un ""número razonable (digamos 10-50):"#: index.docbook:27msgid "<![CDATA[hibernate.jdbc.batch_size 20]]>"msgstr "<![CDATA[hibernate.jdbc.batch_size 20]]>"#: index.docbook:29msgid """Note that Hibernate disables insert batching at the JDBC level transparently ""if you use an <literal>identiy</literal> identifier generator."msgstr """UNTRANSLATED! Note that Hibernate disables insert batching at the JDBC level ""transparently if you use an <literal>identiy</literal> identifier generator."#: index.docbook:34msgid """You also might like to do this kind of work in a process where interaction ""with the second-level cache is completely disabled:"msgstr """Podrías además querer hacer este tipo de trabajo en un proceso donde la ""interacción con el caché de segundo nivel esté completamente deshabilitado:"#: index.docbook:39msgid "<![CDATA[hibernate.cache.use_second_level_cache false]]>"msgstr "<![CDATA[hibernate.cache.use_second_level_cache false]]>"#: index.docbook:41msgid """However, this is not absolutely necessary, since we can explicitly set the ""<literal>CacheMode</literal> to disable interaction with the second-level ""cache."msgstr """UNTRANSLATED! However, this is not absolutely necessary, since we can ""explicitly set the <literal>CacheMode</literal> to disable interaction with ""the second-level cache."#: index.docbook:47msgid "Batch inserts"msgstr "Inserciones en lote"#: index.docbook:49msgid """When making new objects persistent, you must <literal>flush()</literal> and ""then <literal>clear()</literal> the session regularly, to control the size ""of the first-level cache."msgstr """Al hacer persistentes objetos nuevos, debes limpiar con <literal>flush()</""literal> y llamar a <literal>clear()</literal> en la sesión regularmente, ""para controlar el tamaño del caché de primer nivel."#: index.docbook:55msgid """<![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();]]>"#: index.docbook:60msgid "Batch updates"msgstr "Actualizaciones en lote"#: index.docbook:62msgid """For retrieving and updating data the same ideas apply. In addition, you need ""to use <literal>scroll()</literal> to take advantage of server-side cursors ""for queries that return many rows of data."msgstr """Para recuperar y actualizar datos se aplican las mismas ideas. ""Adicionalmente, necesitas usar <literal>scroll()</literal> para sacar ""ventaja de los cursores del lado del servidor en consultas que devuelvan ""muchas filas de datos."#: index.docbook:68msgid """<![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();]]>"#: index.docbook:73msgid "The StatelessSession interface"msgstr "UNTRANSLATED! The StatelessSession interface"#: index.docbook:74msgid """Alternatively, Hibernate provides a command-oriented API that may be used ""for streaming data to and from the database in the form of detached objects. ""A <literal>StatelessSession</literal> 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 do not ever cascade to associated instances. ""Collections are ignored by a stateless session. Operations performed via a ""stateless session bypass Hibernate's event model and interceptors. Stateless ""sessions are vulnerable to data aliasing effects, due to the lack of a first-""level cache. A stateless session is a lower-level abstraction, much closer ""to the underlying JDBC."msgstr """Alternatively, Hibernate provides a command-oriented API that may be used ""for streaming data to and from the database in the form of detached objects. ""A <literal>StatelessSession</literal> 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 do not ever cascade to associated instances. ""Collections are ignored by a stateless session. Operations performed via a ""stateless session bypass Hibernate's event model and interceptors. Stateless ""sessions are vulnerable to data aliasing effects, due to the lack of a first-""level cache. A stateless session is a lower-level abstraction, much closer ""to the underlying JDBC."#: index.docbook:89msgid """<![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();]]>"#: index.docbook:91msgid """Note that in this code example, the <literal>Customer</literal> instances ""returned by the query are immediately detached. They are never associated ""with any persistence context."msgstr """Note that in this code example, the <literal>Customer</literal> instances ""returned by the query are immediately detached. They are never associated ""with any persistence context."#: index.docbook:97msgid """The <literal>insert(), update()</literal> and <literal>delete()</literal> ""operations defined by the <literal>StatelessSession</literal> interface are ""considered to be direct database row-level operations, which result in ""immediate execution of a SQL <literal>INSERT, UPDATE</literal> or ""<literal>DELETE</literal> respectively. Thus, they have very different ""semantics to the <literal>save(), saveOrUpdate()</literal> and ""<literal>delete()</literal> operations defined by the <literal>Session</""literal> interface."msgstr """The <literal>insert(), update()</literal> and <literal>delete()</literal> ""operations defined by the <literal>StatelessSession</literal> interface are ""considered to be direct database row-level operations, which result in ""immediate execution of a SQL <literal>INSERT, UPDATE</literal> or ""<literal>DELETE</literal> respectively. Thus, they have very different ""semantics to the <literal>save(), saveOrUpdate()</literal> and ""<literal>delete()</literal> operations defined by the <literal>Session</""literal> interface."#: index.docbook:110msgid "DML-style operations"msgstr "update/delete en masa"#: index.docbook:112
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -