1

我需要一些帮助,让我告诉你我的上下文,我们有两个测试环境,其中一个 Web 应用程序被定向到 postgres 中的一个数据库,应用程序在这里运行得很好,在另一个环境中我们有两个数据库从属一台和主一台,在应用程序中显示与数据库相关的错误。

有一个名为讨论的表,另一个名为 network_discussion,当我立即保存讨论时,我保存到 network_discussion,但在第二个环境中不起作用,我认为这与 GRANT 访问有关,但显然不是,这是错误跟踪:

2012-09-15 15:10:27,162|TP-Processor12|ERROR|mp_sites|web|mpmvstage|/home/matchpoint-web/yfroot||Hibernate operation: Could not execute JDBC batch update; uncategorized SQLException for SQL [insert into users.network_discussion (network_id, user_discussion_id, title, last_updated_dt, id) values (?, ?, ?, ?, ?)]; SQL state [null]; error code [0]; Batch entry 0 insert into users.network_discussion (network_id, user_discussion_id, title, last_updated_dt, id) values (33214047252677632, 33495522229786655, company-corp.com_newdisa, 2012-09-15 15:10:27.153000 -07:00, 33495522229786656) was aborted.  Call getNextException to see the cause.; nested exception is java.sql.BatchUpdateException: Batch entry 0 insert into users.network_discussion (network_id, user_discussion_id, title, last_updated_dt, id) values (33214047252677632, 33495522229786655, company-corp.com_newdisa, 2012-09-15 15:10:27.153000 -07:00, 33495522229786656) was aborted.  Call getNextException to see the cause.
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: Could not execute JDBC batch update; uncategorized SQLException for SQL [insert into users.network_discussion (network_id, user_discussion_id, title, last_updated_dt, id) values (?, ?, ?, ?, ?)]; SQL state [null]; error code [0]; Batch entry 0 insert into users.network_discussion (network_id, user_discussion_id, title, last_updated_dt, id) values (33214047252677632, 33495522229786655, company-corp.com_newdisa, 2012-09-15 15:10:27.153000 -07:00, 33495522229786656) was aborted.  Call getNextException to see the cause.; nested exception is java.sql.BatchUpdateException: Batch entry 0 insert into users.network_discussion (network_id, user_discussion_id, title, last_updated_dt, id) values (33214047252677632, 33495522229786655, company-corp.com_newdisa, 2012-09-15 15:10:27.153000 -07:00, 33495522229786656) was aborted.  Call getNextException to see the cause.
java.sql.BatchUpdateException: Batch entry 0 insert into users.network_discussion (network_id, user_discussion_id, title, last_updated_dt, id) values (33214047252677632, 33495522229786655, company-corp.com_newdisa, 2012-09-15 15:10:27.153000 -07:00, 33495522229786656) was aborted.  Call getNextException to see the cause.
    at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2512)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1314)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:347)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2574)
    at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
    at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
    at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
    at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
    at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:584)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:500)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:473)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectSupport.java:267)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
    at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:623)
    at com.netblue.matchpoint.service.DiscussionService$$EnhancerByCGLIB$$b685dad0.addOrGetDiscussions(<generated>)
    at com.netblue.matchpoint.filter.DiscussionFilter.doFilter(DiscussionFilter.java:30)
    at com.netblue.matchpoint.sitecontroller.MpBaseSiteController.getFilteredParams(MpBaseSiteContr

它继续,我的意思是错误跟踪继续更多,所以给我一个想法的任何帮助都会很棒,我已经在谷歌中跟踪了这个,但没有结果,谢谢。

4

2 回答 2

1

BatchUpdateException.getNextException没有帮助(或者它只是返回null)时,也可以在 hibernate 中禁用批处理hibernate.jdbc.factory_class=org.hibernate.jdbc.NonBatchingBatcherFactory在 hibernate 会话配置中设置(当然,这应该只是为了解决问题而不应该永远设置)。

于 2012-11-18T23:34:08.857 回答
1

我实际上解决了这个问题,这真的很痛苦,但感谢上帝,我能做到。正如我所说,它在某些带有数据库的环境中工作,但在另一个环境中不起作用,问题是我有多个保存和依赖寄存器,但第一个需要一些时间才能保存,所以当我保存时第二个寄存器(不同的表第二个取决于第一个)密钥的数据尚未保存,所以我不能像往常一样级联保存,因为它需要更改很多代码,因为这个不是“从零开始”的开发,所以我所做的是更多地挖掘代码并获取数据的确切保存位置,并将其他寄存器的保存放在那里。因此,基本上,如果您正在跟踪那个奇怪的错误,那么没有什么比试图将损坏的数据保存在 DB 中的特别之处了。

于 2012-09-18T04:29:58.787 回答