📄 transactions.po
字号:
"literal> or <literal>iterate()</literal>. You <emphasis>must</emphasis> ""release the underlying database cursor by calling <literal>ScrollableResults.""close()</literal> or <literal>Hibernate.close(Iterator)</literal> explicity ""from a <literal>finally</literal> block. (Of course, most applications can ""easily avoid using <literal>scroll()</literal> or <literal>iterate()</""literal> at all from the JTA or CMT code.)"msgstr """A operação <literal>getCurrentSession()</literal> tem um aspecto negativo em ""um ambiente JTA. Há uma advertência para o uso do método liberado de conexão ""<literal>after_statement</literal>, o qual é usado então por padrão. Devido ""a uma limitação simples da especificação JTA, não é possível para o ""Hibernate automaticamente limpar quaisquer instâncias ""<literal>ScrollableResults</literal> ou <literal>Iterator</literal> abertas ""retornadas pelo <literal>scroll()</literal> ou <literal>iterate()</literal>. ""Você <emphasis>deve</emphasis> liberar o cursor subjacente da base de dados ""chamando <literal>ScrollableResults.close()</literal> ou <literal>Hibernate.""close(Iterator)</literal> explicitamente de um bloco <literal>finally</""literal>. (Claro que a maioria de aplicações podem facilmente evitar o uso ""do <literal>scroll()</literal> ou do <literal>iterate()</literal> em todo ""código provindo do JTA ou do CMT.)"#. Tag: title#: transactions.xml:524#, no-c-formatmsgid "Exception handling"msgstr "Tratamento de Exceção"#. Tag: para#: transactions.xml:526#, no-c-formatmsgid """If the <literal>Session</literal> throws an exception (including any ""<literal>SQLException</literal>), you should immediately rollback the ""database transaction, call <literal>Session.close()</literal> and discard ""the <literal>Session</literal> instance. Certain methods of ""<literal>Session</literal> will <emphasis>not</emphasis> leave the session ""in a consistent state. No exception thrown by Hibernate can be treated as ""recoverable. Ensure that the <literal>Session</literal> will be closed by ""calling <literal>close()</literal> in a <literal>finally</literal> block."msgstr """Se a <literal>Session</literal> levantar uma exceção (incluindo qualquer ""<literal>SQLException</literal>), você deve imediatamente dar um rollback na ""transação do banco, chamando <literal>Session.close()</literal> e ""descartando a instância da <literal>Session</literal>. Certos métodos da ""<literal>Session</literal><literal>não</literal> deixarão a sessão em um ""estado inconsistente. Nenhuma exceção lançada pelo Hibernate pode ser ""recuperada. Certifique-se que a <literal>Session</literal> será fechada ""chamando <literal>close()</literal> no bloco <literal>finally</literal>."#. Tag: para#: transactions.xml:537#, no-c-formatmsgid """The <literal>HibernateException</literal>, which wraps most of the errors ""that can occur in a Hibernate persistence layer, is an unchecked exception ""(it wasn't in older versions of Hibernate). In our opinion, we shouldn't ""force the application developer to catch an unrecoverable exception at a low ""layer. In most systems, unchecked and fatal exceptions are handled in one of ""the first frames of the method call stack (i.e. in higher layers) and an ""error message is presented to the application user (or some other ""appropriate action is taken). Note that Hibernate might also throw other ""unchecked exceptions which are not a <literal>HibernateException</literal>. ""These are, again, not recoverable and appropriate action should be taken."msgstr """A exceção <literal>HibernateException</literal>, a qual envolve a maioria ""dos erros que podem ocorrer em uma camada de persistência do Hibernate, é ""uma exceção unchecked ( não estava em umas versões mais antigas de ""Hibernate). Em nossa opinião, nós não devemos forçar o desenvolvedor a ""tratar uma exceção irrecuperável em uma camada mais baixa. Na maioria dos ""sistemas, as exceções unchecked e fatais são tratadas em um dos primeiros ""frames da pilha da chamada do método (isto é, em umas camadas mais elevadas) ""e uma mensagem de erro é apresentada ao usuário da aplicação (ou a alguma ""outra ação apropriada é feita). Note que Hibernate pode também lançar outras ""exceções unchecked que não são um <literal>HibernateException</literal>. ""Estas, também são, irrecuperáveis e uma ação apropriada deve ser tomada."#. Tag: para#: transactions.xml:549#, 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 eexception into a more meningful 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 """O Hibernate envolve <literal>SQLException</literal>s lançadas ao interagir ""com a base de dados em um <literal>JDBCException</literal>. Na realidade, o ""Hibernate tentará converter a exceção em em uma sub classe mais ""significativa da <literal>JDBCException</literal>. A <literal>SQLException</""literal> subjacente está sempre disponível através de <literal>JDBCException.""getCause()</literal>. O Hibernate converte a <literal>SQLException</literal> ""em uma sub classe <literal>JDBCException</literal> apropriada usando ""<literal>SQLExceptionConverter</literal> associado ao SessionFactory. Por ""padrão, o <literal>SQLExceptionConverter</literal> é definido pelo dialeto ""configurado; entretanto, é também possível conectar em uma implementação ""customizada (veja o javadoc para mais detalhes da classe ""<literal>SQLExceptionConverterFactory</literal>). Os subtipos padrão de ""<literal>JDBCException</literal> são:"#. Tag: para#: transactions.xml:565#, no-c-formatmsgid """<literal>JDBCConnectionException</literal> - indicates an error with the ""underlying JDBC communication."msgstr """<literal>JDBCConnectionException</literal> - indica um erro com a ""comunicação subjacente de JDBC."#. Tag: para#: transactions.xml:571#, no-c-formatmsgid """<literal>SQLGrammarException</literal> - indicates a grammar or syntax ""problem with the issued SQL."msgstr """<literal>SQLGrammarException</literal> - indica um problema da gramática ou ""da sintaxe com o SQL emitido."#. Tag: para#: transactions.xml:577#, no-c-formatmsgid """<literal>ConstraintViolationException</literal> - indicates some form of ""integrity constraint violation."msgstr """<literal>ConstraintViolationException</literal> - indica algum forma de ""violação de confinamento de integridade."#. Tag: para#: transactions.xml:583#, no-c-formatmsgid """<literal>LockAcquisitionException</literal> - indicates an error acquiring a ""lock level necessary to perform the requested operation."msgstr """<literal>LockAcquisitionException</literal> - indica um erro ao adquirir um ""nível de bloqueio necessário para realizar a operação de requisição."#. Tag: para#: transactions.xml:589#, no-c-formatmsgid """<literal>GenericJDBCException</literal> - a generic exception which did not ""fall into any of the other categories."msgstr """<literal>GenericJDBCException</literal> - uma exceção genérica que não cai ""em algumas das outras categorias."#. Tag: title#: transactions.xml:599#, no-c-formatmsgid "Transaction timeout"msgstr "Timeout de Transação"#. Tag: para#: transactions.xml:601#, 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 functioanlity is abstracted by the ""Hibernate <literal>Transaction</literal> object."msgstr """Uma característica extremamente importante fornecida por um ambiente ""gerenciado como EJB e que nunca é fornecido pelo código não gerenciado é o ""timeout de transação. Timeouts de transação asseguram que nenhuma transação ""possa reter indefinidamente recursos enquanto não retorna nenhuma resposta ""ao usuário. Fora de um ambiente controlado (JTA), o Hibernate não pode ""fornecer inteiramente esta funcionalidade. Entretanto, o Hibernate pode ""afinal controlar as operações do acesso a dados, assegurando que o nível de ""deadlocks e queries do banco de dados com imensos resultados definidos sejam ""limitados pelo timeout. Em um ambiente gerenciado, o Hibernate pode delegar ""o timeout da transação ao JTA. Esta funcionalidade é abstraída pelo objeto ""<literal>Transaction</literal> do Hibernate."#. Tag: programlisting#: transactions.xml:614#, 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:616#, no-c-formatmsgid """Note that <literal>setTimeout()</literal> may not be called in a CMT bean, ""where transaction timeouts must be defined declaratively."msgstr """Veja que <literal>setTimeout()</literal> não pode ser chamado em um CMT ""bean, onde os timeouts das transações devem ser definidos declarativamente."#. Tag: title#: transactions.xml:626#, no-c-formatmsgid "Optimistic concurrency control"msgstr "Controle de concorrência otimista"#. Tag: para#: transactions.xml:628#, 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 """O único caminho que é consistente com a elevada concorrência e ""escalabilidade é controle de concorrência otimista com versionamento. ""Checagem de versão usa número de versão, ou timestamps, para detectar ""conflitos de atualizações (e para impedir atualizações perdidas). O ""Hibernate fornece três caminhos possíveis para escrever aplicações que usam ""concorrência otimista. Os casos de uso que nós mostramos estão no contexto ""de conversações longas, mas a checagem de versão também tem o benefício de ""impedir atualizações perdidas em únicas transações."#. Tag: title#: transactions.xml:639#, no-c-formatmsgid "Application version checking"msgstr "Checagem de versão da aplicação"#. Tag: para#: transactions.xml:641#, 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 """Em uma implementação sem muita ajuda do Hibernate, cada interação com o ""banco de dados ocorre em uma nova <literal>Session</literal> e o ""desenvolvedor é responsável par
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -