【发布时间】:2012-07-04 01:19:07
【问题描述】:
在我看来,我们有一些代码尚未启动事务,用于只读操作,我们通过 JPA/Hibernate 和直接 SQL 的查询似乎可以工作。我们的框架会打开一个 hibernate/jpa 会话,但是对于遗留代码中的一些地方,我们发现没有打开任何事务。
似乎最终发生的是,只要不使用 EntityManager.persist 和 EntityManager.merge,代码通常就会运行。但是偶尔(可能是 1/10)次 servlet 容器会因此错误而失败...
Failed to load resource: the server responded with a status of 500 (org.hibernate.exception.JDBCConnectionException: The last packet successfully received from the server was 314,024,057 milliseconds ago. The last packet sent successfully to the server was 314,024,057 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.)
据我所知,我们的应用程序代码中只有少数几个在查询之前没有启动事务的地方会出现这个问题。有没有其他人认为可能是运行的非事务性查询导致了这种行为?
仅供参考,这是我们的堆栈...
-Guice -Guice-坚持 -Guice-Servlet -MySql 5.1.63 -休眠/C3P0 4.1.4.Final -码头
【问题讨论】:
标签: java mysql hibernate jdbc guice-persist