简体   繁体   English

Hibernate 4默认事务超时值

[英]Hibernate 4 default transaction timeout value

I'm getting this error: 我收到此错误:

2014-11-14 17:39:44 [WARN]SqlExceptionHelper:143    SQL Error: 0, SQLState: 08S01
2014-11-14 17:39:44 [ERROR]SqlExceptionHelper:144   Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
2014-11-14 17:39:44 [ERROR]BackupService:245    org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Could not open connection

Seems that Hibernate has a small transaction timeout for my job, but I can not find what is the default timeout value. 似乎Hibernate对我的工作来说有一个小的事务超时,但是我找不到默认的超时值。 I did not find it also in hibernate documentation, I find how to change it, but not the default value. 我也没有在休眠文档中找到它,我找到了如何更改它,但是没有更改默认值。

This is my hibernate configuration: 这是我的休眠配置:

<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="packagesToScan">
            <list>
                <value>com.test.db.entity</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
                <prop key="hibernate.show_sql">false</prop>             
                <prop key="hibernate.bytecode.use_reflection_optimizer">false</prop>
                <prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                <prop key="hibernate.search.autoregister_listeners">false</prop>
                <prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</prop>         
            </props>
        </property>
</bean>

Do you know what is the default timeout value for an hibernate transaction with this configuration? 您知道使用此配置的休眠事务的默认超时值是多少吗?

I got the same exception. 我有同样的例外。 I googled and found your question without answer :) 我用Google搜索,发现您的问题没有答案:)

I changed "Timeout Seconds:" from 300 to 1000 (possible to increase more, it depends on your transaction timeout) on "mydomain->Configuration->JTA" on Weblogic Console or increase JTA timeout on your application server. 我在Weblogic Console上的“ mydomain-> Configuration-> JTA”上将“超时秒数”从300更改为1000(可能会增加,具体取决于您的事务超时),或者将应用程序服务器上的JTA超时增加。

Then, for hibernate.cfg.xml you may check this answer: Hibernate/MySQL Connection Timeout 然后,对于hibernate.cfg.xml,您可以检查以下答案: Hibernate / MySQL连接超时

It works. 有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM