我正在使用hibernate將對象放入數據庫。 DB是MYSQL社區版。 整個更新運行到事務中。數據庫更新 - 長時間運行操作失敗
,做它是這樣做的代碼:
getHibernateTemplate()saveOrUpdate(順序);
有沒有問題,當訂單雖小,但是當我測試了密切的情況下,以1個000 000項目我就遇到了這個問題:
[email protected]:56:48 DEBUG PersistOrderServiceImpl [flow.ottoImportOrderPlacementInboundFlow.1] - saving order instance::
[Order [orderId=080661, vatOrderNumber=SODE000001, orderDate=Tue Nov 08 10:12:37 CET 2011, shippingMethod=STANDARD, ....
[email protected]:02:12 ERROR JDBCTransaction [flow.ottoImportOrderPlacementInboundFlow.1] - JDBC rollback failed
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
.....
....
[email protected]:02:12 ERROR TransactionInterceptor [flow.ottoImportOrderPlacementInboundFlow.1] - Application exception overridden by rollback exception
java.lang.NullPointerException
at com.mysql.jdbc.Field.setConnection(Field.java:972)
at com.mysql.jdbc.StatementImpl.getGeneratedKeysInternal(StatementImpl.java:1912)
at com.mysql.jdbc.StatementImpl.getGeneratedKeysInternal(StatementImpl.java:1905)
at com.mysql.jdbc.StatementImpl.getGeneratedKeys(StatementImpl.java:1885)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.getGeneratedKeys(NewProxyPreparedStatement.java:1749)
at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:97)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:57)
......
......
看來這個問題後表現總共大約5分24秒或324秒。
我在MySQL日誌中找不到任何關於它的東西。
看來它沒有記憶相關,因爲當我降低內存的例外情況是不同的:
java.lang.OutOfMemoryError: GC overhead limit exceeded
我不知道這是否是在MySQL的休眠某種錯誤的,或者是一些設置限制了更新/連接/事務可以運行的時間。
我在MySQL文檔或Hibernate設置中找不到任何相關內容。
我希望有任何幫助調試或解決此問題。
已解決:問題出在我的tomcat lib中的文件c3p0.properties中。它包含:c3p0.unreturnedConnectionTimeout = 300或多或少的時間後,我得到的錯誤。我刪除它後更新通過,沒有問題。
所以你正在創建1mil的訂單對象,並堅持使用休眠?你可以發佈休眠保存代碼嗎? –
不,我正在用1密爾的物品創造一個訂單。將代碼發佈到該問題。 –