java Hibernate 4 默认事务超时值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26990090/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 11:00:40  来源:igfitidea点击:

Hibernate 4 default transaction timeout value

javamysqlspringhibernatetimeout

提问by Tobia

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. I did not find it also in hibernate documentation, I find how to change it, but not the default value.

似乎 Hibernate 对我的工作有一个小的事务超时,但我找不到默认超时值是多少。我也没有在 hibernate 文档中找到它,我找到了如何更改它,但没有找到默认值。

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?

您知道具有此配置的休眠事务的默认超时值是多少吗?

采纳答案by Sedat Polat

I got the same exception. I googled and found your question without answer :)

我得到了同样的例外。我用谷歌搜索,发现你的问题没有答案:)

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 控制台上的“mydomain->Configuration->JTA”上将“Timeout Seconds:”从 300 更改为 1000(可能会增加更多,这取决于您的事务超时),或者在您的应用程序服务器上增加 JTA 超时。

Then, for hibernate.cfg.xml you may check this answer: Hibernate/MySQL Connection Timeout

然后,对于 hibernate.cfg.xml 你可以检查这个答案:Hibernate/MySQL Connection Timeout

It works.

有用。