我开发了一个带GWT的Web应用程序。我只创建一个EntityManagerFactory(单例),但我不知道什么时候必须关闭它。我按照这个网页的指示:http://javanotepad.blogspot.com/2007/05/jpa-entitymanagerfactory-in-web.html,且8个小时没有进入我的应用程序后,我有错误:在Web应用程序中管理EntityManagerFactory
78616509 [http-9080-Processor4] ERROR org.hibernate.transaction.JDBCTransaction - JDBC begin failed
com.mysql.jdbc.CommunicationsException: The last packet successfully received from the server was 44,115,64
4 milliseconds ago. The last packet sent successfully to the server was 44,115,644 milliseconds ago. is lo
nger 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 tim
eouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1112)
后2或3次尝试一切工作正常。如果我在每次事务之后关闭EntityManagerFactory,我没有问题,但我不想那样做。我想知道如何管理EntityManagerFactory循环。
在此先感谢。