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

📄 transactions.po

📁 hibernate-distribution-3.3.1.GA-dist.zip源码
💻 PO
📖 第 1 页 / 共 5 页
字号:
#. Tag: para#: transactions.xml:573#, fuzzy, no-c-formatmsgid """Hibernate wraps <literal>SQLException</literal>s thrown while interacting ""with the database in a <literal>JDBCException</literal>. In fact, Hibernate ""will attempt to convert the exception into a more meaningful subclass of ""<literal>JDBCException</literal>. The underlying <literal>SQLException</""literal> is always available via <literal>JDBCException.getCause()</""literal>. Hibernate converts the <literal>SQLException</literal> into an ""appropriate <literal>JDBCException</literal> subclass using the ""<literal>SQLExceptionConverter</literal> attached to the ""<literal>SessionFactory</literal>. By default, the ""<literal>SQLExceptionConverter</literal> is defined by the configured ""dialect; however, it is also possible to plug in a custom implementation ""(see the javadocs for the <literal>SQLExceptionConverterFactory</literal> ""class for details). The standard <literal>JDBCException</literal> subtypes ""are:"msgstr """在和数据库进行交互时,Hibernate把捕获的<literal>SQLException</literal>封装为""Hibernate的 <literal>JDBCException</literal>。事实上,Hibernate尝试把异常转换""为更有实际含义 的<literal>JDBCException</literal>异常的子类。底层的""<literal>SQLException</literal>可以 通过<literal>JDBCException.getCause()</""literal>来得到。Hibernate通过使用关联到 <literal>SessionFactory</literal>上的""<literal>SQLExceptionConverter</literal>来 把<literal>SQLException</literal>""转换为一个对应的<literal>JDBCException</literal> 异常的子类。默认情况下,""<literal>SQLExceptionConverter</literal>可以通过配置dialect 选项指定;此外,""也可以使用用户自定义的实现类(参考javadocs ""<literal>SQLExceptionConverterFactory</literal>类来了解详情)。标准的 ""<literal>JDBCException</literal>子类型是:"#. Tag: para#: transactions.xml:589#, no-c-formatmsgid """<literal>JDBCConnectionException</literal> - indicates an error with the ""underlying JDBC communication."msgstr """<literal>JDBCConnectionException</literal> - 指明底层的JDBC通讯出现错误"#. Tag: para#: transactions.xml:595#, no-c-formatmsgid """<literal>SQLGrammarException</literal> - indicates a grammar or syntax ""problem with the issued SQL."msgstr """<literal>SQLGrammarException</literal> - 指明发送的SQL语句的语法或者格式错误"#. Tag: para#: transactions.xml:601#, no-c-formatmsgid """<literal>ConstraintViolationException</literal> - indicates some form of ""integrity constraint violation."msgstr """<literal>ConstraintViolationException</literal> - 指明某种类型的约束违例错误"#. Tag: para#: transactions.xml:607#, no-c-formatmsgid """<literal>LockAcquisitionException</literal> - indicates an error acquiring a ""lock level necessary to perform the requested operation."msgstr """<literal>LockAcquisitionException</literal> - 指明了在执行请求操作时,获取 所""需的锁级别时出现的错误。"#. Tag: para#: transactions.xml:613#, no-c-formatmsgid """<literal>GenericJDBCException</literal> - a generic exception which did not ""fall into any of the other categories."msgstr "<literal>GenericJDBCException</literal> - 不属于任何其他种类的原生异常"#. Tag: title#: transactions.xml:623#, no-c-formatmsgid "Transaction timeout"msgstr "事务超时"#. Tag: para#: transactions.xml:625#, fuzzy, no-c-formatmsgid """One extremely important feature provided by a managed environment like EJB ""that is never provided for non-managed code is transaction timeout. ""Transaction timeouts ensure that no misbehaving transaction can indefinitely ""tie up resources while returning no response to the user. Outside a managed ""(JTA) environment, Hibernate cannot fully provide this functionality. ""However, Hibernate can at least control data access operations, ensuring ""that database level deadlocks and queries with huge result sets are limited ""by a defined timeout. In a managed environment, Hibernate can delegate ""transaction timeout to JTA. This functionality is abstracted by the ""Hibernate <literal>Transaction</literal> object."msgstr """EJB这样的托管环境有一项极为重要的特性,而它从未在非托管环境中提供过,那就是事""务超时。在出现错误的事务行为的时候,超时可以确保不会无限挂起资源、对用户没有""交代。在托管(JTA)环境之外,Hibernate无法完全提供这一功能。但是,Hiberante至少""可以控制数据访问,确保数据库级别的死锁,和返回巨大结果集的查询被限定在一个规""定的时间内。在托管环境中,Hibernate会把事务超时转交给JTA。这一功能通过""Hibernate <literal>Transaction</literal>对象进行抽象。"#. Tag: programlisting#: transactions.xml:638#, no-c-formatmsgid """<![CDATA[\n""Session sess = factory.openSession();\n""try {\n""    //set transaction timeout to 3 seconds\n""    sess.getTransaction().setTimeout(3);\n""    sess.getTransaction().begin();\n""\n""    // do some work\n""    ...\n""\n""    sess.getTransaction().commit()\n""}\n""catch (RuntimeException e) {\n""    sess.getTransaction().rollback();\n""    throw e; // or display error message\n""}\n""finally {\n""    sess.close();\n""}]]>"msgstr ""#. Tag: para#: transactions.xml:640#, no-c-formatmsgid """Note that <literal>setTimeout()</literal> may not be called in a CMT bean, ""where transaction timeouts must be defined declaratively."msgstr """注意<literal>setTimeout()</literal>不应该在CMT bean中调用,此时事务超时值应该""是被声明式定义的。"#. Tag: title#: transactions.xml:650#, no-c-formatmsgid "Optimistic concurrency control"msgstr "乐观并发控制(Optimistic concurrency control)"#. Tag: para#: transactions.xml:652#, no-c-formatmsgid """The only approach that is consistent with high concurrency and high ""scalability is optimistic concurrency control with versioning. Version ""checking uses version numbers, or timestamps, to detect conflicting updates ""(and to prevent lost updates). Hibernate provides for three possible ""approaches to writing application code that uses optimistic concurrency. The ""use cases we show are in the context of long conversations, but version ""checking also has the benefit of preventing lost updates in single database ""transactions."msgstr """唯一能够同时保持高并发和高可伸缩性的方法就是使用带版本化的乐观并发控制。版本""检查使用版本号、 或者时间戳来检测更新冲突(并且防止更新丢失)。Hibernate为使""用乐观并发控制的代码提供了三种可 能的方法,应用程序在编写这些代码时,可以采用""它们。我们已经在前面应用程序对话那部分展示了 乐观并发控制的应用场景,此外,在""单个数据库事务范围内,版本检查也提供了防止更新丢失的好处。"#. Tag: title#: transactions.xml:663#, no-c-formatmsgid "Application version checking"msgstr "应用程序级别的版本检查(Application version checking)"#. Tag: para#: transactions.xml:665#, no-c-formatmsgid """In an implementation without much help from Hibernate, each interaction with ""the database occurs in a new <literal>Session</literal> and the developer is ""responsible for reloading all persistent instances from the database before ""manipulating them. This approach forces the application to carry out its own ""version checking to ensure conversation transaction isolation. This approach ""is the least efficient in terms of database access. It is the approach most ""similar to entity EJBs."msgstr """未能充分利用Hibernate功能的实现代码中,每次和数据库交互都需要一个新的 ""<literal>Session</literal>,而且开发人员必须在显示数据之前从数据库中重 新载入""所有的持久化对象实例。这种方式迫使应用程序自己实现版本检查来确保 对话事务的隔""离,从数据访问的角度来说是最低效的。这种使用方式和 entity EJB最相似。"#. Tag: programlisting#: transactions.xml:674#, no-c-formatmsgid """<![CDATA[// foo is an instance loaded by a previous Session\n""session = factory.openSession();\n""Transaction t = session.beginTransaction();\n""\n""int oldVersion = foo.getVersion();\n""session.load( foo, foo.getKey() ); // load the current state\n""if ( oldVersion != foo.getVersion() ) throw new StaleObjectStateException""();\n""foo.setProperty(\"bar\");\n""\n""t.commit();\n""session.close();]]>"msgstr ""#. Tag: para#: transactions.xml:676#, no-c-formatmsgid """The <literal>version</literal> property is mapped using <literal>&lt;""version&gt;</literal>, and Hibernate will automatically increment it during ""flush if the entity is dirty."msgstr """<literal>version</literal> 属性使用 <literal>&lt;version&gt;</literal>来映""射,如果对象 是脏数据,在同步的时候,Hibernate会自动增加版本号。"#. Tag: para#: transactions.xml:682#, no-c-formatmsgid """Of course, if you are operating in a low-data-concurrency environment and ""don't require version checking, you may use this approach and just skip the ""version check. In that case, <emphasis>last commit wins</emphasis> will be ""the default strategy for your long conversations. Keep in mind that this ""might confuse the users of the application, as they might experience lost ""updates without error messages or a chance to merge conflicting changes."msgstr """当然,如果你的应用是在一个低数据并发环境下,并不需要版本检查的话,你照样可以""使用 这种方式,只不过跳过版本检查就是了。在这种情况下,<emphasis>最晚提交生效""</emphasis> (<emphasis>last commit wins</emphasis>)就是你的长对话的默认处理""策略。 请记住这种策略可能会让应用软件的用户感到困惑,因为他们有可能会碰上更新""丢失掉却没 有出错信息,或者需要合并更改冲突的情况。"#. Tag: para#: transactions.xml:691#, fuzzy, no-c-formatmsgid """Clearly, manual version checking is only feasible in very trivial ""circumstances and not practical for most applications. Often not only single ""instances, but complete graphs of modified objects have to be checked. ""Hibernate offers automatic version checking with either an extended ""<literal>Session</literal> or detached instances as the design paradigm."msgstr """很明显,手工进行版本检查只适合于某些软件规模非常小的应用场景,对于大多数软件""应用场景 来说并不现实。通常情况下,不仅是单个对象实例需要进行版本检查,整个被""修改过的关 联对象图也都需要进行版本检查。作为标准设计范例,Hibernate使用扩展""周期的 <literal>Session</literal>的方式,或者脱管对象实例的方式来提供自动版本""检查。"#. Tag: title#: transactions.xml:702#, no-c-formatmsgid "Extended session and automatic versioning"msgstr "扩展周期的session和自动版本化"#. Tag: para#: transactions.xml:704#, no-c-formatmsgid """A single <literal>Session</literal> instance and its persistent instances ""are used for the whole conversation, known as <emphasis>session-per-""conversation</emphasis>. Hibernate checks instance versions at flush time, ""throwing an exception if concurrent modification is detected. It's up to the ""developer to catch and handle this exception (common options are the ""opportunity for the user to merge changes or to restart the business ""conversation with non-stale data)."msgstr """单个 <literal>Session</literal>实例和它所关

⌨️ 快捷键说明

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