Hibernate 4默认事务超时值

时间:2014-11-18 08:50:51

标签: java mysql spring hibernate timeout

我收到此错误:

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

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

这是我的hibernate配置:

<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>

您知道具有此配置的hibernate事务的默认超时值是什么?

1 个答案:

答案 0 :(得分:0)

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

我在Weblogic控制台上的“mydomain-&gt; Configuration-&gt; JTA”上将“Timeout Seconds:”从300更改为1000(可能会增加更多,这取决于您的事务超时)或增加应用程序服务器上的JTA超时。

然后,对于hibernate.cfg.xml,您可以查看以下答案:Hibernate/MySQL Connection Timeout

有效。