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

📄 batch.po

📁 hibernate-distribution-3.3.1.GA-dist.zip源码
💻 PO
📖 第 1 页 / 共 2 页
字号:
msgid ""msgstr """Project-Id-Version: PACKAGE VERSION\n""Report-Msgid-Bugs-To: http://bugs.kde.org\n""POT-Creation-Date: 2008-08-14 15:28+0000\n""PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n""Last-Translator: FULL NAME <EMAIL@ADDRESS>\n""Language-Team: LANGUAGE <LL@li.org>\n""MIME-Version: 1.0\n""Content-Type: text/plain; charset=UTF-8\n""Content-Transfer-Encoding: 8bit\n"#. Tag: title#: batch.xml:29#, no-c-formatmsgid "Batch processing"msgstr "批量处理(Batch processing)"#. Tag: para#: batch.xml:31#, no-c-formatmsgid """A naive approach to inserting 100 000 rows in the database using Hibernate ""might look like this:"msgstr """使用Hibernate将 100 000 条记录插入到数据库的一个很自然的做法可能是这样的"#. Tag: programlisting#: batch.xml:36#, no-c-formatmsgid """<![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 ""#. Tag: para#: batch.xml:38#, no-c-formatmsgid """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 """这段程序大概运行到 50 000 条记录左右会失败并抛出 <literal>内存溢出异常""(OutOfMemoryException)</literal> 。 这是因为 Hibernate 把所有新插入的 ""<literal>客户(Customer)</literal>实例在 session级别的缓存区进行了缓存的缘""故。"#. Tag: para#: batch.xml:44#, no-c-formatmsgid """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 """我们会在本章告诉你如何避免此类问题。首先,如果你要执行批量处理并且想要达到一""个理想的性能, 那么使用JDBC的批量(batching)功能是至关重要。将JDBC的批量抓取""数量(batch size)参数设置到一个合适值 (比如,10-50之间):"#. Tag: programlisting#: batch.xml:51#, no-c-formatmsgid "<![CDATA[hibernate.jdbc.batch_size 20]]>"msgstr ""#. Tag: para#: batch.xml:53#, no-c-formatmsgid """Note that Hibernate disables insert batching at the JDBC level transparently ""if you use an <literal>identiy</literal> identifier generator."msgstr """注意,假若你使用了<literal>identiy</literal>标识符生成器,Hibernate在JDBC级别透""明的关闭插入语句的批量执行。"#. Tag: para#: batch.xml:58#, no-c-formatmsgid """You also might like to do this kind of work in a process where interaction ""with the second-level cache is completely disabled:"msgstr "你也可能想在执行批量处理时关闭二级缓存:"#. Tag: programlisting#: batch.xml:63#, no-c-formatmsgid "<![CDATA[hibernate.cache.use_second_level_cache false]]>"msgstr ""#. Tag: para#: batch.xml:65#, no-c-formatmsgid """However, this is not absolutely necessary, since we can explicitly set the ""<literal>CacheMode</literal> to disable interaction with the second-level ""cache."msgstr """但是,这不是绝对必须的,因为我们可以显式设置<literal>CacheMode</literal>来关""闭与二级缓存的交互。"#. Tag: title#: batch.xml:71#, no-c-formatmsgid "Batch inserts"msgstr "批量插入(Batch inserts)"#. Tag: para#: batch.xml:73#, no-c-formatmsgid """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 """如果要将很多对象持久化,你必须通过经常的调用 <literal>flush()</literal> 以及""稍后调用 <literal>clear()</literal> 来控制第一级缓存的大小。"#. Tag: programlisting#: batch.xml:79#, no-c-formatmsgid """<![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 ""#. Tag: title#: batch.xml:84#, no-c-formatmsgid "Batch updates"msgstr "批量更新(Batch updates)"#. Tag: para#: batch.xml:86#, no-c-formatmsgid """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 """此方法同样适用于检索和更新数据。此外,在进行会返回很多行数据的查询时, 你需要""使用 <literal>scroll()</literal> 方法以便充分利用服务器端游标所带来的好处。"#. Tag: programlisting#: batch.xml:92#, no-c-formatmsgid """<![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 ""#. Tag: title#: batch.xml:97#, no-c-formatmsgid "The StatelessSession interface"msgstr "StatelessSession (无状态session)接口"#. Tag: para#: batch.xml:98#, no-c-formatmsgid """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 """作为选择,Hibernate提供了基于命令的API,可以用detached object的形式把数据以流""的方法加入到数据库,或从数据库输出。<literal>StatelessSession</literal>没有持""久化上下文,也不提供多少高层的生命周期语义。特别是,无状态session不实现第一级""cache,也不和第二级缓存,或者查询缓存交互。它不实现事务化写,也不实现脏数据检""查。用stateless session进行的操作甚至不级联到关联实例。stateless session忽略""集合类(Collections)。通过stateless session进行的操作不触发Hibernate的事件模型""和拦截器。无状态session对数据的混淆现象免疫,因为它没有第一级缓存。无状态""session是低层的抽象,和低层JDBC相当接近。"#. Tag: programlisting#: batch.xml:113#, no-c-formatmsgid """<![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 ""#. Tag: para#: batch.xml:115#, no-c-formatmsgid """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 """注意在上面的例子中,查询返回的<literal>Customer</literal>实例立即被脱管""(detach)。它们与任何持久化上下文都没有关系。"#. Tag: para#: batch.xml:121#, no-c-formatmsgid """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 """<literal>StatelessSession</literal> 接口定义的<literal>insert(), update()</""literal> 和 <literal>delete()</literal>操作是直接的数据库行级别操作,其结果是""立刻执行一条<literal>INSERT, UPDATE</literal> 或 <literal>DELETE</literal> 语""句。因此,它们的语义和<literal>Session</literal> 接口定义的<literal>save(), ""saveOrUpdate()</literal> 和<literal>delete()</literal> 操作有很大的不同。"#. Tag: title#: batch.xml:134#, no-c-formatmsgid "DML-style operations"msgstr "DML(数据操作语言)风格的操作(DML-style operations)"#. Tag: para#: batch.xml:136#, fuzzy, no-c-formatmsgid """As already discussed, automatic and transparent object/relational mapping is ""concerned with the management of object state. This implies that the object ""state is available in memory, hence manipulating (using the SQL ""<literal>Data Manipulation Language</literal> (DML) statements: ""<literal>INSERT</literal>, <literal>UPDATE</literal>, <literal>DELETE</""literal>) data directly in the database will not affect in-memory state. ""However, Hibernate provides methods for bulk SQL-style DML statement ""execution which are performed through the Hibernate Query Language (<link ""linkend=\"queryhql\">HQL</link>)."msgstr """hence manipulating (using the SQL <literal>Data Manipulation Language</""literal> (DML) statements: <literal>INSERT</literal>, <literal>UPDATE</""literal>, <literal>DELETE</literal>) data directly in the database will not ""affect in-memory state. However, Hibernate provides methods for bulk SQL-""style DML statement execution which are performed through the Hibernate ""Query Language (<xref linkend=\"queryhql\">HQL</xref>). 就像已经讨论的那样,""自动和透明的 对象/关系 映射(object/relational mapping)关注于管理对象的状""态。 这就意味着对象的状态存在于内存,因此直接操作 (使用 SQL <literal>Data ""Manipulation Language</literal>(DML,数据操作语言)语句 :<literal>INSERT</""literal> ,<literal>UPDATE</literal> 和 <literal>DELETE</literal>) 数据库中的""数据将不会影响内存中的对象状态和对象数据。 不过,Hibernate提供通过Hibernate查""询语言(<xref linkend=\"queryhql\">HQL</xref>)来执行大批 量SQL风格的DML语句""的方法。"

⌨️ 快捷键说明

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